-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Bug fix] aws_lambda_function: Suppress false persistent diffs on log levels when logging_format = "JSON" and publish = true #42660
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
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
publish
is true
Would really appreciate this PR to get merged to solve this ugly bug of fake lambda changes which spam the tf plan |
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.
LGTM 🚀.
% make testacc TESTARGS='-run=TestAccLambdaFunction_' PKG=lambda ACCTEST_PARALLELISM=4
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.10 test ./internal/service/lambda/... -v -count 1 -parallel 4 -run=TestAccLambdaFunction_ -timeout 360m -vet=off
2025/06/17 09:09:33 Initializing Terraform AWS Provider...
=== RUN TestAccLambdaFunction_tags
=== PAUSE TestAccLambdaFunction_tags
=== RUN TestAccLambdaFunction_tags_null
=== PAUSE TestAccLambdaFunction_tags_null
=== RUN TestAccLambdaFunction_tags_EmptyMap
=== PAUSE TestAccLambdaFunction_tags_EmptyMap
=== RUN TestAccLambdaFunction_tags_AddOnUpdate
=== PAUSE TestAccLambdaFunction_tags_AddOnUpdate
=== RUN TestAccLambdaFunction_tags_EmptyTag_OnCreate
=== PAUSE TestAccLambdaFunction_tags_EmptyTag_OnCreate
=== RUN TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Add
=== PAUSE TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Add
=== RUN TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Replace
=== PAUSE TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Replace
=== RUN TestAccLambdaFunction_tags_DefaultTags_providerOnly
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_providerOnly
=== RUN TestAccLambdaFunction_tags_DefaultTags_nonOverlapping
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_nonOverlapping
=== RUN TestAccLambdaFunction_tags_DefaultTags_overlapping
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_overlapping
=== RUN TestAccLambdaFunction_tags_DefaultTags_updateToProviderOnly
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_updateToProviderOnly
=== RUN TestAccLambdaFunction_tags_DefaultTags_updateToResourceOnly
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_updateToResourceOnly
=== RUN TestAccLambdaFunction_tags_DefaultTags_emptyResourceTag
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_emptyResourceTag
=== RUN TestAccLambdaFunction_tags_DefaultTags_emptyProviderOnlyTag
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_emptyProviderOnlyTag
=== RUN TestAccLambdaFunction_tags_DefaultTags_nullOverlappingResourceTag
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_nullOverlappingResourceTag
=== RUN TestAccLambdaFunction_tags_DefaultTags_nullNonOverlappingResourceTag
=== PAUSE TestAccLambdaFunction_tags_DefaultTags_nullNonOverlappingResourceTag
=== RUN TestAccLambdaFunction_tags_ComputedTag_OnCreate
=== PAUSE TestAccLambdaFunction_tags_ComputedTag_OnCreate
=== RUN TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Add
=== PAUSE TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Add
=== RUN TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Replace
=== PAUSE TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Replace
=== RUN TestAccLambdaFunction_tags_IgnoreTags_Overlap_DefaultTag
=== PAUSE TestAccLambdaFunction_tags_IgnoreTags_Overlap_DefaultTag
=== RUN TestAccLambdaFunction_tags_IgnoreTags_Overlap_ResourceTag
=== PAUSE TestAccLambdaFunction_tags_IgnoreTags_Overlap_ResourceTag
=== RUN TestAccLambdaFunction_basic
=== PAUSE TestAccLambdaFunction_basic
=== RUN TestAccLambdaFunction_disappears
=== PAUSE TestAccLambdaFunction_disappears
=== 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:932: 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_loggingConfig
=== PAUSE TestAccLambdaFunction_loggingConfig
=== RUN TestAccLambdaFunction_loggingConfigWithPublish
=== PAUSE TestAccLambdaFunction_loggingConfigWithPublish
=== 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
=== RUN TestAccLambdaFunction_ipv6AllowedForDualStack
=== PAUSE TestAccLambdaFunction_ipv6AllowedForDualStack
=== RUN TestAccLambdaFunction_skipDestroy
=== PAUSE TestAccLambdaFunction_skipDestroy
=== CONT TestAccLambdaFunction_tags
=== CONT TestAccLambdaFunction_disablePublish
=== CONT TestAccLambdaFunction_VPC_withInvocation
=== CONT TestAccLambdaFunction_skipDestroy
--- PASS: TestAccLambdaFunction_skipDestroy (37.60s)
=== CONT TestAccLambdaFunction_ipv6AllowedForDualStack
--- PASS: TestAccLambdaFunction_disablePublish (52.01s)
=== CONT TestAccLambdaFunction_Zip_validation
--- PASS: TestAccLambdaFunction_Zip_validation (3.08s)
=== CONT TestAccLambdaFunction_runtimes
--- PASS: TestAccLambdaFunction_tags (68.48s)
=== CONT TestAccLambdaFunction_snapStart
--- PASS: TestAccLambdaFunction_snapStart (187.70s)
=== CONT TestAccLambdaFunction_S3Update_unversioned
--- PASS: TestAccLambdaFunction_S3Update_unversioned (47.64s)
=== CONT TestAccLambdaFunction_S3Update_basic
--- PASS: TestAccLambdaFunction_S3Update_basic (51.96s)
=== CONT TestAccLambdaFunction_LocalUpdate_nameOnly
--- PASS: TestAccLambdaFunction_LocalUpdate_nameOnly (95.88s)
=== CONT TestAccLambdaFunction_localUpdate
--- PASS: TestAccLambdaFunction_localUpdate (42.69s)
=== CONT TestAccLambdaFunction_s3
--- PASS: TestAccLambdaFunction_s3 (29.09s)
=== CONT TestAccLambdaFunction_emptyVPC
--- PASS: TestAccLambdaFunction_emptyVPC (39.84s)
=== CONT TestAccLambdaFunction_VPC_replaceSGWithCustom
--- PASS: TestAccLambdaFunction_VPC_withInvocation (598.01s)
=== CONT TestAccLambdaFunction_VPC_replaceSGWithDefault
--- PASS: TestAccLambdaFunction_runtimes (582.87s)
=== CONT TestAccLambdaFunction_VPC_properIAMDependencies
--- PASS: TestAccLambdaFunction_ipv6AllowedForDualStack (772.60s)
=== CONT TestAccLambdaFunction_VPCPublishHas_changes
--- PASS: TestAccLambdaFunction_VPC_replaceSGWithCustom (276.20s)
=== CONT TestAccLambdaFunction_VPCPublishNo_changes
--- PASS: TestAccLambdaFunction_VPC_replaceSGWithDefault (415.27s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_overlapping
--- PASS: TestAccLambdaFunction_VPC_properIAMDependencies (375.47s)
=== CONT TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Add
--- PASS: TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Add (207.84s)
=== CONT TestAccLambdaFunction_tags_ComputedTag_OnCreate
--- PASS: TestAccLambdaFunction_tags_DefaultTags_overlapping (215.76s)
=== CONT TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Replace
--- PASS: TestAccLambdaFunction_tags_ComputedTag_OnCreate (32.15s)
=== CONT TestAccLambdaFunction_enablePublish
--- PASS: TestAccLambdaFunction_tags_ComputedTag_OnUpdate_Replace (42.61s)
=== CONT TestAccLambdaFunction_versionedUpdate
--- PASS: TestAccLambdaFunction_enablePublish (60.52s)
=== CONT TestAccLambdaFunction_versioned
--- PASS: TestAccLambdaFunction_versionedUpdate (72.15s)
=== CONT TestAccLambdaFunction_nameValidation
--- PASS: TestAccLambdaFunction_nameValidation (0.79s)
=== CONT TestAccLambdaFunction_encryptedEnvVariables
--- PASS: TestAccLambdaFunction_versioned (39.50s)
=== CONT TestAccLambdaFunction_EnvironmentVariables_noValue
--- PASS: TestAccLambdaFunction_EnvironmentVariables_noValue (39.74s)
=== CONT TestAccLambdaFunction_envVariables
--- PASS: TestAccLambdaFunction_encryptedEnvVariables (74.23s)
=== CONT TestAccLambdaFunction_expectFilenameAndS3Attributes
--- PASS: TestAccLambdaFunction_expectFilenameAndS3Attributes (0.86s)
=== CONT TestAccLambdaFunction_concurrencyCycle
--- PASS: TestAccLambdaFunction_VPCPublishNo_changes (595.19s)
=== CONT TestAccLambdaFunction_concurrency
--- PASS: TestAccLambdaFunction_concurrencyCycle (62.50s)
=== CONT TestAccLambdaFunction_codeSigning
--- PASS: TestAccLambdaFunction_concurrency (50.64s)
=== CONT TestAccLambdaFunction_unpublishedCodeUpdate
--- PASS: TestAccLambdaFunction_envVariables (89.26s)
=== CONT TestAccLambdaFunction_disappears
--- PASS: TestAccLambdaFunction_codeSigning (50.95s)
=== CONT TestAccLambdaFunction_basic
--- PASS: TestAccLambdaFunction_disappears (38.30s)
=== CONT TestAccLambdaFunction_tags_IgnoreTags_Overlap_ResourceTag
--- PASS: TestAccLambdaFunction_unpublishedCodeUpdate (56.35s)
=== CONT TestAccLambdaFunction_tags_IgnoreTags_Overlap_DefaultTag
--- PASS: TestAccLambdaFunction_basic (40.00s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_nullNonOverlappingResourceTag
--- PASS: TestAccLambdaFunction_tags_IgnoreTags_Overlap_ResourceTag (56.02s)
=== CONT TestAccLambdaFunction_tags_AddOnUpdate
--- PASS: TestAccLambdaFunction_tags_IgnoreTags_Overlap_DefaultTag (49.56s)
=== CONT TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Add
--- PASS: TestAccLambdaFunction_tags_DefaultTags_nullNonOverlappingResourceTag (29.55s)
=== CONT TestAccLambdaFunction_tags_EmptyTag_OnCreate
--- PASS: TestAccLambdaFunction_tags_AddOnUpdate (39.16s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_nonOverlapping
--- PASS: TestAccLambdaFunction_tags_EmptyTag_OnCreate (41.42s)
=== CONT TestAccLambdaFunction_loggingConfig
--- PASS: TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Add (56.41s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_providerOnly
--- PASS: TestAccLambdaFunction_tags_DefaultTags_nonOverlapping (56.51s)
=== CONT TestAccLambdaFunction_vpcUpdate
--- PASS: TestAccLambdaFunction_tags_DefaultTags_providerOnly (73.53s)
=== CONT TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Replace
--- PASS: TestAccLambdaFunction_loggingConfig (83.05s)
=== CONT TestAccLambdaFunction_vpcRemoval
--- PASS: TestAccLambdaFunction_tags_EmptyTag_OnUpdate_Replace (211.79s)
=== CONT TestAccLambdaFunction_layers
--- PASS: TestAccLambdaFunction_layers (180.18s)
=== CONT TestAccLambdaFunction_vpc
--- PASS: TestAccLambdaFunction_vpcRemoval (397.35s)
=== CONT TestAccLambdaFunction_layersUpdate
--- PASS: TestAccLambdaFunction_layersUpdate (55.84s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_emptyResourceTag
--- PASS: TestAccLambdaFunction_VPCPublishHas_changes (1481.55s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_emptyProviderOnlyTag
--- PASS: TestAccLambdaFunction_vpcUpdate (625.79s)
=== CONT TestAccLambdaFunction_tracing
--- PASS: TestAccLambdaFunction_tags_DefaultTags_emptyResourceTag (172.34s)
=== CONT TestAccLambdaFunction_architectures
--- PASS: TestAccLambdaFunction_tags_DefaultTags_emptyProviderOnlyTag (54.02s)
=== CONT TestAccLambdaFunction_ephemeralStorage
--- PASS: TestAccLambdaFunction_tracing (72.70s)
=== CONT TestAccLambdaFunction_architecturesWithLayer
--- PASS: TestAccLambdaFunction_architectures (50.02s)
=== CONT TestAccLambdaFunction_tags_EmptyMap
--- PASS: TestAccLambdaFunction_ephemeralStorage (56.41s)
=== CONT TestAccLambdaFunction_architecturesUpdate
--- PASS: TestAccLambdaFunction_tags_EmptyMap (33.21s)
=== CONT TestAccLambdaFunction_loggingConfigWithPublish
--- PASS: TestAccLambdaFunction_architecturesWithLayer (68.22s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_updateToResourceOnly
--- PASS: TestAccLambdaFunction_architecturesUpdate (56.49s)
=== CONT TestAccLambdaFunction_nilDeadLetter
--- PASS: TestAccLambdaFunction_tags_DefaultTags_updateToResourceOnly (38.30s)
=== CONT TestAccLambdaFunction_fileSystem
--- PASS: TestAccLambdaFunction_nilDeadLetter (31.42s)
=== CONT TestAccLambdaFunction_deadLetterUpdated
--- PASS: TestAccLambdaFunction_loggingConfigWithPublish (121.76s)
=== CONT TestAccLambdaFunction_tags_null
--- PASS: TestAccLambdaFunction_deadLetterUpdated (56.15s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_nullOverlappingResourceTag
--- PASS: TestAccLambdaFunction_vpc (471.59s)
=== CONT TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables
--- PASS: TestAccLambdaFunction_tags_null (33.50s)
=== CONT TestAccLambdaFunction_deadLetter
--- PASS: TestAccLambdaFunction_tags_DefaultTags_nullOverlappingResourceTag (33.90s)
=== CONT TestAccLambdaFunction_tags_DefaultTags_updateToProviderOnly
--- PASS: TestAccLambdaFunction_KMSKeyARN_noEnvironmentVariables (41.56s)
--- PASS: TestAccLambdaFunction_tags_DefaultTags_updateToProviderOnly (42.15s)
--- PASS: TestAccLambdaFunction_deadLetter (56.13s)
--- PASS: TestAccLambdaFunction_fileSystem (999.87s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/lambda 3495.146s
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.
LGTM 🚀
Warning This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
@tabito-hara Thanks for the contribution 🎉 👏. |
This functionality has been released in v6.1.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! |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
When
logging_format
inlogging_config
is set toJSON
andpublish
istrue
, persistent diffs appear. This PR fixes that issue.application_log_level
andsystem_log_level
) are not explicitly specified, the AWS API response for describing Lambda functions differs depending on thelogging_format
. When the format isText
, the default log level is an empty string (""
), but when the format isJSON
, the default is"INFO"
.logging_format
isJSON
, the log level in the Terraform state is refreshed to"INFO"
, causing Terraform to plan an update to reset it back to the default value of""
.DiffSuppressFunc
introduced in Resolve logging_config consecutive diff issue #35694.publish
istrue
, Terraform determines whether to updateversion
,qualified_arn
, andqualified_invoke_arn
usingd.HasChange()
for each argument. The issue is thatd.HasChange()
does not takeDiffSuppressFunc
into account—it only checks for literal differences in the argument values.The function that determines whether a new version should be published now incorporates the logic of
DiffSuppressFunc
for log levels.The newly added acceptance tests verify that no plan diffs occur when log levels remain unchanged.
See also
aws_lambda_function
perpetual difference whenlog_format
is set toJSON
#42181 (comment)Relations
Closes #42181
Closes #41065
Relates #35694
Output from Acceptance Testing
Some tests failed, which are reported in #42661.
One test (TestAccLambdaFunction_versionedUpdate) is fixed in this PR.