【发布时间】:2021-05-02 02:09:47
【问题描述】:
我试图了解在启动 AWS Batch 作业时如何进行参数替换。我需要做的是为我的 AWS Batch 作业提供一个 S3 对象密钥。我还没有找到将参数传递给批处理作业的 Terraform 示例,我似乎无法让它工作。
aws_batch_job_definition 的文档包含以下示例:
resource "aws_batch_job_definition" "test" {
name = "tf_test_batch_job_definition"
type = "container"
container_properties = <<CONTAINER_PROPERTIES
{
"command": ["ls", "-la"],
"image": "busybox",
"memory": 1024,
"vcpus": 1,
"volumes": [
{
"host": {
"sourcePath": "/tmp"
},
"name": "tmp"
}
],
"environment": [
{"name": "VARNAME", "value": "VARVAL"}
],
"mountPoints": [
{
"sourceVolume": "tmp",
"containerPath": "/tmp",
"readOnly": false
}
],
"ulimits": [
{
"hardLimit": 1024,
"name": "nofile",
"softLimit": 1024
}
]
}
CONTAINER_PROPERTIES
}
假设我希望 VARNAME 成为一个参数,这样当我通过 AWS Batch API 启动作业时,我会指定它的值。这是如何实现的?根据aws_batch_job_definition 资源的文档,有一个名为parameters 的参数。然而,这是一张地图,而不是我所期望的列表。此映射中给出的键和值是什么?
【问题讨论】:
标签: terraform terraform-provider-aws aws-batch