Skip to content

Commit

Permalink
Update design doc
Browse files Browse the repository at this point in the history
  • Loading branch information
piradeepk committed May 20, 2019
1 parent b3f424a commit 9e022bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions design/aws-ecs-autoscaling-queue-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,19 @@ export interface QueueWorkerServiceBaseProps {
/**
* The environment variables to pass to the container.
*
* @default none
* @default 'QUEUE_NAME: queue.queueName'
*/
readonly environment?: { [key: string]: string };

/**
* A name for the queue.
* A queue for which to process items from.
*
* If specified and this is a FIFO queue, must end in the string '.fifo'.
* If specified and this is a FIFO queue, the queue name must end in the string '.fifo'.
* @see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html
*
* @default CloudFormation-generated name
* @default 'SQSQueue with CloudFormation-generated name'
*/
readonly queueName?: string;
readonly queue?: IQueue;

/**
* Maximum capacity to scale to.
Expand Down Expand Up @@ -147,6 +148,9 @@ const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
});
const queue = new sqs.Queue(stack, 'WorkerQueue', {
QueueName: 'EcsWorkerQueue'
});

// Create the Queue Worker task
new Ec2QueueWorkerService(stack, 'EcsQueueWorkerService', {
Expand All @@ -156,7 +160,7 @@ new Ec2QueueWorkerService(stack, 'EcsQueueWorkerService', {
maxScalingCapacity: 5,
memoryReservationMiB: 512,
cpu: 256,
queueName: 'EcsWorkerQueue'
queue
});
```

Expand Down Expand Up @@ -213,13 +217,16 @@ An example use case:
// Create the vpc and cluster used by the Queue Worker task
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 2 });
const cluster = new ecs.Cluster(stack, 'FargateCluster', { vpc });
const queue = new sqs.Queue(stack, 'WorkerQueue', {
QueueName: 'FargateWorkerQueue'
});

// Create the Queue Worker task
new FargateQueueWorkerService(stack, 'FargateQueueWorkerService', {
cluster,
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
desiredTaskCount: 2,
maxScalingCapacity: 5,
queueName: 'FargateWorkerQueue'
queue
});
```
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/queue-worker-service-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface QueueWorkerServiceBaseProps {
/**
* A queue for which to process items from.
*
* If specified and this is a FIFO queue, must end in the string '.fifo'.
* If specified and this is a FIFO queue, the queue name must end in the string '.fifo'.
* @see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html
*
* @default 'SQSQueue with CloudFormation-generated name'
Expand Down

0 comments on commit 9e022bb

Please sign in to comment.