Skip to content

Commit

Permalink
resource/aws_ssm_parameter: ForceNew on ssm_parameter rename
Browse files Browse the repository at this point in the history
Fixes: #1008

There doesn't seem to be a way to change the name of an AWS SSM
Parameter. Therefore, it should be marked as ForceNew.

```
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSSSMParameter_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSSMParameter_ -timeout 120m
=== RUN   TestAccAWSSSMParameter_basic
--- PASS: TestAccAWSSSMParameter_basic (25.06s)
=== RUN   TestAccAWSSSMParameter_update
--- PASS: TestAccAWSSSMParameter_update (43.21s)
=== RUN   TestAccAWSSSMParameter_changeNameForcesNew
--- PASS: TestAccAWSSSMParameter_changeNameForcesNew (40.84s)
=== RUN   TestAccAWSSSMParameter_secure
--- PASS: TestAccAWSSSMParameter_secure (37.90s)
=== RUN   TestAccAWSSSMParameter_secure_with_key
--- PASS: TestAccAWSSSMParameter_secure_with_key (73.26s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	220.297s
```
  • Loading branch information
stack72 committed Jun 30, 2017
1 parent b315c47 commit 09e8b8d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions aws/resource_aws_ssm_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func resourceAwsSsmParameter() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"type": {
Type: schema.TypeString,
Expand Down
29 changes: 29 additions & 0 deletions aws/resource_aws_ssm_parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ func TestAccAWSSSMParameter_update(t *testing.T) {
})
}

func TestAccAWSSSMParameter_changeNameForcesNew(t *testing.T) {
name := acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSSMParameterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSSSMParameterBasicConfig(name, "bar"),
},
{
Config: testAccAWSSSMParameterBasicConfigChangeName(name, "baz1"),
PlanOnly: true,
ExpectNonEmptyPlan: true,
},
},
})
}

func TestAccAWSSSMParameter_secure(t *testing.T) {
name := acctest.RandString(10)
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -183,6 +202,16 @@ resource "aws_ssm_parameter" "foo" {
`, rName, value)
}

func testAccAWSSSMParameterBasicConfigChangeName(rName string, value string) string {
return fmt.Sprintf(`
resource "aws_ssm_parameter" "foo" {
name = "test_parameter-%s"
type = "String"
value = "%s"
}
`, rName, value)
}

func testAccAWSSSMParameterBasicConfigOverwrite(rName string, value string) string {
return fmt.Sprintf(`
resource "aws_ssm_parameter" "foo" {
Expand Down

0 comments on commit 09e8b8d

Please sign in to comment.