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

Incorrect ARN output for aws_ssm_parameter #2593

Closed
jurajseffer opened this issue Dec 8, 2017 · 6 comments
Closed

Incorrect ARN output for aws_ssm_parameter #2593

jurajseffer opened this issue Dec 8, 2017 · 6 comments
Milestone

Comments

@jurajseffer
Copy link
Contributor

jurajseffer commented Dec 8, 2017

Terraform Version

  • Terraform v0.11.0
  • provider.aws v1.5.0

Affected Resource(s)

aws_ssm_parameter

Terraform confg

resource "aws_ssm_parameter" "some_key" {
  name      = "/some/path"
  type      = "SecureString"
  value     = "${var.some_key}"
  overwrite = true
}

resource "aws_iam_role_policy" "some_policy" {
...
{
  "Effect": "Allow",
  "Resource": [
    "${aws_ssm_parameter.some_key.arn}",
  ],
   "Action": [
     "ssm:GetParameter*"
  ]
}
...

ARN exported for this type of resource has a double slash (//) after the word parameter. I've tried creating a parameter without the leading slash but Terraform throws an AWS API error:
aws_ssm_parameter.some_key: [ERROR] Error creating SSM parameter: ValidationException: Parameter name must be a fully qualified name.

The double slash is a problem because when I include the ARN into a policy for an IAM role, I get "unauthorized" response from AWS. Permissions work once one of the slashes is manually removed.

Perhaps this is caused by the trailing slash after parameter in https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_ssm_parameter.go#L94

The obvious workaround is to manually construct the ARN or use replace function.

@bflad
Copy link
Contributor

bflad commented Dec 9, 2017

Hi @jurajseffer, thanks for this bug report! It certainly looks like this is an issue since the ID will include the leading /. I was able to verify in the acceptance testing by making the ARN attribute test more robust with a regex instead of just testing existence:

	testing.go:503: Step 0 error: Check failed: Check 2/4 error: aws_ssm_parameter.foo: Attribute 'arn' didn't match "^arn:aws:ssm:[a-z0-9-]+:[0-9]{12}:parameter/path/TestAccAWSSSMParameter_fullPath_dud3bzqera$", got "arn:aws:ssm:us-west-2:193075746082:parameter//path/TestAccAWSSSMParameter_fullPath_dud3bzqera"

I have submitted #2604 with the bugfix and enhanced testing. 😄

@jen20
Copy link
Contributor

jen20 commented Dec 17, 2017

This should be fixed in 6cd9169 (rebased #2604) - thanks for the report!

@jen20 jen20 closed this as completed Dec 17, 2017
@jerthom
Copy link

jerthom commented Jan 17, 2018

@seppi91
Copy link

seppi91 commented Jan 18, 2018

Please reopen this issue as it still exists in aws_ssm_parameter data source as @jerthom described.

@bflad
Copy link
Contributor

bflad commented Feb 9, 2018

The data source fix has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 8, 2020

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 and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants