[英]AWS Lambda not updating using Terraform source_code_hash property
I have a Terraform configuration for creating a Lambda resource and am using the source_code_hash property to detect changes to the zip.我有一个用于创建 Lambda 资源的 Terraform 配置,我正在使用 source_code_hash 属性来检测对 zip 的更改。 I am also uploading a separate file that contains the SHA256 hash of the file along with the zip file to S3.我还将一个单独的文件上传到 S3,其中包含文件的 SHA256 哈希值以及 zip 文件。
I am able to do the deploy once, but then the problem is that the running Lambda is not getting updated after I update the zip and in the build log I am seeing "Still creating..."我可以进行一次部署,但问题是在我更新 zip 后运行的 Lambda 没有得到更新,并且在构建日志中我看到“仍在创建...”
How can I see the value of the source_code_hash property?如何查看 source_code_hash 属性的值? I just see + source_code_hash = (known after apply) both in the plan output and the apply output so I don't know if the value is getting updated or not.我只在计划输出和应用输出中看到 + source_code_hash = (known after apply),所以我不知道该值是否正在更新。
My code is below:我的代码如下:
data "aws_s3_object" "source_hash" {
bucket = "dap-bucket-2"
key = "lambda.zip.sha256"
}
resource "aws_lambda_function" "lambda" {
function_name = "lambda_function_name"
s3_bucket = "dap-bucket-2"
s3_key = "lambda.zip"
handler = "template.handleRequest"
runtime = "java11"
role = aws_iam_role.lambda_exec.arn
source_code_hash = "${data.aws_s3_object.source_hash.body}"
publish = true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.