Skip to content

Commit 6d83cb9

Browse files
piradeepkrix0rrr
authored andcommitted
fix(ecs-patterns): expose service on queue worker services (#2780)
1 parent a610017 commit 6d83cb9

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

packages/@aws-cdk/aws-ecs-patterns/lib/base/queue-worker-service-base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sqs = require('@aws-cdk/aws-sqs');
44
import cdk = require('@aws-cdk/cdk');
55

66
/**
7-
* Properties to define a Query Worker service
7+
* Properties to define a queue worker service
88
*/
99
export interface QueueWorkerServiceBaseProps {
1010
/**

packages/@aws-cdk/aws-ecs-patterns/lib/ecs/ecs-queue-worker-service.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cdk = require('@aws-cdk/cdk');
33
import { QueueWorkerServiceBase, QueueWorkerServiceBaseProps } from '../base/queue-worker-service-base';
44

55
/**
6-
* Properties to define an Ec2 query worker service
6+
* Properties to define an Ec2 queue worker service
77
*/
88
export interface Ec2QueueWorkerServiceProps extends QueueWorkerServiceBaseProps {
99
/**
@@ -41,9 +41,15 @@ export interface Ec2QueueWorkerServiceProps extends QueueWorkerServiceBaseProps
4141
}
4242

4343
/**
44-
* Class to create an Ec2 query worker service
44+
* Class to create an Ec2 queue worker service
4545
*/
4646
export class Ec2QueueWorkerService extends QueueWorkerServiceBase {
47+
48+
/**
49+
* The ECS service in this construct
50+
*/
51+
public readonly service: ecs.Ec2Service;
52+
4753
constructor(scope: cdk.Construct, id: string, props: Ec2QueueWorkerServiceProps) {
4854
super(scope, id, props);
4955

@@ -61,11 +67,11 @@ export class Ec2QueueWorkerService extends QueueWorkerServiceBase {
6167

6268
// Create an ECS service with the previously defined Task Definition and configure
6369
// autoscaling based on cpu utilization and number of messages visible in the SQS queue.
64-
const ecsService = new ecs.Ec2Service(this, 'QueueWorkerService', {
70+
this.service = new ecs.Ec2Service(this, 'QueueWorkerService', {
6571
cluster: props.cluster,
6672
desiredCount: this.desiredCount,
6773
taskDefinition
6874
});
69-
this.configureAutoscalingForService(ecsService);
75+
this.configureAutoscalingForService(this.service);
7076
}
7177
}

packages/@aws-cdk/aws-ecs-patterns/lib/fargate/fargate-queue-worker-service.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ export interface FargateQueueWorkerServiceProps extends QueueWorkerServiceBasePr
4545
}
4646

4747
/**
48-
* Class to create a Fargate query worker service
48+
* Class to create a Fargate queue worker service
4949
*/
5050
export class FargateQueueWorkerService extends QueueWorkerServiceBase {
51+
/**
52+
* The Fargate service in this construct
53+
*/
54+
public readonly service: ecs.FargateService;
55+
5156
constructor(scope: cdk.Construct, id: string, props: FargateQueueWorkerServiceProps) {
5257
super(scope, id, props);
5358

@@ -65,11 +70,11 @@ export class FargateQueueWorkerService extends QueueWorkerServiceBase {
6570

6671
// Create a Fargate service with the previously defined Task Definition and configure
6772
// autoscaling based on cpu utilization and number of messages visible in the SQS queue.
68-
const fargateService = new ecs.FargateService(this, 'FargateQueueWorkerService', {
73+
this.service = new ecs.FargateService(this, 'FargateQueueWorkerService', {
6974
cluster: props.cluster,
7075
desiredCount: this.desiredCount,
7176
taskDefinition
7277
});
73-
this.configureAutoscalingForService(fargateService);
78+
this.configureAutoscalingForService(this.service);
7479
}
7580
}

0 commit comments

Comments
 (0)