Skip to content

Commit

Permalink
feat(ecs-patterns): Add support for taskSubnets and securityGroups on…
Browse files Browse the repository at this point in the history
… 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*
  • Loading branch information
lgvo authored Feb 17, 2021
1 parent 5be09b9 commit 996e69d
Show file tree
Hide file tree
Showing 9 changed files with 2,235 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-ecs-patterns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ const loadBalancedFargateService = new ApplicationLoadBalancedFargateService(sta
});
```


### Set deployment configuration on QueueProcessingService

```ts
Expand All @@ -412,6 +413,18 @@ const queueProcessingFargateService = new QueueProcessingFargateService(stack, '
});
```

### Set taskSubnets and securityGroups on QueueProcessingFargateService

```ts
const queueProcessingFargateService = new QueueProcessingFargateService(stack, 'Service', {
vpc,
memoryLimitMiB: 512,
image: ecs.ContainerImage.fromRegistry('test'),
securityGroups: [securityGroup],
taskSubnets: { subnetType: ec2.SubnetType.ISOLATED },
});
```

### Select specific vpc subnets for ApplicationLoadBalancedFargateService

```ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
import { Construct } from 'constructs';
import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base';
Expand Down Expand Up @@ -66,6 +67,20 @@ export interface QueueProcessingFargateServiceProps extends QueueProcessingServi
* @default - QueueProcessingContainer
*/
readonly containerName?: string;

/**
* The subnets to associate with the service.
*
* @default - Public subnets if `assignPublicIp` is set, otherwise the first available one of Private, Isolated, Public, in that order.
*/
readonly taskSubnets?: ec2.SubnetSelection;

/**
* 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.
*
* @default - A new security group is created.
*/
readonly securityGroups?: ec2.ISecurityGroup[];
}

/**
Expand Down Expand Up @@ -117,6 +132,8 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
enableECSManagedTags: props.enableECSManagedTags,
platformVersion: props.platformVersion,
deploymentController: props.deploymentController,
securityGroups: props.securityGroups,
vpcSubnets: props.taskSubnets,
});
this.configureAutoscalingForService(this.service);
this.grantPermissionsToService(this.service);
Expand Down
Loading

0 comments on commit 996e69d

Please sign in to comment.