From dad54a406384b7e06243c79fe130e0971e422610 Mon Sep 17 00:00:00 2001 From: Austin Ely Date: Fri, 21 Jul 2023 14:44:49 -0400 Subject: [PATCH] fix(ecs): deployment alarm configurations are being added in isolated partitions (#26458) Fixes #26456. Renames the isolated partitions to their correct names. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-ecs/lib/base/base-service.ts | 2 +- .../aws-ecs/test/ec2/ec2-service.test.ts | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts b/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts index 05a0054491554..7eaaccbb86b01 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts @@ -1367,7 +1367,7 @@ export abstract class BaseService extends Resource } private deploymentAlarmsAvailableInRegion(): boolean { - const unsupportedPartitions = ['aws-cn', 'aws-us-gov', 'aws-us-iso', 'aws-us-iso-b']; + const unsupportedPartitions = ['aws-cn', 'aws-us-gov', 'aws-iso', 'aws-iso-b']; const currentRegion = RegionInfo.get(this.stack.resolve(this.stack.region)); if (currentRegion.partition) { return !unsupportedPartitions.includes(currentRegion.partition); diff --git a/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts b/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts index 8da11d24bae4e..a07841af5d75f 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts @@ -2365,6 +2365,32 @@ describe('ec2 service', () => { }); }); + test('no deployment alarms in isolated partitions', () => { + const app = new cdk.App(); + const govCloudStack = new cdk.Stack(app, 'IsoStack', { + env: { region: 'us-isob-east-1' }, + }); + const vpc = new ec2.Vpc(govCloudStack, 'MyVpc', {}); + const gcCluster = new ecs.Cluster(govCloudStack, 'EcsCluster', { vpc }); + addDefaultCapacityProvider(gcCluster, govCloudStack, vpc); + const gcTaskDefinition = new ecs.Ec2TaskDefinition(govCloudStack, 'Ec2TaskDef'); + + gcTaskDefinition.addContainer('web', { + image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), + memoryLimitMiB: 512, + }); + new ecs.Ec2Service(govCloudStack, 'Ec2Service', { + cluster: gcCluster, + taskDefinition: gcTaskDefinition, + }); + + Template.fromStack(govCloudStack).hasResourceProperties('AWS::ECS::Service', { + DeploymentConfiguration: { + Alarms: Match.absent(), + }, + }); + }); + /** * This section of tests test all combinations of the following possible * alarm names and metrics. Most combinations work just fine, some