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

fix incorrect Lambda GovCloud regexes #14850

Conversation

jeremy-asher
Copy link
Contributor

I'm putting this up for comment on the approach.

This updates two regexes that are used to validate and parse ARNs for
aws_lambda_permission.  The ARNs were not accurate when using GovCloud
Lambdas.  This resulted in failures during the read call after applying
a resource.

Without this fix:

2017/05/25 17:01:25 [ERROR] root.module_name: eval: *terraform.EvalRefresh, err: aws_lambda_permission.allow_cloudwatch: Invalid ARN or otherwise unable to get qualifier from ARN ("arn:aws-us-gov:lambda:us-gov-west-1:123456789012:function:function_name")
...
Error refreshing state: 1 error(s) occurred:

* module.module-name.aws_lambda_permission.allow_cloudwatch: aws_lambda_permission.allow_cloudwatch: Invalid ARN or otherwise unable to get qualifier from ARN ("arn:aws-us-gov:lambda:us-gov-west-1:123456789012:function:function_name")

This occurs because the region name for GovCloud contains an additional section.

Considering the duplication of the regex and the fact that validateLambdaFunctionName is only used in aws_lambda_permission, I'm thinking some cleanup is in order as well, but this patch should work on its own. I'm open to suggestions to improve this, but wasn't sure where I should put the Regex if it needs to be reused. Note that it's tightly coupled to this code as well:
https://github.com/jeremy-asher/terraform/blob/28a2ec1b9fa83549a2b5c45ab75f5928ce848893/builtin/providers/aws/resource_aws_lambda_permission.go#L346-L363

This updates two regexes that are used to validate and parse ARNs for
aws_lambda_permission.  The ARNs were not accurate when using GovCloud
Lambdas.  This resulted in failures during the read call after applying
a resource.
@stack72
Copy link
Contributor

stack72 commented Jun 5, 2017

Hi @jeremy-asher

Thanks for this - please can you add a unit test to show that both gov and non-gov partitions will now satisfy the regex?

Thanks

Paul

@stack72 stack72 added the waiting-response An issue/pull request is waiting for a response from the community label Jun 5, 2017
This corrects the region of the existing Lambda GovCloud tests and adds
one more GovCloud test for the aws_lambda_permission resource.
@jeremy-asher
Copy link
Contributor Author

Done. Looks like there were a few existing tests, but they were referencing the wrong region for GovCloud.

@jeremy-asher
Copy link
Contributor Author

@stack72 need anything else on this?

@jeremy-asher
Copy link
Contributor Author

Opened hashicorp/terraform-provider-aws#16 to replace this.

@ghost
Copy link

ghost commented Apr 11, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants