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

Added invoke_arn to lambda alias resource (GH-4479) #6329

Merged
merged 1 commit into from
Dec 4, 2018

Conversation

sjauld
Copy link
Contributor

@sjauld sjauld commented Nov 2, 2018

Fixes #4479

Changes proposed in this pull request:

  • Added invoke_arn to the AWS Lambda Alias resource
  • Refactored AWS Lambda Function to DRY the interpolation of invoke_arn

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSLambdaFunction TestAccAWSLambdaAlias'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSLambdaFunction TestAccAWSLambdaAlias -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSLambdaFunction_importLocalFile
=== PAUSE TestAccAWSLambdaFunction_importLocalFile
=== RUN   TestAccAWSLambdaFunction_importLocalFile_VPC
=== PAUSE TestAccAWSLambdaFunction_importLocalFile_VPC
=== RUN   TestAccAWSLambdaFunction_importS3
=== PAUSE TestAccAWSLambdaFunction_importS3
=== RUN   TestAccAWSLambdaFunction_basic
=== PAUSE TestAccAWSLambdaFunction_basic
=== RUN   TestAccAWSLambdaFunction_concurrency
=== PAUSE TestAccAWSLambdaFunction_concurrency
=== RUN   TestAccAWSLambdaFunction_concurrencyCycle
=== PAUSE TestAccAWSLambdaFunction_concurrencyCycle
=== RUN   TestAccAWSLambdaFunction_updateRuntime
=== PAUSE TestAccAWSLambdaFunction_updateRuntime
=== RUN   TestAccAWSLambdaFunction_expectFilenameAndS3Attributes
=== PAUSE TestAccAWSLambdaFunction_expectFilenameAndS3Attributes
=== RUN   TestAccAWSLambdaFunction_envVariables
=== PAUSE TestAccAWSLambdaFunction_envVariables
=== RUN   TestAccAWSLambdaFunction_encryptedEnvVariables
=== PAUSE TestAccAWSLambdaFunction_encryptedEnvVariables
=== RUN   TestAccAWSLambdaFunction_versioned
=== PAUSE TestAccAWSLambdaFunction_versioned
=== RUN   TestAccAWSLambdaFunction_versionedUpdate
=== PAUSE TestAccAWSLambdaFunction_versionedUpdate
=== RUN   TestAccAWSLambdaFunction_DeadLetterConfig
=== PAUSE TestAccAWSLambdaFunction_DeadLetterConfig
=== RUN   TestAccAWSLambdaFunction_DeadLetterConfigUpdated
=== PAUSE TestAccAWSLambdaFunction_DeadLetterConfigUpdated
=== RUN   TestAccAWSLambdaFunction_nilDeadLetterConfig
=== PAUSE TestAccAWSLambdaFunction_nilDeadLetterConfig
=== RUN   TestAccAWSLambdaFunction_tracingConfig
=== PAUSE TestAccAWSLambdaFunction_tracingConfig
=== RUN   TestAccAWSLambdaFunction_VPC
=== PAUSE TestAccAWSLambdaFunction_VPC
=== RUN   TestAccAWSLambdaFunction_VPCRemoval
=== PAUSE TestAccAWSLambdaFunction_VPCRemoval
=== RUN   TestAccAWSLambdaFunction_VPCUpdate
=== PAUSE TestAccAWSLambdaFunction_VPCUpdate
=== RUN   TestAccAWSLambdaFunction_VPC_withInvocation
=== PAUSE TestAccAWSLambdaFunction_VPC_withInvocation
=== RUN   TestAccAWSLambdaFunction_EmptyVpcConfig
=== PAUSE TestAccAWSLambdaFunction_EmptyVpcConfig
=== RUN   TestAccAWSLambdaFunction_s3
=== PAUSE TestAccAWSLambdaFunction_s3
=== RUN   TestAccAWSLambdaFunction_localUpdate
=== PAUSE TestAccAWSLambdaFunction_localUpdate
=== RUN   TestAccAWSLambdaFunction_localUpdate_nameOnly
=== PAUSE TestAccAWSLambdaFunction_localUpdate_nameOnly
=== RUN   TestAccAWSLambdaFunction_s3Update_basic
=== PAUSE TestAccAWSLambdaFunction_s3Update_basic
=== RUN   TestAccAWSLambdaFunction_s3Update_unversioned
=== PAUSE TestAccAWSLambdaFunction_s3Update_unversioned
=== RUN   TestAccAWSLambdaFunction_runtimeValidation_noRuntime
=== PAUSE TestAccAWSLambdaFunction_runtimeValidation_noRuntime
=== RUN   TestAccAWSLambdaFunction_runtimeValidation_nodeJs43
=== PAUSE TestAccAWSLambdaFunction_runtimeValidation_nodeJs43
=== RUN   TestAccAWSLambdaFunction_runtimeValidation_python27
=== PAUSE TestAccAWSLambdaFunction_runtimeValidation_python27
=== RUN   TestAccAWSLambdaFunction_runtimeValidation_java8
=== PAUSE TestAccAWSLambdaFunction_runtimeValidation_java8
=== RUN   TestAccAWSLambdaFunction_tags
=== PAUSE TestAccAWSLambdaFunction_tags
=== RUN   TestAccAWSLambdaFunction_runtimeValidation_python36
=== PAUSE TestAccAWSLambdaFunction_runtimeValidation_python36
=== CONT  TestAccAWSLambdaFunction_importLocalFile
=== CONT  TestAccAWSLambdaFunction_runtimeValidation_python36
=== CONT  TestAccAWSLambdaFunction_tags
=== CONT  TestAccAWSLambdaFunction_nilDeadLetterConfig
--- PASS: TestAccAWSLambdaFunction_nilDeadLetterConfig (56.75s)
=== CONT  TestAccAWSLambdaFunction_DeadLetterConfigUpdated
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_python36 (78.18s)
=== CONT  TestAccAWSLambdaFunction_DeadLetterConfig
--- PASS: TestAccAWSLambdaFunction_importLocalFile (78.67s)
=== CONT  TestAccAWSLambdaFunction_versionedUpdate
--- PASS: TestAccAWSLambdaFunction_tags (163.96s)
=== CONT  TestAccAWSLambdaFunction_versioned
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfigUpdated (125.69s)
=== CONT  TestAccAWSLambdaFunction_encryptedEnvVariables
--- PASS: TestAccAWSLambdaFunction_versionedUpdate (122.34s)
=== CONT  TestAccAWSLambdaFunction_envVariables
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfig (128.24s)
=== CONT  TestAccAWSLambdaFunction_expectFilenameAndS3Attributes
--- PASS: TestAccAWSLambdaFunction_versioned (80.90s)
=== CONT  TestAccAWSLambdaFunction_updateRuntime
--- PASS: TestAccAWSLambdaFunction_expectFilenameAndS3Attributes (55.16s)
=== CONT  TestAccAWSLambdaFunction_concurrencyCycle
--- FAIL: TestAccAWSLambdaFunction_encryptedEnvVariables (124.89s)
    testing.go:538: Step 1 error: Check failed: Check 5/5 error: aws_lambda_function.lambda_function_test: Attribute 'kms_key_arn' expected "", got "arn:aws:kms:us-west-2:552577692908:key/b9bdefa4-ef66-4a7a-bbbd-b52f0c5335f7"
=== CONT  TestAccAWSLambdaFunction_concurrency
--- PASS: TestAccAWSLambdaFunction_updateRuntime (117.87s)
=== CONT  TestAccAWSLambdaFunction_basic
--- PASS: TestAccAWSLambdaFunction_envVariables (202.86s)
=== CONT  TestAccAWSLambdaFunction_importS3
--- PASS: TestAccAWSLambdaFunction_concurrencyCycle (158.28s)
=== CONT  TestAccAWSLambdaFunction_importLocalFile_VPC
--- PASS: TestAccAWSLambdaFunction_concurrency (116.04s)
=== CONT  TestAccAWSLambdaFunction_localUpdate
--- PASS: TestAccAWSLambdaFunction_basic (76.43s)
=== CONT  TestAccAWSLambdaFunction_runtimeValidation_java8
--- PASS: TestAccAWSLambdaFunction_importS3 (85.79s)
=== CONT  TestAccAWSLambdaFunction_runtimeValidation_python27
--- PASS: TestAccAWSLambdaFunction_localUpdate (80.72s)
=== CONT  TestAccAWSLambdaFunction_runtimeValidation_nodeJs43
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_java8 (78.62s)
=== CONT  TestAccAWSLambdaFunction_runtimeValidation_noRuntime
--- PASS: TestAccAWSLambdaFunction_importLocalFile_VPC (100.33s)
=== CONT  TestAccAWSLambdaFunction_s3Update_unversioned
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_noRuntime (2.74s)
=== CONT  TestAccAWSLambdaFunction_s3Update_basic
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_python27 (76.82s)
=== CONT  TestAccAWSLambdaFunction_localUpdate_nameOnly
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_nodeJs43 (81.36s)
=== CONT  TestAccAWSLambdaFunction_VPCUpdate
--- PASS: TestAccAWSLambdaFunction_localUpdate_nameOnly (85.05s)
=== CONT  TestAccAWSLambdaFunction_s3
--- PASS: TestAccAWSLambdaFunction_s3Update_unversioned (138.01s)
=== CONT  TestAccAWSLambdaFunction_EmptyVpcConfig
--- PASS: TestAccAWSLambdaFunction_s3Update_basic (138.15s)
=== CONT  TestAccAWSLambdaFunction_VPC_withInvocation
--- PASS: TestAccAWSLambdaFunction_VPCUpdate (141.34s)
=== CONT  TestAccAWSLambdaFunction_VPC
--- PASS: TestAccAWSLambdaFunction_s3 (75.95s)
=== CONT  TestAccAWSLambdaFunction_VPCRemoval
--- PASS: TestAccAWSLambdaFunction_EmptyVpcConfig (75.65s)
=== CONT  TestAccAWSLambdaFunction_tracingConfig
--- PASS: TestAccAWSLambdaFunction_VPC_withInvocation (128.44s)
--- PASS: TestAccAWSLambdaFunction_VPC (366.11s)
--- PASS: TestAccAWSLambdaFunction_VPCRemoval (531.76s)
--- PASS: TestAccAWSLambdaFunction_tracingConfig (525.40s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	1259.271s

Note: that TestAccAWSLambdaFunction_encryptedEnvVariables seems unrelated to these changes. I cam across #2959, not sure if it's related to that (although it's marked as closed). I'm not really sure what to do with this one...

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/lambda Issues and PRs that pertain to the lambda service. labels Nov 2, 2018
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 7, 2018
@bflad bflad added this to the v1.51.0 milestone Dec 4, 2018
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.

LGTM, sorry for the delayed review. I added test checks for this new attribute in both resource acceptance tests to ensure coverage:

// aws/resource_aws_lambda_alias_test.go
resource.TestMatchResourceAttr(resourceName, "invoke_arn", regexp.MustCompile(fmt.Sprintf("^arn:[^:]+:apigateway:[^:]+:lambda:path/2015-03-31/functions/arn:[^:]+:lambda:[^:]+:[^:]+:function:%s:%s/invocations$", funcName, aliasName))),

// aws/resource_aws_lambda_function_test.go
resource.TestMatchResourceAttr(resourceName, "invoke_arn", regexp.MustCompile(fmt.Sprintf("^arn:[^:]+:apigateway:[^:]+:lambda:path/2015-03-31/functions/arn:[^:]+:lambda:[^:]+:[^:]+:function:%s/invocations$", funcName))),
--- PASS: TestAccAWSLambdaAlias_basic (23.96s)
--- PASS: TestAccAWSLambdaAlias_nameupdate (29.93s)
--- PASS: TestAccAWSLambdaFunction_basic (33.68s)
--- PASS: TestAccAWSLambdaAlias_routingconfig (43.12s)

@bflad bflad merged commit 35cc749 into hashicorp:master Dec 4, 2018
bflad added a commit that referenced this pull request Dec 4, 2018
@bflad
Copy link
Contributor

bflad commented Dec 5, 2018

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

@ghost
Copy link

ghost commented Apr 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 and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/lambda Issues and PRs that pertain to the lambda service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lambda Alias Invoke ARN
2 participants