CDK Constructs for AWS ECS
Project description
CDK Construct library for higher-level ECS Constructs
This API is still under active development and subject to non-backward compatible changes or removal in any future version. Use of the API is not recommended in production environments. Experimental APIs are not subject to the Semantic Versioning model.
This library provides higher-level ECS constructs which follow common architectural patterns. It contains:
- Load Balanced Services
- Queue Worker Services
- Scheduled Tasks (cron jobs)
Load Balanced Services
To define a service that is behind a load balancer, instantiate one of the following:
LoadBalancedEc2Service
const loadBalancedEcsService = new ecsPatterns.LoadBalancedEc2Service(stack, 'Service', {
cluster,
memoryLimitMiB: 1024,
image: ecs.ContainerImage.fromRegistry('test'),
desiredCount: 2,
environment: {
TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value",
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
}
});
LoadBalancedFargateService
const loadBalancedFargateService = new ecsPatterns.LoadBalancedFargateService(stack, 'Service', {
cluster,
memoryMiB: '1GB',
cpu: '512',
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
});
Queue Worker Services
To define a service that creates a queue and reads from that queue, instantiate one of the following:
Ec2QueueWorkerService
const ecsQueueWorkerService = new Ec2QueueWorkerService(stack, 'Service', {
cluster,
memoryLimitMiB: 1024,
image: ecs.ContainerImage.fromRegistry('test'),
command: ["-c", "4", "amazon.com"],
enableLogging: false,
desiredTaskCount: 2,
environment: {
TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value",
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
},
queue,
maxScalingCapacity: 5
});
FargateQueueWorkerService
const fargateQueueWorkerService = new FargateQueueWorkerService(stack, 'Service', {
cluster,
memoryMiB: '512',
image: ecs.ContainerImage.fromRegistry('test'),
command: ["-c", "4", "amazon.com"],
enableLogging: false,
desiredTaskCount: 2,
environment: {
TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value",
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value"
},
queue,
maxScalingCapacity: 5
});
Scheduled Tasks
To define a task that runs periodically, instantiate an ScheduledEc2Task
:
// Instantiate an Amazon EC2 Task to run at a scheduled interval
const ecsScheduledTask = new ScheduledEc2Task(this, 'ScheduledTask', {
cluster,
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
scheduleExpression: 'rate(1 minute)',
environment: [{ name: 'TRIGGER', value: 'CloudWatch Events' }],
memoryLimitMiB: 256
});
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-ecs-patterns-0.34.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3884b3fc8afb52eb30908a12c56e1090853ddfb53e6673daffa8ae53b05a9dde |
|
MD5 | 85fe315138ea080b67fa860825e62d0f |
|
BLAKE2b-256 | a116ed3721acdfd0fb8465bb4564b47964a8e96a46b24b8116edabdc6ee466a2 |
Hashes for aws_cdk.aws_ecs_patterns-0.34.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06ae6644b9002e7943479e5b5541ea05cdde3d42630f12c84339d43717fff97d |
|
MD5 | 385118f3dbbabdfda566e1af6d712b9c |
|
BLAKE2b-256 | 22a07fb866af314f5a351b3deddc6b9ed67941e58e834e31e89a8fc68420c1e4 |