I am working on building a fargate cluster and am having difficulties following the documentation for the aws_ecs_task_definition section (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition)
│ Error: ECS Task Definition container_definitions is invalid: Error decoding JSON: json: cannot unmarshal string into Go struct field ContainerDefinition.Cpu of type int64
│
│ with aws_ecs_task_definition.app,
│ on ecs.tf line 40, in resource "aws_ecs_task_definition" "app":
│ 40: container_definitions = jsonencode([
│ 41: {
│ 42: "name": "${var.prefix}",
│ 43: "image": "${var.app_image}",
│ 44: "cpu": "256",
│ 45: "memory": "${var.fargate_memory}",
│ 46: "networkMode": "awsvpc",
│ 47: "logConfiguration": {
│ 48: "logDriver": "awslogs",
│ 49: "options": {
│ 50: "awslogs-group": "${aws_cloudwatch_log_group.ecs.name}",
│ 51: "awslogs-region": "${var.region}",
│ 52: "awslogs-stream-prefix": "ecs"
│ 53: }
│ 54: },
│ 55: "environment": [
│ 56: {"name": "ENV_RUNNER_SLEEP_SECS", "value": "${var.app_env_runner_sleep_secs}"}
│ 57: ]
│ 58: }
│ 59: ])
The error is pointing to the value for CPU. This would normally be another variable but I'm just testing out inputs to try and get it to pass. Annoyingly enough, if I set the value to a number, I get a different error: cannot unmarshal number into Go struct field KeyValuePair.Environment.Value of type string.
Any ideas?