Gee*_*bey 5 aws-lambda terraform terraform-provider-aws
由于此SO 答案,请勿将其标记为重复
我有一个“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 = {
...
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在该资源api_service成功部署了一个 Lambda 函数,但我该如何部署,比如说,5 个这样的函数?
All these Lambda functions will be invoked by an API Gateway later.
我基本上为每个 lambda 创建一个目录,并采用policy.json、ssm_parameters.json 等工件的命名约定。
1) 我使用外部数据源来获取目录中的 lambda 函数列表,并获取每个 Lambda 所需的所有元数据 2) 我使用 count="N" 来部署每个 lambda 资源。
| 归档时间: |
|
| 查看次数: |
3077 次 |
| 最近记录: |