Create ECS task definitions
✓Works with OpenClaudeYou are an AWS ECS specialist. The user wants to create ECS task definitions programmatically using the AWS SDK or CloudFormation.
What to check first
- Run
aws ecs describe-task-definition --task-definition <name>to verify if a task definition already exists - Confirm IAM role ARN exists:
aws iam get-role --role-name ecsTaskExecutionRole - Verify container image URI is accessible:
aws ecr describe-images --repository-name <repo>
Steps
- Define the task execution role ARN (usually
arn:aws:iam::ACCOUNT:role/ecsTaskExecutionRole) — this grants ECS permissions to pull images and write logs - Create container definition object with
image,name,memory,cpu,portMappings, andlogConfigurationkeys - Set
logConfigurationto CloudWatch withawslogsdriver, specifyinglogGroup,logRegion, andlogStreamPrefix - Define environment variables in the
environmentarray withnameandvaluekey-value pairs - Configure port mappings with
containerPort,hostPort, andprotocol(tcp/udp) - Set
requiresCompatibilitiesto["FARGATE"]or["EC2"]based on launch type - Register the task definition using
register_task_definition()method withfamily,networkMode,requiresCompatibilities,cpu,memory, andcontainerDefinitions - Capture the returned
taskDefinitionArnfor use in ECS services
Code
import boto3
import json
ecs_client = boto3.client('ecs', region_name='us-east-1')
# Task execution role (pre-existing)
execution_role_arn = 'arn:aws:iam::123456789012:role/ecsTaskExecutionRole'
# Container definition
container_definition = {
'name': 'my-app',
'image': '123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest',
'memory': 512,
'cpu': 256,
'essential': True,
'portMappings': [
{
'containerPort': 8080,
'hostPort': 8080,
'protocol': 'tcp'
}
],
'logConfiguration': {
'logDriver': 'awslogs',
'options': {
'awslogs-group': '/ecs/my-app',
'awslogs-region': 'us-east-1',
'awslogs-stream-prefix': 'ecs'
}
},
'environment': [
{
'name': 'ENVIRONMENT',
'value': 'production'
},
{
'name': '
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Cloud (AWS/GCP/Azure) Skills
Other Claude Code skills in the same category — free to download.
Lambda Function
Create AWS Lambda function with handler
S3 Operations
Set up S3 bucket operations (upload, download, presigned URLs)
DynamoDB CRUD
Create DynamoDB CRUD operations
SQS Setup
Set up SQS queue producer and consumer
SNS Notifications
Configure SNS for push notifications
CloudFront Setup
Set up CloudFront CDN distribution
Cognito Auth
Implement AWS Cognito authentication
RDS Setup
Configure RDS database connection
Want a Cloud (AWS/GCP/Azure) skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.