无法使用 terraform 在 AWS 控制台上更新 lambda 代码
Not able to update lambda code on AWS console using terraform
我正在根据 terraform 语法使用 terraform 创建 lambda 函数 lambda 代码应作为 zip 文件传递。以类似的方式,我传入了一个资源块,并且它的创建也没有任何问题。但是当我尝试在下一个 运行 中使用 terraform 更新 lambda 代码时,它没有得到更新。以下区块供参考。
data "archive_file" "stop_ec2" {
type = "zip"
source_file = "src_dir/stop_ec2.py"
output_path = "dest_dir/stop_ec2_upload.zip"
}
resource "aws_lambda_function" "stop_ec2" {
function_name = "stopEC2"
handler = "stop_ec2.handler"
runtime = "python3.6"
filename = "dest_dir/stop_ec2_upload.zip"
role = "..."
}
需要帮助解决这个问题。
设置 source_code_hash 参数,这样 Terraform 就会在 lambda 代码更改时更新 lambda 函数。
resource "aws_lambda_function" "stop_ec2" {
source_code_hash = filebase64sha256("dest_dir/stop_ec2_upload.zip")
我正在根据 terraform 语法使用 terraform 创建 lambda 函数 lambda 代码应作为 zip 文件传递。以类似的方式,我传入了一个资源块,并且它的创建也没有任何问题。但是当我尝试在下一个 运行 中使用 terraform 更新 lambda 代码时,它没有得到更新。以下区块供参考。
data "archive_file" "stop_ec2" {
type = "zip"
source_file = "src_dir/stop_ec2.py"
output_path = "dest_dir/stop_ec2_upload.zip"
}
resource "aws_lambda_function" "stop_ec2" {
function_name = "stopEC2"
handler = "stop_ec2.handler"
runtime = "python3.6"
filename = "dest_dir/stop_ec2_upload.zip"
role = "..."
}
需要帮助解决这个问题。
设置 source_code_hash 参数,这样 Terraform 就会在 lambda 代码更改时更新 lambda 函数。
resource "aws_lambda_function" "stop_ec2" {
source_code_hash = filebase64sha256("dest_dir/stop_ec2_upload.zip")