0
0
AWScloud~10 mins

ECS with ALB integration in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Amy-ecs-cluster
Becs-cluster-1
Cexample-cluster
Dcluster-ecs
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the name blank or using invalid characters.
Using a name that conflicts with existing resources.
2fill in blank
medium

Complete 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'
Anetwork
Bapplication
Cgateway
Dclassic
Attempts:
3 left
💡 Hint
Common Mistakes
Using "network" or "classic" instead of "application".
Leaving the load_balancer_type undefined.
3fill in blank
hard

Fix 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'
A22
B8080
C443
D80
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.
4fill in blank
hard

Fill 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'
A80
B443
CHTTP
DHTTPS
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing port 443 with HTTP protocol.
Using HTTPS protocol without proper certificates.
5fill in blank
hard

Fill 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'
Aarn
Bid
C80
Drevision
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.