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|d]/aws_lambda_function: Migrate to AWS SDK v2 #29615

Merged
merged 8 commits into from
Feb 24, 2023

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Feb 23, 2023

Description

Migrates the aws_lambda_function resource and data source to AWS SDK V2. This primary benefit of this migration is the improved error messaging for ValidationExceptions (see #13709 and aws/aws-sdk-go#4733). Below are examples of the error message returned from an invalid configuration before and after this change:

AWS SDK V1:

aws_lambda_function.test: Creating...
╷
│ Error: creating Lambda Function (jb-test-persistent-diffs): ValidationException:
│       status code: 400, request id: 0531f106-dea6-40d5-93c5-d3785112d583
│
│   with aws_lambda_function.test,
│   on main.tf line 28, in resource "aws_lambda_function" "test":
│   28: resource "aws_lambda_function" "test" {
│
╵

AWS SDK V2 (this PR):

aws_lambda_function.test: Creating...
╷
│ Error: creating Lambda Function (jb-test-persistent-diffs): operation error Lambda: CreateFunction, https response error StatusCode: 400, RequestID: 2d5e0c1b-7d35-47a8-bbd7-76224fb2416a, api error ValidationException: 1 validation error detected: Value '2000' at 'timeout' failed to satisfy constraint: Member must have value less than or equal to 900
│
│   with aws_lambda_function.test,
│   on main.tf line 28, in resource "aws_lambda_function" "test":
│   28: resource "aws_lambda_function" "test" {
│
╵

Relations

Closes #13709

Output from Acceptance Testing

$ make testacc PKG=lambda TESTS="TestAccLambdaFunction_"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/lambda/... -v -count 1 -parallel 20 -run='TestAccLambdaFunction_'  -timeout 180m
<snip>
--- PASS: TestAccLambdaFunction_Zip_validation (9.25s)
=== CONT  TestAccLambdaFunction_tracing
=== CONT  TestAccLambdaFunction_layers
--- PASS: TestAccLambdaFunction_basic (47.42s)
--- PASS: TestAccLambdaFunction_S3Update_unversioned (57.99s)
=== CONT  TestAccLambdaFunction_layersUpdate
--- PASS: TestAccLambdaFunction_S3Update_basic (60.87s)
=== CONT  TestAccLambdaFunction_deadLetter
--- PASS: TestAccLambdaFunction_versioned (66.04s)
=== CONT  TestAccLambdaFunction_nilDeadLetter
--- PASS: TestAccLambdaFunction_snapStart (72.20s)
=== CONT  TestAccLambdaFunction_deadLetterUpdated
--- PASS: TestAccLambdaFunction_architectures (83.66s)
=== CONT  TestAccLambdaFunction_fileSystem
--- PASS: TestAccLambdaFunction_ephemeralStorage (96.25s)
=== CONT  TestAccLambdaFunction_LocalUpdate_nameOnly
--- PASS: TestAccLambdaFunction_VPC_properIAMDependencies (294.67s)
=== CONT  TestAccLambdaFunction_concurrencyCycle
--- PASS: TestAccLambdaFunction_tracing (290.65s)
=== CONT  TestAccLambdaFunction_localUpdate
--- PASS: TestAccLambdaFunction_runtimes (325.95s)
=== CONT  TestAccLambdaFunction_nameValidation
--- PASS: TestAccLambdaFunction_nameValidation (0.77s)
=== CONT  TestAccLambdaFunction_envVariables
--- PASS: TestAccLambdaFunction_VPC_withInvocation (690.19s)
=== CONT  TestAccLambdaFunction_expectFilenameAndS3Attributes
--- PASS: TestAccLambdaFunction_expectFilenameAndS3Attributes (0.81s)
=== CONT  TestAccLambdaFunction_enablePublish
--- PASS: TestAccLambdaFunction_vpc (1043.18s)
=== CONT  TestAccLambdaFunction_disablePublish
--- PASS: TestAccLambdaFunction_vpcRemoval (1083.07s)
=== CONT  TestAccLambdaFunction_EnvironmentVariables_noValue
--- PASS: TestAccLambdaFunction_VPC_replaceSGWithDefault (1570.73s)
=== CONT  TestAccLambdaFunction_versionedUpdate
--- PASS: TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables (1635.09s)
=== CONT  TestAccLambdaFunction_encryptedEnvVariables
--- PASS: TestAccLambdaFunction_layers (1597.45s)
=== CONT  TestAccLambdaFunction_emptyVPC
--- PASS: TestAccLambdaFunction_vpcUpdate (1647.26s)
=== CONT  TestAccLambdaFunction_unpublishedCodeUpdate
--- PASS: TestAccLambdaFunction_nilDeadLetter (1586.18s)
=== CONT  TestAccLambdaFunction_concurrency
--- PASS: TestAccLambdaFunction_deadLetter (1609.07s)
=== CONT  TestAccLambdaFunction_VPC_replaceSGWithCustom
--- PASS: TestAccLambdaFunction_architecturesUpdate (1670.76s)
=== CONT  TestAccLambdaFunction_tags
--- PASS: TestAccLambdaFunction_layersUpdate (1626.39s)
=== CONT  TestAccLambdaFunction_codeSigning
--- PASS: TestAccLambdaFunction_deadLetterUpdated (1613.49s)
=== CONT  TestAccLambdaFunction_disappears
--- PASS: TestAccLambdaFunction_VPCPublishHas_changes (1733.39s)
=== CONT  TestAccLambdaFunction_s3
--- PASS: TestAccLambdaFunction_s3 (32.25s)
--- PASS: TestAccLambdaFunction_concurrencyCycle (1609.38s)
--- PASS: TestAccLambdaFunction_EnvironmentVariables_noValue (825.44s)
--- PASS: TestAccLambdaFunction_disablePublish (871.29s)
--- PASS: TestAccLambdaFunction_architecturesWithLayer (1916.00s)
--- PASS: TestAccLambdaFunction_enablePublish (1229.08s)
--- PASS: TestAccLambdaFunction_emptyVPC (292.03s)
--- PASS: TestAccLambdaFunction_envVariables (1616.92s)
--- PASS: TestAccLambdaFunction_LocalUpdate_nameOnly (1859.83s)
--- PASS: TestAccLambdaFunction_concurrency (309.62s)
--- PASS: TestAccLambdaFunction_encryptedEnvVariables (332.97s)
--- PASS: TestAccLambdaFunction_tags (310.46s)
--- PASS: TestAccLambdaFunction_disappears (477.87s)
--- PASS: TestAccLambdaFunction_localUpdate (1866.11s)
--- PASS: TestAccLambdaFunction_VPC_replaceSGWithCustom (503.19s)
--- PASS: TestAccLambdaFunction_codeSigning (496.12s)
--- PASS: TestAccLambdaFunction_unpublishedCodeUpdate (536.40s)
--- PASS: TestAccLambdaFunction_versionedUpdate (625.45s)
--- PASS: TestAccLambdaFunction_fileSystem (2145.77s)
--- PASS: TestAccLambdaFunction_VPCPublishNo_changes (3064.83s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/lambda     3068.071s

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. client-connections Pertains to the AWS Client and service connections. generators Relates to code generators. service/lambda Issues and PRs that pertain to the lambda service. tags Pertains to resource tagging. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 23, 2023
@jar-b jar-b marked this pull request as ready for review February 24, 2023 01:16
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccLambdaFunction_' PKG=lambda ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/lambda/... -v -count 1 -parallel 3  -run=TestAccLambdaFunction_ -timeout 180m
go: downloading github.com/aws/aws-sdk-go-v2/service/lambda v1.29.4
=== RUN   TestAccLambdaFunction_basic
=== PAUSE TestAccLambdaFunction_basic
=== RUN   TestAccLambdaFunction_disappears
=== PAUSE TestAccLambdaFunction_disappears
=== RUN   TestAccLambdaFunction_tags
=== PAUSE TestAccLambdaFunction_tags
=== RUN   TestAccLambdaFunction_unpublishedCodeUpdate
=== PAUSE TestAccLambdaFunction_unpublishedCodeUpdate
=== RUN   TestAccLambdaFunction_codeSigning
=== PAUSE TestAccLambdaFunction_codeSigning
=== RUN   TestAccLambdaFunction_concurrency
=== PAUSE TestAccLambdaFunction_concurrency
=== RUN   TestAccLambdaFunction_concurrencyCycle
=== PAUSE TestAccLambdaFunction_concurrencyCycle
=== RUN   TestAccLambdaFunction_expectFilenameAndS3Attributes
=== PAUSE TestAccLambdaFunction_expectFilenameAndS3Attributes
=== RUN   TestAccLambdaFunction_envVariables
=== PAUSE TestAccLambdaFunction_envVariables
=== RUN   TestAccLambdaFunction_EnvironmentVariables_noValue
=== PAUSE TestAccLambdaFunction_EnvironmentVariables_noValue
=== RUN   TestAccLambdaFunction_encryptedEnvVariables
=== PAUSE TestAccLambdaFunction_encryptedEnvVariables
=== RUN   TestAccLambdaFunction_nameValidation
=== PAUSE TestAccLambdaFunction_nameValidation
=== RUN   TestAccLambdaFunction_versioned
=== PAUSE TestAccLambdaFunction_versioned
=== RUN   TestAccLambdaFunction_versionedUpdate
=== PAUSE TestAccLambdaFunction_versionedUpdate
=== RUN   TestAccLambdaFunction_enablePublish
=== PAUSE TestAccLambdaFunction_enablePublish
=== RUN   TestAccLambdaFunction_disablePublish
=== PAUSE TestAccLambdaFunction_disablePublish
=== RUN   TestAccLambdaFunction_deadLetter
=== PAUSE TestAccLambdaFunction_deadLetter
=== RUN   TestAccLambdaFunction_deadLetterUpdated
=== PAUSE TestAccLambdaFunction_deadLetterUpdated
=== RUN   TestAccLambdaFunction_nilDeadLetter
=== PAUSE TestAccLambdaFunction_nilDeadLetter
=== RUN   TestAccLambdaFunction_fileSystem
=== PAUSE TestAccLambdaFunction_fileSystem
=== RUN   TestAccLambdaFunction_image
    function_test.go:925: Environment variable AWS_LAMBDA_IMAGE_LATEST_ID is not set
--- SKIP: TestAccLambdaFunction_image (0.00s)
=== RUN   TestAccLambdaFunction_architectures
=== PAUSE TestAccLambdaFunction_architectures
=== RUN   TestAccLambdaFunction_architecturesUpdate
=== PAUSE TestAccLambdaFunction_architecturesUpdate
=== RUN   TestAccLambdaFunction_architecturesWithLayer
=== PAUSE TestAccLambdaFunction_architecturesWithLayer
=== RUN   TestAccLambdaFunction_ephemeralStorage
=== PAUSE TestAccLambdaFunction_ephemeralStorage
=== RUN   TestAccLambdaFunction_tracing
=== PAUSE TestAccLambdaFunction_tracing
=== RUN   TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables
=== PAUSE TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables
=== RUN   TestAccLambdaFunction_layers
=== PAUSE TestAccLambdaFunction_layers
=== RUN   TestAccLambdaFunction_layersUpdate
=== PAUSE TestAccLambdaFunction_layersUpdate
=== RUN   TestAccLambdaFunction_vpc
=== PAUSE TestAccLambdaFunction_vpc
=== RUN   TestAccLambdaFunction_vpcRemoval
=== PAUSE TestAccLambdaFunction_vpcRemoval
=== RUN   TestAccLambdaFunction_vpcUpdate
=== PAUSE TestAccLambdaFunction_vpcUpdate
=== RUN   TestAccLambdaFunction_VPC_withInvocation
=== PAUSE TestAccLambdaFunction_VPC_withInvocation
=== RUN   TestAccLambdaFunction_VPCPublishNo_changes
=== PAUSE TestAccLambdaFunction_VPCPublishNo_changes
=== RUN   TestAccLambdaFunction_VPCPublishHas_changes
=== PAUSE TestAccLambdaFunction_VPCPublishHas_changes
=== RUN   TestAccLambdaFunction_VPC_properIAMDependencies
=== PAUSE TestAccLambdaFunction_VPC_properIAMDependencies
=== RUN   TestAccLambdaFunction_VPC_replaceSGWithDefault
=== PAUSE TestAccLambdaFunction_VPC_replaceSGWithDefault
=== RUN   TestAccLambdaFunction_VPC_replaceSGWithCustom
=== PAUSE TestAccLambdaFunction_VPC_replaceSGWithCustom
=== RUN   TestAccLambdaFunction_emptyVPC
=== PAUSE TestAccLambdaFunction_emptyVPC
=== RUN   TestAccLambdaFunction_s3
=== PAUSE TestAccLambdaFunction_s3
=== RUN   TestAccLambdaFunction_localUpdate
=== PAUSE TestAccLambdaFunction_localUpdate
=== RUN   TestAccLambdaFunction_LocalUpdate_nameOnly
=== PAUSE TestAccLambdaFunction_LocalUpdate_nameOnly
=== RUN   TestAccLambdaFunction_S3Update_basic
=== PAUSE TestAccLambdaFunction_S3Update_basic
=== RUN   TestAccLambdaFunction_S3Update_unversioned
=== PAUSE TestAccLambdaFunction_S3Update_unversioned
=== RUN   TestAccLambdaFunction_snapStart
=== PAUSE TestAccLambdaFunction_snapStart
=== RUN   TestAccLambdaFunction_runtimes
=== PAUSE TestAccLambdaFunction_runtimes
=== RUN   TestAccLambdaFunction_Zip_validation
=== PAUSE TestAccLambdaFunction_Zip_validation
=== CONT  TestAccLambdaFunction_basic
=== CONT  TestAccLambdaFunction_ephemeralStorage
=== CONT  TestAccLambdaFunction_Zip_validation
--- PASS: TestAccLambdaFunction_Zip_validation (9.84s)
=== CONT  TestAccLambdaFunction_runtimes
--- PASS: TestAccLambdaFunction_basic (56.62s)
=== CONT  TestAccLambdaFunction_snapStart
--- PASS: TestAccLambdaFunction_ephemeralStorage (74.01s)
=== CONT  TestAccLambdaFunction_S3Update_unversioned
--- PASS: TestAccLambdaFunction_snapStart (59.42s)
=== CONT  TestAccLambdaFunction_S3Update_basic
--- PASS: TestAccLambdaFunction_S3Update_unversioned (61.15s)
=== CONT  TestAccLambdaFunction_LocalUpdate_nameOnly
--- PASS: TestAccLambdaFunction_S3Update_basic (66.58s)
=== CONT  TestAccLambdaFunction_localUpdate
--- PASS: TestAccLambdaFunction_LocalUpdate_nameOnly (57.92s)
=== CONT  TestAccLambdaFunction_s3
--- PASS: TestAccLambdaFunction_s3 (37.93s)
=== CONT  TestAccLambdaFunction_emptyVPC
--- PASS: TestAccLambdaFunction_localUpdate (49.30s)
=== CONT  TestAccLambdaFunction_VPC_replaceSGWithCustom
--- PASS: TestAccLambdaFunction_emptyVPC (43.48s)
=== CONT  TestAccLambdaFunction_VPC_replaceSGWithDefault
--- PASS: TestAccLambdaFunction_runtimes (367.76s)
=== CONT  TestAccLambdaFunction_VPC_properIAMDependencies
--- PASS: TestAccLambdaFunction_VPC_replaceSGWithDefault (417.34s)
=== CONT  TestAccLambdaFunction_VPCPublishHas_changes
--- PASS: TestAccLambdaFunction_VPC_properIAMDependencies (498.47s)
=== CONT  TestAccLambdaFunction_VPCPublishNo_changes
--- PASS: TestAccLambdaFunction_VPCPublishHas_changes (750.79s)
=== CONT  TestAccLambdaFunction_VPC_withInvocation
--- PASS: TestAccLambdaFunction_VPC_replaceSGWithCustom (1337.04s)
=== CONT  TestAccLambdaFunction_vpcUpdate
--- PASS: TestAccLambdaFunction_VPC_withInvocation (583.55s)
=== CONT  TestAccLambdaFunction_vpcRemoval
--- PASS: TestAccLambdaFunction_vpcUpdate (855.13s)
=== CONT  TestAccLambdaFunction_vpc
--- PASS: TestAccLambdaFunction_vpcRemoval (578.95s)
=== CONT  TestAccLambdaFunction_layersUpdate
--- PASS: TestAccLambdaFunction_VPCPublishNo_changes (1729.73s)
=== CONT  TestAccLambdaFunction_layers
--- PASS: TestAccLambdaFunction_layers (65.27s)
=== CONT  TestAccLambdaFunction_versioned
--- PASS: TestAccLambdaFunction_layersUpdate (82.88s)
=== CONT  TestAccLambdaFunction_architecturesWithLayer
--- PASS: TestAccLambdaFunction_versioned (36.01s)
=== CONT  TestAccLambdaFunction_architecturesUpdate
--- PASS: TestAccLambdaFunction_architecturesWithLayer (64.75s)
=== CONT  TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables
--- PASS: TestAccLambdaFunction_architecturesUpdate (56.33s)
=== CONT  TestAccLambdaFunction_architectures
--- PASS: TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables (37.39s)
=== CONT  TestAccLambdaFunction_tracing
--- PASS: TestAccLambdaFunction_architectures (50.81s)
=== CONT  TestAccLambdaFunction_fileSystem
--- PASS: TestAccLambdaFunction_vpc (418.73s)
=== CONT  TestAccLambdaFunction_nilDeadLetter
--- PASS: TestAccLambdaFunction_tracing (57.19s)
=== CONT  TestAccLambdaFunction_enablePublish
--- PASS: TestAccLambdaFunction_nilDeadLetter (14.21s)
=== CONT  TestAccLambdaFunction_versionedUpdate
--- PASS: TestAccLambdaFunction_enablePublish (72.50s)
=== CONT  TestAccLambdaFunction_deadLetterUpdated
--- PASS: TestAccLambdaFunction_versionedUpdate (82.46s)
=== CONT  TestAccLambdaFunction_disablePublish
--- PASS: TestAccLambdaFunction_deadLetterUpdated (232.18s)
=== CONT  TestAccLambdaFunction_deadLetter
--- PASS: TestAccLambdaFunction_disablePublish (213.19s)
=== CONT  TestAccLambdaFunction_unpublishedCodeUpdate
--- PASS: TestAccLambdaFunction_deadLetter (63.27s)
=== CONT  TestAccLambdaFunction_concurrencyCycle
--- PASS: TestAccLambdaFunction_unpublishedCodeUpdate (66.57s)
=== CONT  TestAccLambdaFunction_concurrency
--- PASS: TestAccLambdaFunction_concurrency (54.95s)
=== CONT  TestAccLambdaFunction_nameValidation
--- PASS: TestAccLambdaFunction_nameValidation (1.29s)
=== CONT  TestAccLambdaFunction_codeSigning
--- PASS: TestAccLambdaFunction_concurrencyCycle (69.87s)
=== CONT  TestAccLambdaFunction_envVariables
--- PASS: TestAccLambdaFunction_codeSigning (63.17s)
=== CONT  TestAccLambdaFunction_EnvironmentVariables_noValue
--- PASS: TestAccLambdaFunction_EnvironmentVariables_noValue (44.31s)
=== CONT  TestAccLambdaFunction_encryptedEnvVariables
--- PASS: TestAccLambdaFunction_envVariables (100.29s)
=== CONT  TestAccLambdaFunction_disappears
--- PASS: TestAccLambdaFunction_disappears (33.52s)
=== CONT  TestAccLambdaFunction_expectFilenameAndS3Attributes
--- PASS: TestAccLambdaFunction_expectFilenameAndS3Attributes (1.71s)
=== CONT  TestAccLambdaFunction_tags
--- PASS: TestAccLambdaFunction_encryptedEnvVariables (89.65s)
--- PASS: TestAccLambdaFunction_tags (67.13s)
--- PASS: TestAccLambdaFunction_fileSystem (850.98s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/lambda	3671.474s

@jar-b jar-b merged commit b246857 into main Feb 24, 2023
@jar-b jar-b deleted the f-aws_lambda_function-validation-err branch February 24, 2023 16:31
@github-actions github-actions bot added this to the v4.56.0 milestone Feb 24, 2023
@jar-b jar-b mentioned this pull request Feb 24, 2023
@github-actions
Copy link

This functionality has been released in v4.56.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. Thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2023
@justinretzolk justinretzolk added the aws-sdk-go-migration Issues that are related to the providers migration to AWS SDK for Go v2. label Mar 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
aws-sdk-go-migration Issues that are related to the providers migration to AWS SDK for Go v2. client-connections Pertains to the AWS Client and service connections. generators Relates to code generators. service/lambda Issues and PRs that pertain to the lambda service. size/XL Managed by automation to categorize the size of a PR. tags Pertains to resource tagging. 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.

Better Lambda error
3 participants