0.9.6
[
{
"name": "kafka",
"image": "mydockerrepo/kafka:${kafka_version}",
"memory": 1024,
"cpu": 256,
"essential": true,
"portMappings": [
{
"containerPort": ${kafka_port},
"hostPort": ${kafka_port}
}
],
"environment": [
{"name": "ZK", "value": "${zk_elb_fqdn}:2181"},
{"name": "KAFKA_ADV_PORT", "value": "${kafka_port}"},
{"name": "AUTO_CREATE_TOPICS", "value": true}
]
}
]
data "template_file" "kafka" {
template = "${file("${path.module}/containers/kafka.json.tpl")}"
vars {
kafka_port = "${var.kafkaport}"
kafka_version = "${var.kafkaversion}"
zk_elb_fqdn = "${var.zk_elb_fqdn}"
}
}
resource "aws_ecs_task_definition" "kafka" {
family = "kafka"
container_definitions = "${data.template_file.kafka.rendered}"
}
resource "aws_ecs_service" "kafka" {
name = "kafka"
cluster = "${var.ecs_cluster}"
task_definition = "${aws_ecs_task_definition.kafka.arn}"
desired_count = 1
iam_role = "${var.iam_role}"
deployment_maximum_percent = 100
deployment_minimum_healthy_percent = 50
load_balancer {
elb_name = "${var.kafka_elb_arn}"
container_name = "kafka"
container_port = "${var.kafkaport}"
}
}
md5-ea3c3d0aee24d820e983620adf7d6f8f
Error running plan: 1 error(s) occurred:
* aws_ecs_task_definition.kafka: ECS Task Definition container_definitions is invalid: Error decoding JSON: json: cannot unmarshal bool into Go struct field KeyValuePair.Value of type string
md5-f000ac37253e82a3fd14e643e9726e38
Error running plan: 1 error(s) occurred:
* aws_ecs_service.kafka: 1 error(s) occurred:
* aws_ecs_service.kafka: Resource 'aws_ecs_task_definition.kafka' not found for variable 'aws_ecs_task_definition.kafka.arn'
Using the provided configuration, run terraform plan/apply
I'm seeing the same bug in Terraform v0.9.9. I basically have the same setup where i have a variable used to configure containerPort and I get the same exact error.
Getting the same here, with or without variables.
Can also duplicate, on v0.9.10. The underlying error can be seen by removing the resource "aws_ecs_service" from the terraform files completely. In my case it's:
* module.klaxon.aws_ecs_task_definition.klaxon_defn: ECS Task Definition container_definitions is invalid: Error decoding JSON: json: cannot unmarshal object into Go value of type []*ecs.ContainerDefinition
With the service resource present all I get is:
* module.klaxon.aws_ecs_service.klaxon_svc: 1 error(s) occurred:
* module.klaxon.aws_ecs_service.klaxon_svc: Resource 'aws_ecs_task_definition.klaxon_defn' not found for variable 'aws_ecs_task_definition.klaxon_defn.arn'
(FYI, if you have the same error as me and can't figure out the issue in your JSON template: container_definitions expects an array, not an object.)
Can confirm this is happening on 0.9.11.
Further on this:
2017/08/01 17:24:58 [TRACE] [walkPlan] Exiting eval tree: aws_ecs_task_definition.thingB
2017/08/01 17:24:58 [DEBUG] root: eval: *terraform.EvalSequence
2017/08/01 17:24:58 [DEBUG] root: eval: *terraform.EvalInterpolate
2017/08/01 17:24:58 [DEBUG] dag/walk: walking "aws_ecs_service.thingB"
2017/08/01 17:24:58 [DEBUG] vertex 'root.aws_ecs_service.thingB': walking
2017/08/01 17:24:58 [DEBUG] vertex 'root.aws_ecs_service.thingB': evaluating
2017/08/01 17:24:58 [TRACE] [walkPlan] Entering eval tree: aws_ecs_service.thingB
2017/08/01 17:24:58 [DEBUG] root: eval: *terraform.EvalGetProvider
2017/08/01 17:24:58 [DEBUG] root: eval: *terraform.EvalValidateResource
2017/08/01 17:24:58 [ERROR] root: eval: *terraform.EvalValidateResource, err: Warnings: []. Errors: [ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character '"' after object key:value pair]
2017/08/01 17:24:58 [ERROR] root: eval: *terraform.EvalSequence, err: Warnings: []. Errors: [ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character '"' after object key:value pair]
2017/08/01 17:24:58 [TRACE] [walkPlan] Exiting eval tree: aws_ecs_task_definition.thingA
2017/08/01 17:24:58 [DEBUG] dag/walk: walking "aws_ecs_service.thingA"
2017/08/01 17:24:58 [DEBUG] vertex 'root.aws_ecs_service.thingA': walking
2017/08/01 17:24:58 [DEBUG] vertex 'root.aws_ecs_service.thingA': evaluating
2017/08/01 17:24:58 [TRACE] [walkPlan] Entering eval tree: aws_ecs_service.thingA
2017/08/01 17:24:58 [DEBUG] root.alb: eval: *terraform.EvalOpFilter
2017/08/01 17:24:58 [DEBUG] root.alb: eval: *terraform.EvalSequence
2017/08/01 17:24:58 [DEBUG] root.alb: eval: *terraform.EvalWriteOutput
2017/08/01 17:24:58 [TRACE] [walkPlan] Exiting eval tree: module.alb.output.listerner_rule_arn
The error seems to be detected but skipped, I tried going through the code but TBH I fail to see why this does not trigger an error and a bad network_mode does.
Both seem to just run a validator to validate the content.
This issue has been automatically migrated to terraform-providers/terraform-provider-aws#1644 because it looks like an issue with that provider. If you believe this is _not_ an issue with the provider, please reply to this issue and let us know.
Here is a structure that passed for me. Just adapt it
{
"name": "sonarqube",
"image": "sonarqube:7.5-community",
"memory": "2048",
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${log-group}",
"awslogs-region": "${region}",
"awslogs-stream-prefix": "ecs"
}
},
"portMappings": {
"hostPort": "9000",
"protocol": "tcp",
"containerPort": "9000"
},
"environment": [
{
"name": "sonar.jdbc.password",
"value": "${password}"
},
{
"name": "sonar.jdbc.url",
"value": "${url}/${extra_url}"
},
{
"name": "sonar.jdbc.username",
"value": "${username}"
}
]
}
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Can also duplicate, on
v0.9.10. The underlying error can be seen by removing theresource "aws_ecs_service"from the terraform files completely. In my case it's:With the service resource present all I get is:
(FYI, if you have the same error as me and can't figure out the issue in your JSON template:
container_definitionsexpects an array, not an object.)