-
-
Notifications
You must be signed in to change notification settings - Fork 614
Description
Description
(Is it a bug or a feature?)
I'm trying to use the container-definition module to set up a standalone ecs task that I'll trigger manually. However, the module outputs the json of the container definition without setting into an array that is expected as the input of container_definitions
of aws_ecs_task_definition
.
If the module is intended to be used only together with the service module, this should be highlighted in the docs.
Versions
- Module version [Required]:
6.0.6
Terraform v1.12.2
on linux_amd64
- provider registry.terraform.io/hashicorp/aws v6.4.0
Reproduction Code [Required]
module "ecs_container_definition" {
source = "terraform-aws-modules/ecs/aws//modules/container-definition"
version = "~> 6.0"
name = "test"
cpu = 512
memory = 256
essential = true
image = "hello-world:latest"
}
resource "aws_ecs_task_definition" "this" {
family = "test"
container_definitions = module.ecs_container_definition.container_definition_json
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
task_role_arn = aws_iam_role.task_access.arn
execution_role_arn = aws_iam_role.task_execution.arn
cpu = 512
memory = 256
}
Steps to reproduce the behavior:
Try to run the terraform code above and you get an error.
Expected behavior
It should work with aws_ecs_task_definition
.
Actual behavior
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: ECS Task Definition container_definitions is invalid: json: cannot unmarshal object into Go value of type []types.ContainerDefinition
│
│ with aws_ecs_task_definition.this,
│ on ecs-task.tf line 16, in resource "aws_ecs_task_definition" "this":
│ 16: container_definitions = module.ecs_container_definition.container_definition_json
│
Output from module.ecs_container_definition.container_definition_json
"{\"cpu\":256,\"entrypoint\":[],\"environment\":[],\"environmentFiles\":[],\"essential\":true,\"image\":\"hello-world:latest\",\"interactive\":false,\"linuxParameters\":{\"initProcessEnabled\":false},\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/aws/ecs/iam-auth-rds\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"memory\":512,\"mountPoints\":[],\"name\":\"iam-auth-rds\",\"privileged\":false,\"pseudoTerminal\":false,\"readonlyRootFilesystem\":true,\"restartPolicy\":{\"enabled\":true,\"ignoredExitCodes\":[]},\"startTimeout\":30,\"stopTimeout\":120,\"systemControls\":[],\"versionConsistency\":\"disabled\",\"volumesFrom\":[]}"
Since the output is not a list of containers, it is incompatible with the input of the resource.