diff --git a/jetstream/resource_kv_bucket.go b/jetstream/resource_kv_bucket.go index fb69648..ba32c02 100644 --- a/jetstream/resource_kv_bucket.go +++ b/jetstream/resource_kv_bucket.go @@ -172,6 +172,10 @@ func resourceKVBucketRead(d *schema.ResourceData, m any) error { } bucket, err := js.KeyValue(name) if err != nil { + if err == nats.ErrBucketNotFound { + d.SetId("") + return nil + } return err } status, err := bucket.Status() diff --git a/jetstream/resource_kv_entry.go b/jetstream/resource_kv_entry.go index 3828950..992d405 100644 --- a/jetstream/resource_kv_entry.go +++ b/jetstream/resource_kv_entry.go @@ -93,10 +93,18 @@ func resourceKVEntryRead(d *schema.ResourceData, m any) error { } kv, err := js.KeyValue(bucket) if err != nil { + if err == nats.ErrBucketNotFound { + d.SetId("") + return nil + } return err } entry, err := kv.Get(key) if err != nil { + if err == nats.ErrKeyNotFound { + d.SetId("") + return nil + } return err }