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

r/aws_lambda_function return nil on resource not found errors #16183

Merged

Conversation

ryan-neff
Copy link
Contributor

@ryan-neff ryan-neff commented Nov 13, 2020

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 #16158

Release note for CHANGELOG:

Catching ResourceNotFoundErrors on when deleting lambdas.

Output from acceptance testing:

$ go test ./aws -v -timeout 200m -parallel 4 -run='TestAccAWSLambdaFunction_'
=== RUN   TestAccAWSLambdaFunction_basic
=== PAUSE TestAccAWSLambdaFunction_basic
=== RUN   TestAccAWSLambdaFunction_UnpublishedCodeUpdate
=== PAUSE TestAccAWSLambdaFunction_UnpublishedCodeUpdate
=== RUN   TestAccAWSLambdaFunction_disappears
=== PAUSE TestAccAWSLambdaFunction_disappears
=== RUN   TestAccAWSLambdaFunction_concurrency
=== PAUSE TestAccAWSLambdaFunction_concurrency
=== RUN   TestAccAWSLambdaFunction_concurrencyCycle
=== PAUSE TestAccAWSLambdaFunction_concurrencyCycle
=== 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_enablePublish
=== PAUSE TestAccAWSLambdaFunction_enablePublish
=== RUN   TestAccAWSLambdaFunction_disablePublish
=== PAUSE TestAccAWSLambdaFunction_disablePublish
=== RUN   TestAccAWSLambdaFunction_DeadLetterConfig
=== PAUSE TestAccAWSLambdaFunction_DeadLetterConfig
=== RUN   TestAccAWSLambdaFunction_DeadLetterConfigUpdated
=== PAUSE TestAccAWSLambdaFunction_DeadLetterConfigUpdated
=== RUN   TestAccAWSLambdaFunction_nilDeadLetterConfig
=== PAUSE TestAccAWSLambdaFunction_nilDeadLetterConfig
=== RUN   TestAccAWSLambdaFunction_FileSystemConfig
=== PAUSE TestAccAWSLambdaFunction_FileSystemConfig
=== RUN   TestAccAWSLambdaFunction_tracingConfig
=== PAUSE TestAccAWSLambdaFunction_tracingConfig
=== RUN   TestAccAWSLambdaFunction_KmsKeyArn_NoEnvironmentVariables
=== PAUSE TestAccAWSLambdaFunction_KmsKeyArn_NoEnvironmentVariables
=== RUN   TestAccAWSLambdaFunction_Layers
=== PAUSE TestAccAWSLambdaFunction_Layers
=== RUN   TestAccAWSLambdaFunction_LayersUpdate
=== PAUSE TestAccAWSLambdaFunction_LayersUpdate
=== 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_VpcConfig_ProperIamDependencies
=== PAUSE TestAccAWSLambdaFunction_VpcConfig_ProperIamDependencies
=== 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_tags
=== PAUSE TestAccAWSLambdaFunction_tags
=== RUN   TestAccAWSLambdaFunction_runtimes
=== PAUSE TestAccAWSLambdaFunction_runtimes
=== CONT  TestAccAWSLambdaFunction_basic
=== CONT  TestAccAWSLambdaFunction_KmsKeyArn_NoEnvironmentVariables
=== CONT  TestAccAWSLambdaFunction_s3
=== CONT  TestAccAWSLambdaFunction_versionedUpdate
--- PASS: TestAccAWSLambdaFunction_s3 (34.74s)
=== CONT  TestAccAWSLambdaFunction_tracingConfig
--- PASS: TestAccAWSLambdaFunction_basic (40.81s)
=== CONT  TestAccAWSLambdaFunction_FileSystemConfig
--- PASS: TestAccAWSLambdaFunction_KmsKeyArn_NoEnvironmentVariables (55.27s)
=== CONT  TestAccAWSLambdaFunction_nilDeadLetterConfig
--- PASS: TestAccAWSLambdaFunction_nilDeadLetterConfig (12.82s)
=== CONT  TestAccAWSLambdaFunction_DeadLetterConfigUpdated
--- PASS: TestAccAWSLambdaFunction_tracingConfig (54.30s)
=== CONT  TestAccAWSLambdaFunction_DeadLetterConfig
--- PASS: TestAccAWSLambdaFunction_versionedUpdate (90.83s)
=== CONT  TestAccAWSLambdaFunction_disablePublish
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfigUpdated (60.07s)
=== CONT  TestAccAWSLambdaFunction_enablePublish
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfig (54.44s)
=== CONT  TestAccAWSLambdaFunction_s3Update_unversioned
--- PASS: TestAccAWSLambdaFunction_disablePublish (52.92s)
=== CONT  TestAccAWSLambdaFunction_runtimes
--- PASS: TestAccAWSLambdaFunction_enablePublish (71.34s)
=== CONT  TestAccAWSLambdaFunction_tags
--- PASS: TestAccAWSLambdaFunction_s3Update_unversioned (62.45s)
=== CONT  TestAccAWSLambdaFunction_localUpdate_nameOnly
--- PASS: TestAccAWSLambdaFunction_localUpdate_nameOnly (174.81s)
=== CONT  TestAccAWSLambdaFunction_s3Update_basic
--- PASS: TestAccAWSLambdaFunction_tags (199.18s)
=== CONT  TestAccAWSLambdaFunction_localUpdate
--- PASS: TestAccAWSLambdaFunction_localUpdate (36.56s)
=== CONT  TestAccAWSLambdaFunction_VPCUpdate
--- PASS: TestAccAWSLambdaFunction_s3Update_basic (55.20s)
=== CONT  TestAccAWSLambdaFunction_EmptyVpcConfig
--- PASS: TestAccAWSLambdaFunction_EmptyVpcConfig (39.51s)
=== CONT  TestAccAWSLambdaFunction_VpcConfig_ProperIamDependencies
bdaFunction_versionedUpdate (90.83s)
=== CONT  TestAccAWSLambdaFunction_disablePublish
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfigUpdated (60.07s)
=== CONT  TestAccAWSLambdaFunction_enablePublish
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfig (54.44s)
=== CONT  TestAccAWSLambdaFunction_s3Update_unversioned
--- PASS: TestAccAWSLambdaFunction_disablePublish (52.92s)
=== CONT  TestAccAWSLambdaFunction_runtimes
--- PASS: TestAccAWSLambdaFunction_enablePublish (71.34s)
=== CONT  TestAccAWSLambdaFunction_tags
--- PASS: TestAccAWSLambdaFunction_s3Update_unversioned (62.45s)
=== CONT  TestAccAWSLambdaFunction_localUpdate_nameOnly
--- PASS: TestAccAWSLambdaFunction_localUpdate_nameOnly (174.81s)
=== CONT  TestAccAWSLambdaFunction_s3Update_basic
--- PASS: TestAccAWSLambdaFunction_tags (199.18s)
=== CONT  TestAccAWSLambdaFunction_localUpdate
--- PASS: TestAccAWSLambdaFunction_localUpdate (36.56s)
=== CONT  TestAccAWSLambdaFunction_VPCUpdate
--- PASS: TestAccAWSLambdaFunction_s3Update_basic (55.20s)
=== CO--- PASS: TestAccAWSLambdaFunction_runtimes (520.76s)
=== CONT  TestAccAWSLambdaFunction_VPC_withInvocation
--- PASS: TestAccAWSLambdaFunction_VPCUpdate (1033.77s)
=== CONT  TestAccAWSLambdaFunction_expectFilenameAndS3Attributes
--- PASS: TestAccAWSLambdaFunction_expectFilenameAndS3Attributes (14.41s)
=== CONT  TestAccAWSLambdaFunction_envVariables
--- PASS: TestAccAWSLambdaFunction_envVariables (93.84s)
=== CONT  TestAccAWSLambdaFunction_encryptedEnvVariables
--- PASS: TestAccAWSLambdaFunction_VpcConfig_ProperIamDependencies (1128.04s)
=== CONT  TestAccAWSLambdaFunction_concurrency
--- PASS: TestAccAWSLambdaFunction_VPC_withInvocation (957.01s)
=== CONT  TestAccAWSLambdaFunction_versioned
--- PASS: TestAccAWSLambdaFunction_encryptedEnvVariables (53.99s)
=== CONT  TestAccAWSLambdaFunction_disappears
--- PASS: TestAccAWSLambdaFunction_concurrency (45.44s)
=== CONT  TestAccAWSLambdaFunction_VPC
--- PASS: TestAccAWSLambdaFunction_versioned (39.53s)
=== CONT  TestAccAWSLambdaFunction_VPCRemoval
--- PASS: TestAccAWSLambdaFunction_disappears (34.63s)
=== CONT  TestAccAWSLambdaFunction_concurrencyCycle
--- PASS: TestAccAWSLambdaFunction_concurrencyCycle (230.54s)
=== CONT  TestAccAWSLambdaFunction_Layers
--- PASS: TestAccAWSLambdaFunction_Layers (173.75s)
=== CONT  TestAccAWSLambdaFunction_UnpublishedCodeUpdate
    TestAccAWSLambdaFunction_UnpublishedCodeUpdate: resource_aws_lambda_function_test.go:120: Step 1/3 error: Error running second post-apply plan:
        Error: No configuration files

        Plan requires configuration to be present. Planning without a configuration
        would mark everything for destruction, which is normally not what is desired.
        If you would like to destroy everything, run plan with the -destroy option.
        Otherwise, create a Terraform configuration file (.tf file) and try again.

--- FAIL: TestAccAWSLambdaFunction_UnpublishedCodeUpdate (36.58s)
=== CONT  TestAccAWSLambdaFunction_LayersUpdate
--- PASS: TestAccAWSLambdaFunction_LayersUpdate (61.57s)
--- PASS: TestAccAWSLambdaFunction_FileSystemConfig (2206.15s)
--- PASS: TestAccAWSLambdaFunction_VPC (607.27s)
--- PASS: TestAccAWSLambdaFunction_VPCRemoval (2083.46s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	3746.166s
FAIL
...

The one test error does not seem related to my change

@ryan-neff ryan-neff requested a review from a team as a code owner November 13, 2020 17:49
@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. labels Nov 13, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 13, 2020
@ryan-neff
Copy link
Contributor Author

Running into the VPC Limit issue running acceptance tests. I will try and run again with the recommendation here #10165 (comment)

@ryan-neff ryan-neff changed the title [WIP] r/aws_lambda_function return nil on resource not found errors r/aws_lambda_function return nil on resource not found errors Nov 13, 2020
@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 3, 2020
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

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

Thanks @ryan-neff , looks great !

Output of acceptance tests (commerical):

--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_Latest (73.01s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_AliasName (76.85s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_disappears_LambdaFunction (85.82s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_disappears_LambdaFunctionEventInvokeConfig (86.60s)
--- PASS: TestAccAWSLambdaFunction_disappears (88.31s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_basic (89.27s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_FunctionName_Arn (95.02s)
--- PASS: TestAccAWSLambdaFunction_basic (95.62s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionVersion (96.47s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_Qualifier_FunctionName_Arn (97.44s)
--- PASS: TestAccAWSLambdaFunction_expectFilenameAndS3Attributes (34.74s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_Swap (117.55s)
--- SKIP: TestAccAWSLambdaFunction_imageConfig (1.20s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_MaximumEventAgeInSeconds (119.70s)
--- PASS: TestAccAWSLambdaFunction_nilDeadLetterConfig (29.26s)
--- PASS: TestAccAWSLambdaFunction_UnpublishedCodeUpdate (132.53s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_OnSuccess_Destination (135.73s)
--- PASS: TestAccAWSLambdaFunction_concurrency (135.76s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_Remove (137.48s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_DestinationConfig_OnFailure_Destination (142.11s)
--- PASS: TestAccAWSLambdaFunctionEventInvokeConfig_MaximumRetryAttempts (159.14s)
--- PASS: TestAccAWSLambdaFunction_versioned (82.66s)
--- PASS: TestAccAWSLambdaFunction_concurrencyCycle (173.99s)
--- PASS: TestAccAWSLambdaFunction_codeSigningConfig (177.97s)
--- PASS: TestAccAWSLambdaFunction_KmsKeyArn_NoEnvironmentVariables (72.96s)
--- PASS: TestAccAWSLambdaFunction_Layers (67.31s)
--- FAIL: TestAccAWSLambdaFunction_VPC_withInvocation (63.38s) -- looks to be intermittently failing in TC as well 
--- PASS: TestAccAWSLambdaFunction_disablePublish (111.84s)
--- PASS: TestAccAWSLambdaFunction_encryptedEnvVariables (122.01s)
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfig (113.66s)
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfigUpdated (114.79s)
--- PASS: TestAccAWSLambdaFunction_tracingConfig (102.53s)
--- PASS: TestAccAWSLambdaFunction_enablePublish (136.85s)
--- PASS: TestAccAWSLambdaFunction_EmptyVpcConfig (58.86s)
--- PASS: TestAccAWSLambdaFunction_versionedUpdate (141.06s)
--- PASS: TestAccAWSLambdaFunction_s3 (57.43s)
--- PASS: TestAccAWSLambdaFunction_LayersUpdate (98.96s)
--- PASS: TestAccAWSLambdaFunction_localUpdate (68.95s)
--- PASS: TestAccAWSLambdaFunction_envVariables (172.75s)
--- PASS: TestAccAWSLambdaFunction_localUpdate_nameOnly (60.49s)
--- PASS: TestAccAWSLambdaFunction_s3Update_basic (62.70s)
--- PASS: TestAccAWSLambdaFunction_s3Update_unversioned (51.70s)
--- PASS: TestAccAWSLambdaFunction_tags (66.74s)
--- PASS: TestAccAWSLambdaFunction_VpcConfig_ProperIamDependencies (294.76s)
--- PASS: TestAccAWSLambdaFunction_runtimes (269.90s)
--- PASS: TestAccAWSLambdaFunction_VPCRemoval (476.06s)
--- PASS: TestAccAWSLambdaFunction_VPC (543.50s)
--- PASS: TestAccAWSLambdaFunction_VPCUpdate (922.68s)
--- PASS: TestAccAWSLambdaFunction_FileSystemConfig (1977.34s)

@anGie44 anGie44 added this to the v3.20.0 milestone Dec 3, 2020
@anGie44 anGie44 merged commit 4fe20d0 into hashicorp:master Dec 3, 2020
anGie44 added a commit that referenced this pull request Dec 3, 2020
@ghost
Copy link

ghost commented Dec 3, 2020

This has been released in version 3.20.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 Jan 3, 2021

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 Jan 3, 2021
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/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TF tries to destroy Lambda function which was manually deleted
3 participants