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: Remove Tier from PutParameter if unsupported, fix testing for GovCloud #8664

Merged
merged 2 commits into from
May 17, 2019
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
14 changes: 12 additions & 2 deletions aws/resource_aws_ssm_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ func resourceAwsSsmParameterRead(d *schema.ResourceData, meta interface{}) error
detail := describeResp.Parameters[0]
d.Set("key_id", detail.KeyId)
d.Set("description", detail.Description)
d.Set("tier", detail.Tier)
d.Set("tier", ssm.ParameterTierStandard)
if detail.Tier != nil {
d.Set("tier", detail.Tier)
}
d.Set("allowed_pattern", detail.AllowedPattern)

if tagList, err := ssmconn.ListTagsForResource(&ssm.ListTagsForResourceInput{
Expand Down Expand Up @@ -209,7 +212,14 @@ func resourceAwsSsmParameterPut(d *schema.ResourceData, meta interface{}) error
}

log.Printf("[DEBUG] Waiting for SSM Parameter %v to be updated", d.Get("name"))
if _, err := ssmconn.PutParameter(paramInput); err != nil {
_, err := ssmconn.PutParameter(paramInput)

if isAWSErr(err, "ValidationException", "Tier is not supported") {
paramInput.Tier = nil
_, err = ssmconn.PutParameter(paramInput)
}

if err != nil {
return fmt.Errorf("error creating SSM parameter: %s", err)
}

Expand Down
7 changes: 2 additions & 5 deletions aws/resource_aws_ssm_parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aws

import (
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -49,8 +48,7 @@ func TestAccAWSSSMParameter_basic(t *testing.T) {
Config: testAccAWSSSMParameterBasicConfig(name, "String", "bar"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSSMParameterExists("aws_ssm_parameter.foo", &param),
resource.TestMatchResourceAttr("aws_ssm_parameter.foo", "arn",
regexp.MustCompile(fmt.Sprintf("^arn:aws:ssm:[a-z0-9-]+:[0-9]{12}:parameter/%s$", name))),
testAccCheckResourceAttrRegionalARN("aws_ssm_parameter.foo", "arn", "ssm", fmt.Sprintf("parameter/%s", name)),
resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "value", "bar"),
resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "type", "String"),
resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "tier", "Standard"),
Expand Down Expand Up @@ -230,8 +228,7 @@ func TestAccAWSSSMParameter_fullPath(t *testing.T) {
Config: testAccAWSSSMParameterBasicConfig(name, "String", "bar"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSSMParameterExists("aws_ssm_parameter.foo", &param),
resource.TestMatchResourceAttr("aws_ssm_parameter.foo", "arn",
regexp.MustCompile(fmt.Sprintf("^arn:aws:ssm:[a-z0-9-]+:[0-9]{12}:parameter%s$", name))),
testAccCheckResourceAttrRegionalARN("aws_ssm_parameter.foo", "arn", "ssm", fmt.Sprintf("parameter%s", name)),
resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "value", "bar"),
resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "type", "String"),
),
Expand Down