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

validateArn incorrectly rejects ARNs in isolated AWS regions #8307

Closed
ccday opened this issue Apr 12, 2019 · 7 comments
Closed

validateArn incorrectly rejects ARNs in isolated AWS regions #8307

ccday opened this issue Apr 12, 2019 · 7 comments
Labels
bug Addresses a defect in current functionality. partition/aws-iso Pertains to the aws-iso partition. partition/aws-iso-b Pertains to the aws-iso-b partition. provider Pertains to the provider itself, rather than any interaction with AWS.
Milestone

Comments

@ccday
Copy link

ccday commented Apr 12, 2019

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 "me too" comments, 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 Version

Terraform v0.11.13

  • provider.aws v2.6.0

Affected Resource(s)

  • All resources that have a field that uses validateArn for validation

Terraform Configuration Files

resource "aws_ebs_volume" "test" {
  // Some configuration...

  encrypted = true
  kms_key_id = "arn:aws-iso:kms:us-iso-east-1:012345678901:key/some-uuid-abc123"
}

Expected Behavior

The ARN should validate.

Actual Behavior

The ARN does not validate:

aws_ebs_volume.test: "kms_key_id" doesn't look like a valid ARN ("^arn:[\\w-]+:([a-zA-Z0-9\\-])+:([a-z]{2}-(gov-)?[a-z]+-\\d{1})?:(\\d{12})?:(.*)$"): <arn here>

Suggested fix is to update the regex in the validateArn function of aws/validators.go to match on ARNs from the iso and isob partitions:

pattern := `^arn:[\w-]+:([a-zA-Z0-9\-])+:([a-z]{2}-((?:gov|iso|isob)-)?[a-z]+-\d{1})?:(\d{12})?:(.*)$`

Steps to Reproduce

  1. Create a configuration that uses an ARN from an isolated AWS region.
  2. terraform validate

Important Factoids

This account is located in an isolated AWS region.

@ccday
Copy link
Author

ccday commented Apr 12, 2019

I'd be happy to make a PR with a fix for this issue - let me know if the suggested fix sounds good.

@aeschright aeschright added needs-triage Waiting for first response or review from a maintainer. provider Pertains to the provider itself, rather than any interaction with AWS. labels Jun 20, 2019
@ewbankkit
Copy link
Contributor

@ewbankkit
Copy link
Contributor

Probably most sustainable is to use the AWS SDK's arn.Parse method.
It doesn't validate quite as extensively the regex but its the regex that is brittle and it will certainly catch the most common types of errors which are probably usage of a resource ID or name instead of an ARN.

@aeschright aeschright added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 13, 2019
@ewbankkit
Copy link
Contributor

@bflad bflad added partition/aws-iso Pertains to the aws-iso partition. partition/aws-iso-b Pertains to the aws-iso-b partition. labels Jan 7, 2020
@bflad bflad added this to the v2.44.0 milestone Jan 7, 2020
@bflad
Copy link
Contributor

bflad commented Jan 7, 2020

The fix for this has been merged and will release with version 2.44.0 of the Terraform AWS Provider, on Thursday. 👍

@bflad bflad closed this as completed Jan 7, 2020
@ghost
Copy link

ghost commented Jan 10, 2020

This has been released in version 2.44.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 27, 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 Mar 27, 2020
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. partition/aws-iso Pertains to the aws-iso partition. partition/aws-iso-b Pertains to the aws-iso-b partition. provider Pertains to the provider itself, rather than any interaction with AWS.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants