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

Adding Forcenew for data_type in SSM parameter #35960

Merged
merged 5 commits into from
Mar 26, 2024
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/35960.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ssm_parameter: force create a new SSM parameter when `data_type` is updated.
```
1 change: 1 addition & 0 deletions internal/service/ssm/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func ResourceParameter() *schema.Resource {
"aws:ssm:integration",
"text",
}, false),
ForceNew: true,
},
"description": {
Type: schema.TypeString,
Expand Down
49 changes: 49 additions & 0 deletions internal/service/ssm/parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,42 @@ func TestAccSSMParameter_DataType_ssmIntegration(t *testing.T) {
})
}

func TestAccSSMParameter_DataType_update(t *testing.T) {
ctx := acctest.Context(t)
var param ssm.Parameter
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_ssm_parameter.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.SSMServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckParameterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccParameterConfig_dataTypeUpdate(rName, "text"),
Check: resource.ComposeTestCheckFunc(
testAccCheckParameterExists(ctx, resourceName, &param),
resource.TestCheckResourceAttr(resourceName, "data_type", "text"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"overwrite"},
},
{
Config: testAccParameterConfig_dataTypeUpdate(rName, "aws:ec2:image"),
Check: resource.ComposeTestCheckFunc(
testAccCheckParameterExists(ctx, resourceName, &param),
resource.TestCheckResourceAttr(resourceName, "data_type", "aws:ec2:image"),
),
},
},
})
}

func TestAccSSMParameter_Secure_key(t *testing.T) {
ctx := acctest.Context(t)
var param ssm.Parameter
Expand Down Expand Up @@ -1328,6 +1364,19 @@ resource "aws_ssm_parameter" "test" {
`, rName))
}

func testAccParameterConfig_dataTypeUpdate(rName, datatype string) string {
return acctest.ConfigCompose(
acctest.ConfigLatestAmazonLinux2HVMEBSX8664AMI(),
fmt.Sprintf(`
resource "aws_ssm_parameter" "test" {
name = %[1]q
data_type = %[2]q
type = "String"
value = data.aws_ami.amzn2-ami-minimal-hvm-ebs-x86_64.id
}
`, rName, datatype))
}

func testAccParameterConfig_dataTypeSSMIntegration(rName string) string { // nosemgrep:ci.ssm-in-func-name
return acctest.ConfigCompose(
fmt.Sprintf(`
Expand Down
Loading