Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add skip_destroy to be present in diff. #30354

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/30354.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_cloudwatch_log_group: Fix `invalid new value for .skip_destroy: was cty.False, but now null` errors
```
2 changes: 2 additions & 0 deletions internal/service/logs/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func resourceGroupRead(ctx context.Context, d *schema.ResourceData, meta interfa
d.Set("name", lg.LogGroupName)
d.Set("name_prefix", create.NamePrefixFromName(aws.ToString(lg.LogGroupName)))
d.Set("retention_in_days", lg.RetentionInDays)
// Support in-place update of non-refreshable attribute.
d.Set("skip_destroy", d.Get("skip_destroy"))

tags, err := listLogGroupTags(ctx, conn, d.Id())

Expand Down
72 changes: 48 additions & 24 deletions internal/service/logs/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ func TestAccLogsGroup_basic(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days", "skip_destroy"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand All @@ -79,10 +78,9 @@ func TestAccLogsGroup_nameGenerate(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days", "skip_destroy"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand All @@ -108,10 +106,9 @@ func TestAccLogsGroup_namePrefix(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days", "skip_destroy"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand Down Expand Up @@ -162,10 +159,9 @@ func TestAccLogsGroup_tags(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days", "skip_destroy"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccGroupConfig_tags2(rName, "key1", "value1updated", "key2", "value2"),
Expand Down Expand Up @@ -210,10 +206,9 @@ func TestAccLogsGroup_kmsKey(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days", "skip_destroy"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccGroupConfig_kmsKey(rName, 1),
Expand Down Expand Up @@ -287,10 +282,9 @@ func TestAccLogsGroup_retentionPolicy(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days", "skip_destroy"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccGroupConfig_retentionPolicy(rName, 0),
Expand Down Expand Up @@ -352,6 +346,36 @@ func TestAccLogsGroup_skipDestroy(t *testing.T) {
})
}

func TestAccLogsGroup_skipDestroyInconsistentPlan(t *testing.T) {
ctx := acctest.Context(t)
var v types.LogGroup
rName := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
resourceName := "aws_cloudwatch_log_group.test"

acctest.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.CloudWatchLogsEndpointID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckGroupDestroy(ctx, t),
Steps: []resource.TestStep{
{
Config: testAccGroupConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckGroupExists(ctx, t, resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "skip_destroy", "false"),
),
},
{
Config: testAccGroupConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckGroupExists(ctx, t, resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "skip_destroy", "false"),
),
},
},
})
}

func testAccCheckGroupExists(ctx context.Context, t *testing.T, n string, v *types.LogGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down
Loading