Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Redundant ignore_changes element: in resource "aws_lambda_function" "this"

未关闭
#43 2 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
aws, terraform

调研方向

从 main.tf 中第 93–95 行附近的 lifecycle 块开始,检查针对 aws_lambda_function 资源的 Terraform 警告。使用 Terraform v1.5.6、AWS provider v5.19.0 以及报告中描述的 s3_bucket/s3_key 模块配置复现该问题。完成标准是 terraform plan 或 apply 在没有冗余 ignore_changes 警告的情况下完成。

由索引模型根据 Issue 内容生成。

描述

bug
Describe the Bug

When running terraform plan (or apply), a declaration of this module throws the following warning:

│ Warning: Redundant ignore_changes element
│
│   on .terraform/modules/foo.lambda_changes/main.tf line 21, in resource "aws_lambda_function" "this":
│   21: resource "aws_lambda_function" "this" {
│
│ Adding an attribute name to ignore_changes tells Terraform to ignore future changes to the argument in configuration after the object has been created, retaining the value originally configured.
│
│ The attribute last_modified is decided by the provider alone and therefore there can be no configured value to compare with. Including this attribute in ignore_changes has no effect. Remove the attribute from ignore_changes to quiet this
│ warning.
│
│ (and one more similar warning elsewhere)

The error is coming from the lifecycle block at https://github.com/cloudposse/terraform-aws-lambda-function/blob/0.5.1/main.tf#L93-L95

lifecycle {
  ignore_changes = [last_modified]
}
Expected Behavior

When running terraform plan (or apply), a declaration of this module does not throw a "Redundant ignore_changes element" warning

Steps to Reproduce

In my case, I declared this module with s3_bucket and s3_key:

module "lambda_responses" {
  source  = "cloudposse/lambda-function/aws"
  version = "0.5.1"

  function_name = "${module.lambda_label.id}-test"
  attributes    = concat(module.lambda_label.attributes, ["test"])
  description   = "Yay lambdas"
  s3_bucket     = var.responses_lambda_s3_bucket
  s3_key        = var.responses_lambda_s3_key
  runtime       = var.responses_lambda_runtime
  handler       = var.responses_lambda_handler
  architectures = ["x86_64"]
  context       = module.lambda_label.context
}

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:

  • Terraform v1.5.6
  • module cloudposse/lambda-function/aws 0.5.1
  • provider registry.terraform.io/hashicorp/aws v5.19.0
  • provider registry.terraform.io/hashicorp/time v0.9.1
Additional Context

Root cause and the reason for the lifecycle block in the first place: https://github.com/hashicorp/terraform-provider-aws/issues/29085

主要语言
HCL
星标
36
派生
44
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudposse/terraform-aws-lambda-function 的其他 Issue

查看 cloudposse/terraform-aws-lambda-function 的全部 Issue

相似的 Issue

更多 Cloud Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。