Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define an ECS cluster.
AWS
resource "aws_ecs_cluster" "example" { name = "[1]" }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the name blank or using invalid characters.
Using a name that conflicts with existing resources.
✗ Incorrect
The ECS cluster name is set to "example-cluster" to identify the cluster.
2fill in blank
mediumComplete the code to create an Application Load Balancer (ALB).
AWS
resource "aws_lb" "app_alb" { name = "app-alb" internal = false load_balancer_type = "[1]" subnets = var.subnet_ids }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using "network" or "classic" instead of "application".
Leaving the load_balancer_type undefined.
✗ Incorrect
The ALB type must be set to "application" for ECS integration.
3fill in blank
hardFix the error in the ECS task definition to specify the container port mapping.
AWS
container_definitions = jsonencode([
{
"name": "web",
"image": "nginx",
"portMappings": [
{
"containerPort": [1],
"hostPort": 0,
"protocol": "tcp"
}
]
}
]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 22 which is for SSH, not web traffic.
Using port 443 which is for HTTPS but nginx defaults to 80.
✗ Incorrect
The container port for a web server like nginx is typically 80.
4fill in blank
hardFill both blanks to define a listener and target group for the ALB.
AWS
resource "aws_lb_target_group" "app_tg" { name = "app-tg" port = [1] protocol = "[2]" vpc_id = var.vpc_id }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing port 443 with HTTP protocol.
Using HTTPS protocol without proper certificates.
✗ Incorrect
The target group listens on port 80 using HTTP protocol for typical web traffic.
5fill in blank
hardFill all three blanks to configure the ECS service with ALB integration.
AWS
resource "aws_ecs_service" "app_service" { name = "app-service" cluster = aws_ecs_cluster.example.id task_definition = aws_ecs_task_definition.app_task.[1] desired_count = 2 launch_type = "FARGATE" network_configuration { subnets = var.subnet_ids security_groups = [aws_security_group.app_sg.id] assign_public_ip = true } load_balancer { target_group_arn = aws_lb_target_group.app_tg.[2] container_name = "web" container_port = [3] } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using task definition ARN instead of revision.
Using target group ID instead of ARN.
Setting container port to wrong value.
✗ Incorrect
The ECS service requires the task definition revision, the target group ARN, and the container port 80 for ALB integration.