我从terraform文档中复制了这个资源块,并更新了值。但是,当我触发管道时,我的错误率低于,无法解决它。
我的版本:
source=“hashicorp/aws”
版本=“~>3.0”
我的资源:
resource "aws_ecs_task_definition" "aws-ecs-task" {
family = "${var.app_name}-task"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = 256
memory = 512
execution_role_arn = aws_iam_role.ecsTaskExecutionRole.arn
task_role_arn = aws_iam_role.ecsTaskExecutionRole.arn
container_definitions = jsonencode([
{
name = "${var.app_name}-${var.app_environment}-container"
image = "${var.repository_url}:latest"
essential = true
environment = "${var.app_environment}"
essential = true
portMappings = [
{
containerPort = 8080
hostPort = 8080
}
]
}
])
tags = {
Name = "${var.app_name}-ecs-td"
Environment = var.app_environment
}
}
我的错误输出:
Error: ECS Task Definition container_definitions is invalid: Error decoding JSON: json: cannot unmarshal string into Go struct field ContainerDefinition.Environment of type []*ecs.KeyValuePair
on application/cluster/cluster.tf line 84, in resource "aws_ecs_task_definition" "aws-ecs-task":
84: container_definitions = jsonencode([
85: {
86: name = "${var.app_name}-${var.app_environment}-container"
87: image = "${var.repository_url}:latest"
88: essential = true
89: environment = "${var.app_environment}"
90: essential = true
91: portMappings = [
92: {
93: containerPort = 8080
94: hostPort = 8080
95: }
96: ]
97: }
98: ])