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

resource/aws_ssm_parameter: ForceNew on ssm_parameter rename #1022

Merged
merged 1 commit into from
Jul 6, 2017
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
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
44 changes: 44 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,27 @@ func TestAccAWSSSMParameter_update(t *testing.T) {
})
}

func TestAccAWSSSMParameter_changeNameForcesNew(t *testing.T) {
before := acctest.RandString(10)
after := acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSSMParameterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSSSMParameterBasicConfig(before, "bar"),
},
{
Config: testAccAWSSSMParameterBasicConfig(after, "bar"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSSMParameterDestroyed(before),
),
},
},
})
}

func TestAccAWSSSMParameter_secure(t *testing.T) {
name := acctest.RandString(10)
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -147,6 +168,29 @@ func testAccCheckAWSSSMParameterType(n string, v string) resource.TestCheckFunc
}
}

func testAccCheckAWSSSMParameterDestroyed(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ssmconn

paramInput := &ssm.GetParametersInput{
Names: []*string{
aws.String(name),
},
}

resp, err := conn.GetParameters(paramInput)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned on Slack - I'm surprised this doesn't return a 404 but ¯_(ツ)_/¯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will return an empty response object :) But a response none the less

return err
}

if len(resp.Parameters) > 0 {
return fmt.Errorf("Expected AWS SSM Parameter to be gone, but was still found")
}

return nil
}
}

func testAccCheckAWSSSMParameterDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).ssmconn

Expand Down