From bb2e200b02d5bc942c09d047b1aded7667358ec7 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 7 Mar 2023 09:05:37 -0500 Subject: [PATCH] r/aws_db_instance: Set 'listener_endpoint' even if API result is nil. --- internal/service/rds/instance.go | 2 ++ internal/service/rds/instance_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index 687955c12e8..c62ece13b48 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -1671,6 +1671,8 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte if err := d.Set("listener_endpoint", []interface{}{flattenEndpoint(v.ListenerEndpoint)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting listener_endpoint: %s", err) } + } else { + d.Set("listener_endpoint", nil) } dbSetResourceDataEngineVersionFromInstance(d, v) diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index 202e22a64ff..feddd6caddd 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -65,6 +65,7 @@ func TestAccRDSInstance_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "instance_class", "data.aws_rds_orderable_db_instance.test", "instance_class"), resource.TestCheckResourceAttr(resourceName, "iops", "0"), resource.TestCheckResourceAttr(resourceName, "license_model", "general-public-license"), + resource.TestCheckResourceAttr(resourceName, "listener_endpoint.#", "0"), resource.TestCheckResourceAttrSet(resourceName, "maintenance_window"), resource.TestCheckResourceAttr(resourceName, "max_allocated_storage", "0"), resource.TestCheckResourceAttr(resourceName, "name", "test"), @@ -2827,6 +2828,7 @@ func TestAccRDSInstance_SnapshotIdentifier_multiAZSQLServer(t *testing.T) { testAccCheckInstanceExists(ctx, sourceDbResourceName, &sourceDbInstance), testAccCheckDBSnapshotExists(ctx, snapshotResourceName, &dbSnapshot), testAccCheckInstanceExists(ctx, resourceName, &dbInstance), + resource.TestCheckResourceAttr(resourceName, "listener_endpoint.#", "1"), resource.TestCheckResourceAttr(resourceName, "multi_az", "true"), ), },