terraform apply “terraform.tfplan”
aws_ecs_task_definition.nginx: Creating…
Error: Error decoding JSON: invalid character ‘0’ after object key:value pair
on main.tf line 151, in resource “aws_ecs_task_definition” “nginx”:
151: resource “aws_ecs_task_definition” “nginx” {
When I run terraform apply (see above), I get some kind of a JSON parsing error. This worked fine in 0.11.15, but when I upgraded to 0.12.0 I am getting this error now.
My relevant terraform code is below, is there anything that stands out that is causing this error?
What is the best way to debug this?
main.tf
data "template_file" "nginx" {
template = file("task-definitions/nginx.json")
vars = {
cpu = var.nginx_fargate_cpu
image = "${module.repository_nginx.repository_url}:${var.image_tag}"
memory = var.nginx_fargate_memory
log_group = "log${var.project}Nginx"
aws_region = var.aws_region
project = var.project
environment = var.environment
}
}
resource "aws_ecs_task_definition" "nginx" {
family = "${var.project}Nginx"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = var.nginx_fargate_cpu
memory = var.nginx_fargate_memory
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
container_definitions = data.template_file.nginx.rendered
}
The JSON for this task is:
[
{
"name": "nginx",
"image": "${image}",
"cpu": ${cpu},
"memory": ${memory},
"portMappings": [
{
"containerPort": 8080
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${log_group}",
"awslogs-region": "${aws_region}",
"awslogs-stream-prefix": "nginx"
}
}
}
]