【发布时间】:2019-04-12 20:31:46
【问题描述】:
不要因为这个SO Answer而将其标记为重复@
我有一个“aws_lambda_function”资源,它工作正常。
现在我想部署另一个 lambda 函数,我尝试使用不同的处理程序和别名复制整个块,但它会引发错误。有没有其他方法可以做到这一点。
提前致谢。
更新
这里是地形代码:
resource "aws_lambda_function" "api_service" {
function_name = "${substr("${local.api_artifact_name}", 0, min(64, length(local.api_artifact_name)))}"
# Artifacts bucket
s3_bucket = "${local.artifacts_bucket_name}"
s3_key = "${module.artifact-upload.artifact_key}"
# "index" is the filename within the zip file (main.js) and "handler"
# is the name of the property under which the handler function was
# exported in that file.
handler = "index.api"
runtime = "nodejs8.10"
role = "${module.api-service-iam.iam_role_arn}"
# Optional, but ensures that things don't constantly refresh during local development
source_code_hash = "${base64sha256(file("${local.api_dist_dir}"))}"
environment {
variables = {
...
}
}
}
现在资源 api_service 成功部署了一个 Lambda 函数,但我该如何部署,比如说,5 个这样的函数?
All these Lambda functions will be invoked by an API Gateway later.
【问题讨论】:
-
您的 Terraform 代码是什么样的?运行
terraform plan或terraform apply时遇到的确切错误是什么? -
这是个好问题,我会更新我的帖子。
-
这是一个很好的问题,我也在努力解决这个问题。我有 20 个 Lambda 函数要部署。我能想到的唯一方法是使用 vars 作为
type=map,然后在映射中列出每个单独的 Lambda 函数配置,然后在tf脚本中使用count=??和${count.index}循环遍历映射。不过还没试过,我还在努力。 -
@Geet Choubey 你找到方法了吗?
-
@dege 是的,它起作用了。
标签: aws-lambda terraform terraform-provider-aws