【发布时间】:2021-12-01 00:34:22
【问题描述】:
我在 terraform 中有以下配置来部署 ecs 任务定义。可以创建任务并且所有配置都很好,除了环境变量。我在container_definitions 中指定了environment,但任务仍然没有定义任何环境变量。
如何在此脚本中指定环境变量?
resource "aws_ecs_task_definition" "data-check" {
family = "${var.stage}-data-check"
execution_role_arn = aws_iam_role.ecs_data_check_role.arn
container_definitions = <<TASK_DEFINITION
[
{
"name" : "data-check-task",
"image" : "${local.image_name}",
"essential" : true,
"environment" : [{
"name" : "this is name"
}],
"logConfiguration" : {
"logDriver" : "awslogs",
"options" : {
"awslogs-region" : "${var.aws_region}",
"awslogs-group" : "/ecs/${local.ecs_name}",
"awslogs-stream-prefix" : "ecs"
}
}
}
]
TASK_DEFINITION
cpu = 1024
memory = 2048
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
}
【问题讨论】:
标签: terraform amazon-ecs