diff --git a/.changelog/16618.txt b/.changelog/16618.txt new file mode 100644 index 00000000000..94273c6bc98 --- /dev/null +++ b/.changelog/16618.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_ssm_parameter: Use ARN value from API response rather than generating the value +``` diff --git a/aws/data_source_aws_ssm_parameter.go b/aws/data_source_aws_ssm_parameter.go index 9d77076c45c..10039abd244 100644 --- a/aws/data_source_aws_ssm_parameter.go +++ b/aws/data_source_aws_ssm_parameter.go @@ -3,10 +3,8 @@ package aws import ( "fmt" "log" - "strings" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/ssm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -63,16 +61,9 @@ func dataAwsSsmParameterRead(d *schema.ResourceData, meta interface{}) error { } param := resp.Parameter - d.SetId(aws.StringValue(param.Name)) - arn := arn.ARN{ - Partition: meta.(*AWSClient).partition, - Region: meta.(*AWSClient).region, - Service: "ssm", - AccountID: meta.(*AWSClient).accountid, - Resource: fmt.Sprintf("parameter/%s", strings.TrimPrefix(d.Id(), "/")), - } - d.Set("arn", arn.String()) + d.SetId(aws.StringValue(param.Name)) + d.Set("arn", param.ARN) d.Set("name", param.Name) d.Set("type", param.Type) d.Set("value", param.Value) diff --git a/aws/resource_aws_ssm_parameter.go b/aws/resource_aws_ssm_parameter.go index d577a47bdde..b085eee4080 100644 --- a/aws/resource_aws_ssm_parameter.go +++ b/aws/resource_aws_ssm_parameter.go @@ -4,11 +4,9 @@ import ( "context" "fmt" "log" - "strings" "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/ssm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -197,14 +195,7 @@ func resourceAwsSsmParameterRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error setting tags: %s", err) } - arn := arn.ARN{ - Partition: meta.(*AWSClient).partition, - Region: meta.(*AWSClient).region, - Service: "ssm", - AccountID: meta.(*AWSClient).accountid, - Resource: fmt.Sprintf("parameter/%s", strings.TrimPrefix(d.Id(), "/")), - } - d.Set("arn", arn.String()) + d.Set("arn", param.ARN) return nil } diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index dad41e5b6e7..581650db962 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -325,8 +325,6 @@ for more information about connecting to alternate AWS endpoints or AWS compatib - [`aws_ses_template` resource](/docs/providers/aws/r/ses_template.html) - [`aws_ssm_document` data source](/docs/providers/aws/d/ssm_document.html) - [`aws_ssm_document` resource](/docs/providers/aws/r/ssm_document.html) - - [`aws_ssm_parameter` data source](/docs/providers/aws/d/ssm_parameter.html) - - [`aws_ssm_parameter` resource](/docs/providers/aws/r/ssm_parameter.html) - [`aws_vpc` data source](/docs/providers/aws/d/vpc.html) - [`aws_vpc` resource](/docs/providers/aws/r/vpc.html) - [`aws_vpc_dhcp_options` data source](/docs/providers/aws/d/vpc_dhcp_options.html)