Open natemccurdy opened 11 months ago
Looks like this is actually related to https://github.com/hashicorp/terraform-provider-aws/issues/29085
The last_modified
value changes on each Terraform run for unknown reasons, which is why most modules that wrap aws_lambda_function
ignore that with a lifecycle block.
I tested removing the filename
attribute from this module, only leaving s3_key
and s3_object
(as that's what I need for my use case), and I removed the lifecycle block. The result is that Terraform detected drift on each run for unknown reasons. The last_modified
changes every time Terraform runs.
# module.foo.module.lambda_changes.aws_lambda_function.this[0] will be updated in-place
~ resource "aws_lambda_function" "this" {
id = "test"
~ last_modified = "2023-10-05T21:55:22.433+0000" -> (known after apply)
tags = {}
# (23 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
So, because of the bug I linked above, it's good that this module ignores last_modified
. But an unfortunate side-effect of that on modern Terraform versions is the Warning seen in this bug post.
Is there any workaround to get rid of this warning message ?
Describe the Bug
When running
terraform plan
(orapply
), a declaration of this module throws the following warning:The error is coming from the
lifecycle
block at https://github.com/cloudposse/terraform-aws-lambda-function/blob/0.5.1/main.tf#L93-L95Expected Behavior
When running
terraform plan
(orapply
), a declaration of this module does not throw a "Redundant ignore_changes element" warningSteps to Reproduce
In my case, I declared this module with
s3_bucket
ands3_key
:Then ran
terraform apply
from the root module shown above. The Lambda and related resources were created just fine, but the Terraform run ended with the "ignore_changes" warning.Environment
Versions:
Additional Context
Root cause and the reason for the
lifecycle
block in the first place: https://github.com/hashicorp/terraform-provider-aws/issues/29085