If I create a task running on fargate with more than 1 container. Ignore the fact that each container should be split out in to its on task. e.g. terraform code:
resource "aws_ecs_task_definition" "citi" {
family = "myfamily"
execution_role_arn = data.aws_iam_role.this.arn
container_definitions = <<EOF
[
{
"name": "myapp1",
"image": "myapp1image",
"portMappings": [
{
"containerPort": 10001
}
]
},
{
"name": "myapp2",
"image": "myapp2image",
"portMappings": [
{
"containerPort": 10004
}
]
}
]
EOF
cpu = 512
memory = 1024
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
}
Note: not specifying cpu and memory in containers.
Short story: 1- it depends on the use case. If you want to optimize for simplicity you can avoid that and the two+ containers will fight for resources within the task. If you want to optimize for control you should configure that. 2- Yes (sort of). They are basically going to compete for all cpu/memory resources with even weights. 3- yes
Long story: https://aws.amazon.com/blogs/containers/how-amazon-ecs-manages-cpu-and-memory-resources/