Skip to content

Commit 996e69d

Browse files
authored
feat(ecs-patterns): Add support for taskSubnets and securityGroups on QueueProcessingFagateService (#12604)
Fixes #12603 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5be09b9 commit 996e69d

9 files changed

+2235
-0
lines changed

packages/@aws-cdk/aws-ecs-patterns/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ const loadBalancedFargateService = new ApplicationLoadBalancedFargateService(sta
394394
});
395395
```
396396

397+
397398
### Set deployment configuration on QueueProcessingService
398399

399400
```ts
@@ -412,6 +413,18 @@ const queueProcessingFargateService = new QueueProcessingFargateService(stack, '
412413
});
413414
```
414415

416+
### Set taskSubnets and securityGroups on QueueProcessingFargateService
417+
418+
```ts
419+
const queueProcessingFargateService = new QueueProcessingFargateService(stack, 'Service', {
420+
vpc,
421+
memoryLimitMiB: 512,
422+
image: ecs.ContainerImage.fromRegistry('test'),
423+
securityGroups: [securityGroup],
424+
taskSubnets: { subnetType: ec2.SubnetType.ISOLATED },
425+
});
426+
```
427+
415428
### Select specific vpc subnets for ApplicationLoadBalancedFargateService
416429

417430
```ts

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as ec2 from '@aws-cdk/aws-ec2';
12
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
23
import { Construct } from 'constructs';
34
import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base';
@@ -66,6 +67,20 @@ export interface QueueProcessingFargateServiceProps extends QueueProcessingServi
6667
* @default - QueueProcessingContainer
6768
*/
6869
readonly containerName?: string;
70+
71+
/**
72+
* The subnets to associate with the service.
73+
*
74+
* @default - Public subnets if `assignPublicIp` is set, otherwise the first available one of Private, Isolated, Public, in that order.
75+
*/
76+
readonly taskSubnets?: ec2.SubnetSelection;
77+
78+
/**
79+
* The security groups to associate with the service. If you do not specify a security group, the default security group for the VPC is used.
80+
*
81+
* @default - A new security group is created.
82+
*/
83+
readonly securityGroups?: ec2.ISecurityGroup[];
6984
}
7085

7186
/**
@@ -117,6 +132,8 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
117132
enableECSManagedTags: props.enableECSManagedTags,
118133
platformVersion: props.platformVersion,
119134
deploymentController: props.deploymentController,
135+
securityGroups: props.securityGroups,
136+
vpcSubnets: props.taskSubnets,
120137
});
121138
this.configureAutoscalingForService(this.service);
122139
this.grantPermissionsToService(this.service);

0 commit comments

Comments
 (0)