AWS Scenarios
ECS Fargate with Application Load Balancer
module "ecs_cluster" {
source = "./modules/ecs-cluster"
name = "production"
capacity_providers = ["FARGATE", "FARGATE_SPOT"]
default_capacity_provider_strategy = [
{
capacity_provider = "FARGATE"
weight = 60
base = 1
},
{
capacity_provider = "FARGATE_SPOT"
weight = 40
}
]
container_insights = true
}
module "ecs_service" {
source = "./modules/ecs-service"
name = "api-service"
cluster_id = module.ecs_cluster.id
task_definition = {
cpu = 1024
memory = 2048
container_definitions = [
{
name = "api"
image = "${var.ecr_repository_url}:latest"
cpu = 512
memory = 1024
essential = true
portMappings = [
{
containerPort = 8080
protocol = "tcp"
}
]
environment = [
{
name = "ENV"
value = "production"
}
]
logConfiguration = {
logDriver = "awslogs"
options = {
awslogs-group = "/ecs/api-service"
awslogs-region = var.aws_region
awslogs-stream-prefix = "api"
}
}
}
]
}
networking = {
subnets = var.private_subnet_ids
security_groups = [aws_security_group.ecs_tasks.id]
assign_public_ip = false
}
load_balancer = {
target_group_arn = module.alb.target_group_arns[0]
container_name = "api"
container_port = 8080
}
auto_scaling = {
min_capacity = 2
max_capacity = 10
cpu_threshold = 75
memory_threshold = 75
}
enable_execute_command = true
}Multi-Account AWS Organization
Secure VPC with Transit Gateway
EKS Cluster with Node Groups
Aurora Serverless v2 Database
CloudFront with S3 Origin
Best Practices
1. Resource Tagging Strategy
2. IAM Role Strategy
3. Security Groups
Testing
Integration Tests with Terratest
Last updated