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 for aws_lambda_function_event_invoke_config - unexpected format of function resource #14851

Conversation

nikhil-goenka
Copy link
Contributor

@nikhil-goenka nikhil-goenka commented Aug 26, 2020

Lambda Function ARN not supported along with qualifier.
Reason: functionParts := strings.Split(id, ":") -> id is the arn and the length of variable functionParts was always greater then 2 hence if case was always true.
modified it to functionParts := strings.Split(function, ":") -> length of variable functionParts will either be 1 or 2 based on if user provides qualifier or not.

Failed Acceptance test log:
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn -timeout 120m
=== RUN TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn
=== PAUSE TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn
=== CONT TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn
resource_aws_lambda_function_event_invoke_config_test.go:269: Step 1/2 error: terraform failed: exit status 1
stderr:
Error: unexpected format of function resource (arn:aws:lambda:us-west-2::function:tf-acc-test-:$LATEST), expected n
ame:qualifier
testing_new.go:22: WARNING: destroy failed, so remote objects may still exist and be subject to billing
testing_new.go:22: failed to destroy: terraform failed: exit status 1
stderr:
Error: unexpected format of function resource (arn:aws:lambda:us-west-2::function:tf-acc-test-:$LATEST), expected n
ame:qualifier
--- FAIL: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn (86.72s)
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 89.725s
FAIL

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment 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 pull request followers and do not help prioritize the request

Closes #13166

Release note for CHANGELOG:


Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn -timeout 120m
=== RUN   TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn
=== PAUSE TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn
=== CONT  TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn (114.58s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       115.367s

...

functionParts := strings.Split(id, ":") -> id is the arn and the length of variable functionParts was always greater then 2 hence if case was always true.
modified it to functionParts := strings.Split(function, ":") -> length of variable functionParts will either be 1 or 2 based on if user provides qualifier or not.
@nikhil-goenka nikhil-goenka requested a review from a team August 26, 2020 15:19
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/lambda Issues and PRs that pertain to the lambda service. needs-triage Waiting for first response or review from a maintainer. labels Aug 26, 2020
@ewbankkit
Copy link
Contributor

It looks like this closes #13166.

@nikhil-goenka
Copy link
Contributor Author

It looks like this closes #13166.

yes, it will fix that issue

Acceptance test for checking Lambda ARN with qualifier
@ghost ghost added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Aug 27, 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 Aug 31, 2020
@bflad bflad self-assigned this Aug 31, 2020
@bflad bflad added this to the v3.5.0 milestone Aug 31, 2020
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for fixing this and adding the test @nikhil-goenka 🚀

Output from acceptance testing:

--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn (55.47s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_basic (55.86s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_disappears_LambdaFunctionEventInvokeConfig (68.54s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_disappears_LambdaFunction (70.08s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionVersion (72.29s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_Latest (72.77s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_FunctionName_Arn (73.41s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_AliasName (73.64s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_Remove (80.41s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_MaximumEventAgeInSeconds (86.06s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_Swap (88.02s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_MaximumRetryAttempts (90.44s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_OnSuccess_Destination (102.11s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_OnFailure_Destination (103.06s)

@bflad bflad merged commit fe3a1b5 into hashicorp:master Sep 1, 2020
bflad added a commit that referenced this pull request Sep 1, 2020
@nikhil-goenka nikhil-goenka deleted the aws_lambda_function_event_invoke_config-patch-for-unexpected-format branch September 3, 2020 18:38
@ghost
Copy link

ghost commented Sep 3, 2020

This has been released in version 3.5.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 Oct 1, 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 as resolved and limited conversation to collaborators Oct 1, 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. service/lambda Issues and PRs that pertain to the lambda service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_lambda_function_event_invoke_config documentation example produces state error
3 participants