![通过 terraform 的 AWS lambda 函数 - 无法解压缩上传的文件。请检查您的文件,然后尝试重新上传](https://linux22.com/image/193832/%E9%80%9A%E8%BF%87%20terraform%20%E7%9A%84%20AWS%20lambda%20%E5%87%BD%E6%95%B0%20-%20%E6%97%A0%E6%B3%95%E8%A7%A3%E5%8E%8B%E7%BC%A9%E4%B8%8A%E4%BC%A0%E7%9A%84%E6%96%87%E4%BB%B6%E3%80%82%E8%AF%B7%E6%A3%80%E6%9F%A5%E6%82%A8%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%8C%E7%84%B6%E5%90%8E%E5%B0%9D%E8%AF%95%E9%87%8D%E6%96%B0%E4%B8%8A%E4%BC%A0.png)
我正在使用 terraform 创建 lambda 函数,并且 S3 中已经有 zip 包:
{
RespMetadata: {
StatusCode: 400,
RequestID: "fa9b0e8b-02a6-4eaf-81ae-bf30fc6a1153"
},
Message_: "Could not unzip uploaded file. Please check your file, then try to upload again.",
Type: "User"
}
我的代码如下所示:
resource "aws_lambda_function" "test_lambda" {
s3_bucket = "bucket_name"
s3_key = "lambda.zip"
function_name = "Function_Test"
role = aws_iam_role.test_lambda_role.arn
handler = "config.lambda_handler"
runtime = "python3.8"
timeout = 180
vpc_config {
subnet_ids = ["subnet-123"]
security_group_ids = ["sg-123"]
}
environment {
variables = {
LOG_LEVEL = "DEBUG"
host = "https://abc:9098"
}
}
}