Skip to content

Commit

Permalink
Merge branch 'kuroseets-b_aws_ssm_parameter_arn'
Browse files Browse the repository at this point in the history
  • Loading branch information
bflad committed Feb 12, 2021
2 parents 8b42218 + 2572df9 commit 1a49802
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .changelog/16618.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ssm_parameter: Use ARN value from API response rather than generating the value
```
13 changes: 2 additions & 11 deletions aws/data_source_aws_ssm_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 1 addition & 10 deletions aws/resource_aws_ssm_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1a49802

Please sign in to comment.