Skip to content

ECS

CloudMock emulates Amazon ECS, supporting cluster, task definition, service, and task lifecycle management. Tasks and services are metadata records — no container runtime is involved.

OperationStatusNotes
CreateClusterSupportedCreates an ECS cluster
DeleteClusterSupportedDeletes a cluster
DescribeClustersSupportedReturns cluster details
ListClustersSupportedReturns all cluster ARNs
RegisterTaskDefinitionSupportedRegisters a task definition revision
DeregisterTaskDefinitionSupportedMarks a task definition as INACTIVE
DescribeTaskDefinitionSupportedReturns a task definition
ListTaskDefinitionsSupportedReturns all task definition ARNs
CreateServiceSupportedCreates a long-running service
DeleteServiceSupportedDeletes a service
DescribeServicesSupportedReturns service details
ListServicesSupportedReturns all service ARNs in a cluster
UpdateServiceSupportedUpdates desired count, task definition, etc.
RunTaskSupportedStarts one or more task instances
StopTaskSupportedStops a running task
DescribeTasksSupportedReturns task details
ListTasksSupportedReturns task ARNs in a cluster or service
TagResourceSupportedAdds tags
UntagResourceSupportedRemoves tags
ListTagsForResourceSupportedReturns tags for a resource
Terminal window
# Create a cluster
curl -X POST http://localhost:4566 \
-H "X-Amz-Target: AmazonEC2ContainerServiceV20141113.CreateCluster" \
-H "Content-Type: application/x-amz-json-1.1" \
-d '{"clusterName": "production"}'
# Register a task definition
curl -X POST http://localhost:4566 \
-H "X-Amz-Target: AmazonEC2ContainerServiceV20141113.RegisterTaskDefinition" \
-H "Content-Type: application/x-amz-json-1.1" \
-d '{"family": "web", "containerDefinitions": [{"name": "nginx", "image": "nginx:latest"}]}'
import { ECSClient, CreateClusterCommand, RegisterTaskDefinitionCommand, CreateServiceCommand } from '@aws-sdk/client-ecs';
const ecs = new ECSClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
await ecs.send(new CreateClusterCommand({ clusterName: 'dev' }));
await ecs.send(new RegisterTaskDefinitionCommand({
family: 'worker',
containerDefinitions: [{ name: 'app', image: 'myapp:latest', cpu: 256, memory: 512 }],
requiresCompatibilities: ['FARGATE'],
networkMode: 'awsvpc', cpu: '256', memory: '512',
}));
await ecs.send(new CreateServiceCommand({
cluster: 'dev', serviceName: 'workers',
taskDefinition: 'worker:1', desiredCount: 1, launchType: 'FARGATE',
}));
import boto3
ecs = boto3.client('ecs', endpoint_url='http://localhost:4566',
aws_access_key_id='test', aws_secret_access_key='test',
region_name='us-east-1')
ecs.create_cluster(clusterName='dev')
ecs.register_task_definition(
family='worker',
containerDefinitions=[{'name': 'app', 'image': 'myapp:latest', 'cpu': 256, 'memory': 512}],
requiresCompatibilities=['FARGATE'],
networkMode='awsvpc', cpu='256', memory='512',
)
ecs.create_service(
cluster='dev', serviceName='workers',
taskDefinition='worker:1', desiredCount=1, launchType='FARGATE',
)
response = ecs.describe_services(cluster='dev', services=['workers'])
svc = response['services'][0]
print(svc['status'], svc['runningCount'])
cloudmock.yml
services:
ecs:
enabled: true

No additional service-specific configuration is required.

  • Tasks and services are metadata records. No container runtime is involved.
  • RunTask returns a task record with status RUNNING immediately. No container is started.
  • Service auto-scaling and capacity providers are not implemented.
  • Container Insights and ECS Anywhere are not implemented.
  • Service Connect and service discovery integration are not implemented.
CodeHTTP StatusDescription
ClusterNotFoundException400The specified cluster does not exist
ServiceNotFoundException400The specified service does not exist
ServiceNotActiveException400The service is not active
InvalidParameterException400An input parameter is not valid