Deploy and manage containerized applications on ECS/Fargate
Deploy containerized applications on ECS/Fargate with task definitions, services, and auto-scaling. Use when you need to launch or update container services, configure CPU/memory, set health checks, or manage deployments for production applications.
/plugin marketplace add pluginagentmarketplace/custom-plugin-aws/plugin install pluginagentmarketplace-aws-cloud-assistant@pluginagentmarketplace/custom-plugin-awsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonassets/task-definition.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyDeploy containerized applications with ECS and Fargate.
| Attribute | Value |
|---|---|
| AWS Service | ECS, Fargate |
| Complexity | Medium-High |
| Est. Time | 20-45 min |
| Prerequisites | VPC, ECR image, IAM roles |
| Parameter | Type | Description | Validation |
|---|---|---|---|
| cluster_name | string | ECS cluster name | ^[a-zA-Z0-9_-]{1,255}$ |
| service_name | string | Service name | ^[a-zA-Z0-9_-]{1,255}$ |
| image_uri | string | Container image | ECR or Docker Hub URI |
| cpu | int | CPU units | 256, 512, 1024, 2048, 4096 |
| memory | int | Memory MB | Valid for CPU |
| Parameter | Type | Default | Description |
|---|---|---|---|
| desired_count | int | 2 | Number of tasks |
| launch_type | string | FARGATE | FARGATE or EC2 |
| platform_version | string | LATEST | Fargate platform version |
| health_check_path | string | /health | ALB health check path |
| autoscaling | bool | true | Enable auto-scaling |
| CPU | Memory Options |
|---|---|
| 256 | 512, 1024, 2048 |
| 512 | 1024-4096 (1GB increments) |
| 1024 | 2048-8192 (1GB increments) |
| 2048 | 4096-16384 (1GB increments) |
| 4096 | 8192-30720 (1GB increments) |
{
"family": "my-app",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "512",
"memory": "1024",
"executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole",
"taskRoleArn": "arn:aws:iam::123456789012:role/ecsTaskRole",
"containerDefinitions": [
{
"name": "app",
"image": "123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest",
"portMappings": [
{"containerPort": 8080, "protocol": "tcp"}
],
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/my-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"healthCheck": {
"command": ["CMD-SHELL", "curl -f http://localhost:8080/health || exit 1"],
"interval": 30,
"timeout": 5,
"retries": 3,
"startPeriod": 60
},
"secrets": [
{
"name": "DB_PASSWORD",
"valueFrom": "arn:aws:secretsmanager:us-east-1:123456789012:secret:db-password"
}
]
}
]
}
aws ecs create-service \
--cluster prod-cluster \
--service-name my-service \
--task-definition my-app:1 \
--desired-count 2 \
--launch-type FARGATE \
--network-configuration '{
"awsvpcConfiguration": {
"subnets": ["subnet-111", "subnet-222"],
"securityGroups": ["sg-xxx"],
"assignPublicIp": "DISABLED"
}
}' \
--load-balancers '[{
"targetGroupArn": "arn:aws:elasticloadbalancing:...",
"containerName": "app",
"containerPort": 8080
}]' \
--deployment-configuration '{
"maximumPercent": 200,
"minimumHealthyPercent": 100,
"deploymentCircuitBreaker": {
"enable": true,
"rollback": true
}
}'
# Register scalable target
aws application-autoscaling register-scalable-target \
--service-namespace ecs \
--resource-id service/prod-cluster/my-service \
--scalable-dimension ecs:service:DesiredCount \
--min-capacity 2 \
--max-capacity 10
# Target tracking policy
aws application-autoscaling put-scaling-policy \
--service-namespace ecs \
--resource-id service/prod-cluster/my-service \
--scalable-dimension ecs:service:DesiredCount \
--policy-name cpu-tracking \
--policy-type TargetTrackingScaling \
--target-tracking-scaling-policy-configuration '{
"TargetValue": 70.0,
"PredefinedMetricSpecification": {
"PredefinedMetricType": "ECSServiceAverageCPUUtilization"
},
"ScaleInCooldown": 300,
"ScaleOutCooldown": 60
}'
| Symptom | Cause | Solution |
|---|---|---|
| Task won't start | Image pull failed | Check ECR permissions |
| Task unhealthy | Health check failing | Increase startPeriod |
| Service stuck | Deployment circuit breaker | Check task logs |
| OOM killed | Memory exceeded | Increase memory |
# Get stopped task details
aws ecs describe-tasks \
--cluster prod-cluster \
--tasks arn:aws:ecs:...:task/xxx \
--query 'tasks[0].{status:lastStatus,reason:stoppedReason,containers:containers[*].{name:name,reason:reason}}'
CannotPullContainerError → ECR image or permissions
ResourceInitializationError → Secrets/ENI issue
EssentialContainerExited → Application crash
OutOfMemoryError → Increase memory
HealthCheckFailure → Fix health check
def test_ecs_service_healthy():
# Arrange
cluster = "prod-cluster"
service = "my-service"
# Act
response = ecs.describe_services(
cluster=cluster,
services=[service]
)
# Assert
service_info = response['services'][0]
assert service_info['status'] == 'ACTIVE'
assert service_info['runningCount'] >= service_info['desiredCount']
assert len(service_info['deployments']) == 1 # No pending deployments
assets/task-definition.json - ECS task definition templateThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.