-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
resource/aws_lambda_function: Prevent crash with missing environment variable value #17056
Conversation
…variable value Previously if the environment variable value became `nil` (likely via AWS console update), the resource could panic: ``` { "Configuration": { ... "Environment": { "Variables": { "XXX": null, "YYY": "ZZZ" }, "Error": null }, ... }, ... } ``` ``` panic: runtime error: invalid memory address or nil pointer dereference 2020-12-10T19:59:19.412Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x401dab7] 2020-12-10T19:59:19.413Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: 2020-12-10T19:59:19.413Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: goroutine 485 [running]: 2020-12-10T19:59:19.413Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.flattenLambdaEnvironment(0xc00162daa0, 0x57add72, 0xa, 0x44b4460) 2020-12-10T19:59:19.413Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1594 +0xc7 2020-12-10T19:59:19.413Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLambdaFunctionRead(0xc00016ee00, 0x4c948a0, 0xc000160a00, 0xc00016ee00, 0x0) 2020-12-10T19:59:19.413Z [DEBUG] plugin.terraform-provider-aws_v3.0.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lambda_function.go:599 +0x107a ``` This replaces the unsafe dereferencing with the AWS Go SDK conversion function. Output from acceptance testing: ``` --- PASS: TestAccAWSLambdaFunction_basic (93.45s) --- PASS: TestAccAWSLambdaFunction_codeSigningConfig (143.84s) --- PASS: TestAccAWSLambdaFunction_concurrency (119.18s) --- PASS: TestAccAWSLambdaFunction_concurrencyCycle (80.17s) --- PASS: TestAccAWSLambdaFunction_DeadLetterConfig (130.84s) --- PASS: TestAccAWSLambdaFunction_DeadLetterConfigUpdated (139.36s) --- PASS: TestAccAWSLambdaFunction_disablePublish (290.84s) --- PASS: TestAccAWSLambdaFunction_disappears (76.76s) --- PASS: TestAccAWSLambdaFunction_EmptyVpcConfig (303.87s) --- PASS: TestAccAWSLambdaFunction_enablePublish (301.82s) --- PASS: TestAccAWSLambdaFunction_encryptedEnvVariables (152.33s) --- PASS: TestAccAWSLambdaFunction_Environment_Variables_NoValue (59.03s) --- PASS: TestAccAWSLambdaFunction_envVariables (135.67s) --- PASS: TestAccAWSLambdaFunction_expectFilenameAndS3Attributes (19.70s) --- PASS: TestAccAWSLambdaFunction_FileSystemConfig (2369.47s) --- PASS: TestAccAWSLambdaFunction_KmsKeyArn_NoEnvironmentVariables (1001.01s) --- PASS: TestAccAWSLambdaFunction_Layers (830.27s) --- PASS: TestAccAWSLambdaFunction_LayersUpdate (1218.31s) --- PASS: TestAccAWSLambdaFunction_localUpdate (1253.77s) --- PASS: TestAccAWSLambdaFunction_localUpdate_nameOnly (318.24s) --- PASS: TestAccAWSLambdaFunction_nilDeadLetterConfig (75.02s) --- PASS: TestAccAWSLambdaFunction_runtimes (434.13s) --- PASS: TestAccAWSLambdaFunction_s3 (39.17s) --- PASS: TestAccAWSLambdaFunction_s3Update_basic (65.26s) --- PASS: TestAccAWSLambdaFunction_s3Update_unversioned (66.94s) --- PASS: TestAccAWSLambdaFunction_tags (111.80s) --- PASS: TestAccAWSLambdaFunction_tracingConfig (1022.97s) --- PASS: TestAccAWSLambdaFunction_UnpublishedCodeUpdate (326.86s) --- PASS: TestAccAWSLambdaFunction_versioned (816.85s) --- PASS: TestAccAWSLambdaFunction_versionedUpdate (1283.13s) --- PASS: TestAccAWSLambdaFunction_VPC (810.42s) --- PASS: TestAccAWSLambdaFunction_VPC_withInvocation (1415.48s) --- PASS: TestAccAWSLambdaFunction_VpcConfig_ProperIamDependencies (346.28s) --- PASS: TestAccAWSLambdaFunction_VPCRemoval (2383.24s) --- PASS: TestAccAWSLambdaFunction_VPCUpdate (2409.76s) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, looks great! 🚀
Additional test output for data source which shares same flatten func:
--- PASS: TestAccDataSourceAWSLambdaFunction_environment (38.01s)
--- PASS: TestAccDataSourceAWSLambdaFunction_alias (46.87s)
--- PASS: TestAccDataSourceAWSLambdaFunction_version (52.69s)
--- PASS: TestAccDataSourceAWSLambdaFunction_basic (61.65s)
--- PASS: TestAccDataSourceAWSLambdaFunction_layers (70.06s)
--- PASS: TestAccDataSourceAWSLambdaFunction_fileSystemConfig (502.32s)
--- PASS: TestAccDataSourceAWSLambdaFunction_vpc (620.54s)
This has been released in version 3.25.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! |
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! |
Community Note
Release note for CHANGELOG:
Previously if the environment variable value became
nil
(likely via AWS console update), the resource could panic:This replaces the unsafe dereferencing with the AWS Go SDK conversion function.
Output from acceptance testing: