AWS ECS Fargate (us-west-1)

ECS Service

cs6650-rabbitmq

  • desired_count = 1
  • launch_type = FARGATE
  • Subnets: both us-west-1 subnets
  • Security group: cs6650-services-sg
  • assign_public_ip = true
  • Linked to Cloud Map service

AWS Cloud Map

Namespace: cs6650.local
Service: rabbitmq

When ECS task starts:
→ auto-registers container IP
rabbitmq.cs6650.local resolves to that IP

When ECS task stops:
→ auto-deregisters
→ DNS updated automatically

Security Group: cs6650-services-sg

Inbound rules:

  • All TCP from cs6650-alb-sg (ALB)
  • All TCP from cs6650-services-sg (internal)

→ Cart & Warehouse can reach RabbitMQ
→ Port 5672 NOT exposed to internet

ECS Task Definition

cs6650-rabbitmq

  • Image: rabbitmq:3-management
  • CPU: 512 / Memory: 1024 MB
  • Port 5672 (AMQP)
  • Port 15672 (Management UI)
  • Env: RABBITMQ_DEFAULT_USER / PASS
  • Logs → /ecs/cs6650 (CloudWatch)

Docker Image

rabbitmq:3-management

Pulled directly from Docker Hub.
No need to push to ECR — official image.

Terraform

terraform apply

Creates all AWS resources:

  • ECS task definition (rabbitmq:3-management)
  • ECS service
  • Cloud Map namespace cs6650.local
  • Cloud Map service rabbitmq
  • Security group rules
  • CloudWatch log group /ecs/cs6650

RabbitMQ Container

Running inside ECS Fargate

  • Private IP: 172.31.x.x (changes on restart)
  • AMQP port 5672 → used by Cart & Warehouse
  • UI port 15672 → access via private IP directly

Queue: order_queue

  • durable = true
  • persistent messages

CloudWatch Logs

Log group: /ecs/cs6650
Stream prefix: rabbitmq

aws logs tail /ecs/cs6650 \
  --log-stream-name-prefix rabbitmq

Warehouse Consumer

Connects to:
rabbitmq.cs6650.local:5672

→ 10 threads
→ each thread owns one Channel
→ basicConsume on order_queue

Shopping Cart

Connects to:
rabbitmq.cs6650.local:5672

→ Cloud Map resolves DNS
→ TCP connection established
→ Channel Pool created (size=20)