diff --git a/aws/resource_aws_ssm_parameter.go b/aws/resource_aws_ssm_parameter.go index d2094a8b266..59945679a5f 100644 --- a/aws/resource_aws_ssm_parameter.go +++ b/aws/resource_aws_ssm_parameter.go @@ -33,6 +33,15 @@ func resourceAwsSsmParameter() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "tier": { + Type: schema.TypeString, + Optional: true, + Default: ssm.ParameterTierStandard, + ValidateFunc: validation.StringInSlice([]string{ + ssm.ParameterTierStandard, + ssm.ParameterTierAdvanced, + }, false), + }, "type": { Type: schema.TypeString, Required: true, @@ -127,6 +136,7 @@ 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("allowed_pattern", detail.AllowedPattern) if tagList, err := ssmconn.ListTagsForResource(&ssm.ListTagsForResourceInput{ @@ -173,6 +183,7 @@ func resourceAwsSsmParameterPut(d *schema.ResourceData, meta interface{}) error paramInput := &ssm.PutParameterInput{ Name: aws.String(d.Get("name").(string)), Type: aws.String(d.Get("type").(string)), + Tier: aws.String(d.Get("tier").(string)), Value: aws.String(d.Get("value").(string)), Overwrite: aws.Bool(shouldUpdateSsmParameter(d)), AllowedPattern: aws.String(d.Get("allowed_pattern").(string)), diff --git a/aws/resource_aws_ssm_parameter_test.go b/aws/resource_aws_ssm_parameter_test.go index 025276914e5..dbf4a176ea2 100644 --- a/aws/resource_aws_ssm_parameter_test.go +++ b/aws/resource_aws_ssm_parameter_test.go @@ -53,6 +53,33 @@ func TestAccAWSSSMParameter_basic(t *testing.T) { regexp.MustCompile(fmt.Sprintf("^arn:aws:ssm:[a-z0-9-]+:[0-9]{12}: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"), + resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "tags.%", "1"), + resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "tags.Name", "My Parameter"), + ), + }, + }, + }) +} + +func TestAccAWSSSMParameter_Tier(t *testing.T) { + var param ssm.Parameter + name := fmt.Sprintf("%s_%s", t.Name(), acctest.RandString(10)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSSMParameterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSSMAdvancedParameterConfig(name, "String", "bar"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSSMParameterExists("aws_ssm_parameter.foo", ¶m), + resource.TestMatchResourceAttr("aws_ssm_parameter.foo", "arn", + regexp.MustCompile(fmt.Sprintf("^arn:aws:ssm:[a-z0-9-]+:[0-9]{12}: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", "Advanced"), resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "tags.%", "1"), resource.TestCheckResourceAttr("aws_ssm_parameter.foo", "tags.Name", "My Parameter"), ), @@ -379,6 +406,20 @@ resource "aws_ssm_parameter" "foo" { `, rName, pType, value) } +func testAccAWSSSMAdvancedParameterConfig(rName, pType, value string) string { + return fmt.Sprintf(` +resource "aws_ssm_parameter" "foo" { + name = "%s" + type = "%s" + value = "%s" + tier = "Advanced" + tags = { + Name = "My Parameter" + } +} +`, rName, pType, value) +} + func testAccAWSSSMParameterBasicConfigTagsUpdated(rName, pType, value string) string { return fmt.Sprintf(` resource "aws_ssm_parameter" "foo" { diff --git a/website/docs/r/ssm_parameter.html.markdown b/website/docs/r/ssm_parameter.html.markdown index 59b337c38f0..bccbbc58aed 100644 --- a/website/docs/r/ssm_parameter.html.markdown +++ b/website/docs/r/ssm_parameter.html.markdown @@ -61,6 +61,7 @@ The following arguments are supported: * `type` - (Required) The type of the parameter. Valid types are `String`, `StringList` and `SecureString`. * `value` - (Required) The value of the parameter. * `description` - (Optional) The description of the parameter. +* `tier` - (Optional) The tier of the parameter. If not specified, will default to `Standard`. Valid tiers are `Standard` and `Advanced`. For more information on parameter tiers, see the [AWS SSM Parameter tier comparison and guide](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-advanced-parameters.html). * `key_id` - (Optional) The KMS key id or arn for encrypting a SecureString. * `overwrite` - (Optional) Overwrite an existing parameter. If not specified, will default to `false` if the resource has not been created by terraform to avoid overwrite of existing resource and will default to `true` otherwise (terraform lifecycle rules should then be used to manage the update behavior). * `allowed_pattern` - (Optional) A regular expression used to validate the parameter value.