diff --git a/.changelog/31449.txt b/.changelog/31449.txt new file mode 100644 index 00000000000..212065c70d7 --- /dev/null +++ b/.changelog/31449.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_ecr_registry_scanning_configuration: Correctly delete rules on resource Update +``` \ No newline at end of file diff --git a/internal/service/ecr/registry_scanning_configuration.go b/internal/service/ecr/registry_scanning_configuration.go index b47ca40a6f7..a857f5f21af 100644 --- a/internal/service/ecr/registry_scanning_configuration.go +++ b/internal/service/ecr/registry_scanning_configuration.go @@ -136,10 +136,6 @@ func resourceRegistryScanningConfigurationDelete(ctx context.Context, d *schema. // Helper functions func expandScanningRegistryRules(l []interface{}) []*ecr.RegistryScanningRule { - if len(l) == 0 || l[0] == nil { - return nil - } - rules := make([]*ecr.RegistryScanningRule, 0) for _, rule := range l { diff --git a/internal/service/ecr/registry_scanning_configuration_test.go b/internal/service/ecr/registry_scanning_configuration_test.go index 6fb0d2d9004..bf9b17940db 100644 --- a/internal/service/ecr/registry_scanning_configuration_test.go +++ b/internal/service/ecr/registry_scanning_configuration_test.go @@ -109,6 +109,25 @@ func testAccRegistryScanningConfiguration_update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "scan_type", "ENHANCED"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccRegistryScanningConfigurationConfig_basic(), + Check: resource.ComposeTestCheckFunc( + testAccRegistryScanningConfigurationExists(ctx, resourceName, &v), + acctest.CheckResourceAttrAccountID(resourceName, "registry_id"), + resource.TestCheckResourceAttr(resourceName, "rule.#", "0"), + resource.TestCheckResourceAttr(resourceName, "scan_type", "BASIC"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) }