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

The ARN obtained from the public parameter in data.aws_ssm_parameter is changed #16483

Closed
kuroseets opened this issue Nov 30, 2020 · 2 comments · Fixed by #16618
Closed

The ARN obtained from the public parameter in data.aws_ssm_parameter is changed #16483

kuroseets opened this issue Nov 30, 2020 · 2 comments · Fixed by #16618
Assignees
Labels
bug Addresses a defect in current functionality. service/ssm Issues and PRs that pertain to the ssm service.
Milestone

Comments

@kuroseets
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/aws v3.18.0

Affected Resource(s)

  • aws_ssm_parameter

Terraform Configuration Files

provider "aws" {
  region     = "ap-northeast-1"
}

data aws_ssm_parameter "amzn2_ami" {
  name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
}

Debug Output

terraform apply -auto-approve
data.aws_ssm_parameter.amzn2_ami: Refreshing state...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Expected Behavior

I should be able to get the resources of the public parameter store.

$ cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "0.13.5",
  "serial": 1,
  "lineage": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "outputs": {},
  "resources": [
    {
      "mode": "data",
      "type": "aws_ssm_parameter",
      "name": "amzn2_ami",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ssm:ap-northeast-1::parameter/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "id": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "name": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "type": "String",
            "value": "ami-XXXXXXXXXXXXXXXXX",
            "version": XX,
            "with_decryption": true
          }
        }
      ]
    }
  ]
}

Actual Behavior

but, ARN is strange, includes account ID.

$ cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "0.13.5",
  "serial": 1,
  "lineage": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "outputs": {},
  "resources": [
    {
      "mode": "data",
      "type": "aws_ssm_parameter",
      "name": "amzn2_ami",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ssm:ap-northeast-1:XXXXXXXXXXXX:parameter/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "id": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "name": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2",
            "type": "String",
            "value": "ami-XXXXXXXXXXXXXXXXX",
            "version": XX,
            "with_decryption": true
          }
        }
      ]
    }
  ]
}

It looks like I'm recreating a new ARN without using the return value.

param := resp.Parameter
d.SetId(*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.Set("name", param.Name)
d.Set("type", param.Type)
d.Set("value", param.Value)
d.Set("version", param.Version)

@ghost ghost added the service/ssm Issues and PRs that pertain to the ssm service. label Nov 30, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 30, 2020
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Feb 12, 2021
@bflad bflad self-assigned this Feb 12, 2021
@github-actions github-actions bot added this to the v3.28.0 milestone Feb 12, 2021
@ghost
Copy link

ghost commented Feb 12, 2021

This has been released in version 3.28.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Mar 14, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ssm Issues and PRs that pertain to the ssm service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants