我已将批处理作业指定为:
resource "aws_batch_job_definition" "batch_job" {
name = "${var.name}"
type = "container"
container_properties = <<CONTAINER_PROPERTIES
{
"command": ["${var.command_first}", "${var.command_second}"],
"image": "${var.image_repo}:${var.image_tag}",
"memory": ${var.memory},
"vcpus": 1,
"jobRoleArn": "${var.job_role_arn}",
"environment": "${var.environment}"
}
CONTAINER_PROPERTIES
}
其中 var.environment 来自输入变量
variable "environment" {
}
在我的 terraform 值文件中,我有
environment = {
[
{"name" : "AWS_DEFAULT_REGION", "value" : "region-val"}
]
}
但它不喜欢这种格式。
如果我这样指定批处理作业:
resource "aws_batch_job_definition" "batch_job" {
name = "${var.name}"
type = "container"
container_properties = <<CONTAINER_PROPERTIES
{
"command": ["${var.command_first}", "${var.command_second}"],
"image": "${var.image_repo}:${var.image_tag}",
"memory": ${var.memory},
"vcpus": 1,
"jobRoleArn": "${var.job_role_arn}",
"environment": [
{"name" : "AWS_DEFAULT_REGION", "value" : "region-val"}
]
}
CONTAINER_PROPERTIES
}
它有效,所以问题是当我将它移动到变量文件时它不起作用。
格式应该是什么以及如何在批处理作业定义中使用它?
谢谢!