From 35c2a159829143215b2b0c2ae4e4a4daa905918c Mon Sep 17 00:00:00 2001 From: Nicholas Geil Date: Thu, 31 Aug 2023 11:59:17 -0400 Subject: [PATCH 1/8] Introduce ignoreAlarmConfiguration parameter to aws-codedeploy deployment groups The alarms on a CodeDeploy group are configurable to be enabled or disabled through the SDK or UI. Bringing in that functionality to the CDK to have parity. --- packages/aws-cdk-lib/aws-codedeploy/README.md | 3 ++ .../lib/ecs/deployment-group.ts | 14 ++++++++- .../lib/lambda/deployment-group.ts | 13 ++++++++- .../aws-codedeploy/lib/private/utils.ts | 12 +++++--- .../lib/server/deployment-group.ts | 13 ++++++++- .../test/ecs/deployment-group.test.ts | 29 +++++++++++++++++++ .../test/lambda/deployment-group.test.ts | 25 ++++++++++++++++ .../test/server/deployment-group.test.ts | 24 +++++++++++++++ 8 files changed, 126 insertions(+), 7 deletions(-) diff --git a/packages/aws-cdk-lib/aws-codedeploy/README.md b/packages/aws-cdk-lib/aws-codedeploy/README.md index caeeb2ec8184f..adf0b5d71cc7d 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/README.md +++ b/packages/aws-cdk-lib/aws-codedeploy/README.md @@ -90,6 +90,9 @@ const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'CodeDeployDe // whether to ignore failure to fetch the status of alarms from CloudWatch // default: false ignorePollAlarmsFailure: false, + // whether to skip the step of checking CloudWatch alarms during the deployment process + // default: false + ignoreAlarmConfiguration: false, // auto-rollback configuration autoRollback: { failedDeployment: true, // default: true diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts index 3b1f29cd525b3..597228d0c9f55 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts @@ -178,6 +178,13 @@ export interface EcsDeploymentGroupProps { * @default - default AutoRollbackConfig. */ readonly autoRollback?: AutoRollbackConfig; + + /** + * Whether to skip the step of checking CloudWatch alarms during the deployment process + * + * @default false + */ + readonly ignoreAlarmConfiguration?: boolean; } /** @@ -261,7 +268,12 @@ export class EcsDeploymentGroup extends DeploymentGroupBase implements IEcsDeplo }), loadBalancerInfo: cdk.Lazy.any({ produce: () => this.renderLoadBalancerInfo(props.blueGreenDeploymentConfig) }), alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfiguration(this.alarms, props.ignorePollAlarmsFailure, removeAlarmsFromDeploymentGroup), + produce: () => renderAlarmConfiguration( + this.alarms, + props.ignorePollAlarmsFailure, + removeAlarmsFromDeploymentGroup, + props.ignoreAlarmConfiguration, + ), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts index 6818f643f7ad3..b35eaf4f4fd92 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts @@ -117,6 +117,13 @@ export interface LambdaDeploymentGroupProps { * @default - default AutoRollbackConfig. */ readonly autoRollback?: AutoRollbackConfig; + + /** + * Whether to skip the step of checking CloudWatch alarms during the deployment process + * + * @default false + */ + readonly ignoreAlarmConfiguration?: boolean; } /** @@ -177,7 +184,11 @@ export class LambdaDeploymentGroup extends DeploymentGroupBase implements ILambd deploymentOption: 'WITH_TRAFFIC_CONTROL', }, alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfiguration(this.alarms, props.ignorePollAlarmsFailure, removeAlarmsFromDeploymentGroup), + produce: () => renderAlarmConfiguration( + this.alarms, props.ignorePollAlarmsFailure, + removeAlarmsFromDeploymentGroup, + props.ignoreAlarmConfiguration, + ), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index f424f5775d506..dc98e4b7c4cd9 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -31,12 +31,16 @@ export function arnForDeploymentConfig(name: string, resource?: IResource): stri }); } -export function renderAlarmConfiguration(alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure: boolean | undefined, removeAlarms = true): -CfnDeploymentGroup.AlarmConfigurationProperty | undefined { +export function renderAlarmConfiguration( + alarms: cloudwatch.IAlarm[], + ignorePollAlarmFailure: boolean | undefined, + removeAlarms = true, + ignoreAlarmConfiguration: boolean = false, +): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { if (removeAlarms) { return { alarms: alarms.length > 0 ? alarms.map(a => ({ name: a.alarmName })) : undefined, - enabled: alarms.length > 0, + enabled: !ignoreAlarmConfiguration && alarms.length > 0, ignorePollAlarmFailure, }; } @@ -45,7 +49,7 @@ CfnDeploymentGroup.AlarmConfigurationProperty | undefined { ? undefined : { alarms: alarms.map(a => ({ name: a.alarmName })), - enabled: true, + enabled: !ignoreAlarmConfiguration, ignorePollAlarmFailure, }; } diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts index b973cd81beeb4..3055d7edc5698 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts @@ -210,6 +210,13 @@ export interface ServerDeploymentGroupProps { * @default - default AutoRollbackConfig. */ readonly autoRollback?: AutoRollbackConfig; + + /** + * Whether to skip the step of checking CloudWatch alarms during the deployment process + * + * @default false + */ + readonly ignoreAlarmConfiguration?: boolean; } /** @@ -286,7 +293,11 @@ export class ServerDeploymentGroup extends DeploymentGroupBase implements IServe ec2TagSet: this.ec2TagSet(props.ec2InstanceTags), onPremisesTagSet: this.onPremiseTagSet(props.onPremiseInstanceTags), alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfiguration(this.alarms, props.ignorePollAlarmsFailure, removeAlarmsFromDeploymentGroup), + produce: () => renderAlarmConfiguration( + this.alarms, props.ignorePollAlarmsFailure, + removeAlarmsFromDeploymentGroup, + props.ignoreAlarmConfiguration, + ), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts b/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts index dc8a4539b4c7e..5aa12881aea06 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts @@ -884,4 +884,33 @@ describe('CodeDeploy ECS DeploymentGroup', () => { )); }); }); + + test('can ignore alarm status when alarms are present', () => { + const stack = new cdk.Stack(); + new codedeploy.EcsDeploymentGroup(stack, 'MyDG', { + ignoreAlarmConfiguration: true, + alarms: [ + new cloudwatch.Alarm(stack, 'BlueTGUnHealthyHosts', { + metric: new cloudwatch.Metric({ + namespace: 'AWS/ApplicationELB', + metricName: 'UnHealthyHostCount', + }), + threshold: 1, + evaluationPeriods: 1, + }), + ], + service: mockEcsService(stack), + blueGreenDeploymentConfig: { + blueTargetGroup: mockTargetGroup(stack, 'blue'), + greenTargetGroup: mockTargetGroup(stack, 'green'), + listener: mockListener(stack, 'prod'), + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeDeploy::DeploymentGroup', { + AlarmConfiguration: { + Enabled: false, + }, + }); + }); }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts b/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts index 6d59bbdd6cb45..885ce7a04ce0d 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts @@ -652,6 +652,31 @@ describe('CodeDeploy Lambda DeploymentGroup', () => { )); }); }); + + test('can ignore alarm status when alarms are present', () => { + const stack = new cdk.Stack(); + const application = new codedeploy.LambdaApplication(stack, 'MyApp'); + const alias = mockAlias(stack); + new codedeploy.LambdaDeploymentGroup(stack, 'MyDG', { + application, + alias, + postHook: mockFunction(stack, 'PostHook'), + deploymentConfig: codedeploy.LambdaDeploymentConfig.ALL_AT_ONCE, + ignoreAlarmConfiguration: true, + alarms: [new cloudwatch.Alarm(stack, 'Failures', { + metric: alias.metricErrors(), + comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD, + threshold: 1, + evaluationPeriods: 1, + })], + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeDeploy::DeploymentGroup', { + AlarmConfiguration: { + Enabled: false, + }, + }); + }); }); describe('imported with fromLambdaDeploymentGroupAttributes', () => { diff --git a/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts b/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts index 89c97c5003a73..a189bda4b3123 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts @@ -540,4 +540,28 @@ describe('CodeDeploy Server Deployment Group', () => { )); }); }); + + test('can ignore alarm status when alarms are present', () => { + const stack = new cdk.Stack(); + + new codedeploy.ServerDeploymentGroup(stack, 'DeploymentGroup', { + alarms: [ + new cloudwatch.Alarm(stack, 'Alarm1', { + metric: new cloudwatch.Metric({ + metricName: 'Errors', + namespace: 'my.namespace', + }), + threshold: 1, + evaluationPeriods: 1, + }), + ], + ignoreAlarmConfiguration: true, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeDeploy::DeploymentGroup', { + AlarmConfiguration: { + Enabled: false, + }, + }); + }); }); From 583afc61d76ed7da3a726d6d188fd7b11424bd12 Mon Sep 17 00:00:00 2001 From: Nicholas Geil Date: Wed, 13 Sep 2023 07:01:07 -0400 Subject: [PATCH 2/8] Update integration tests --- ...efaultTestDeployAssert60AABFA0.assets.json | 2 +- .../aws-cdk-codedeploy-ecs-dg.assets.json | 6 +- .../aws-cdk-codedeploy-ecs-dg.template.json | 158 ++--- .../cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 4 +- .../tree.json | 538 +++++++++--------- .../test/ecs/integ.deployment-group.ts | 1 + .../test/lambda/integ.deployment-group.ts | 1 + .../test/server/integ.deployment-group.ts | 1 + 10 files changed, 359 insertions(+), 356 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/EcsDeploymentGroupTestDefaultTestDeployAssert60AABFA0.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/EcsDeploymentGroupTestDefaultTestDeployAssert60AABFA0.assets.json index 450725bf2e337..a12cfbdbba5ba 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/EcsDeploymentGroupTestDefaultTestDeployAssert60AABFA0.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/EcsDeploymentGroupTestDefaultTestDeployAssert60AABFA0.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "34.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.assets.json index a0b1b02ba7950..3cf5ed0926e98 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.assets.json @@ -1,7 +1,7 @@ { - "version": "32.0.0", + "version": "34.0.0", "files": { - "54ea34edd18b9383781f88fd1ab5487b7d2a4ca076f0a365fa77e3b3a4b109d9": { + "710f6bc445077db08ceffaf64861f978b37344d19f910739818890c51a58f0d9": { "source": { "path": "aws-cdk-codedeploy-ecs-dg.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "54ea34edd18b9383781f88fd1ab5487b7d2a4ca076f0a365fa77e3b3a4b109d9.json", + "objectKey": "710f6bc445077db08ceffaf64861f978b37344d19f910739818890c51a58f0d9.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.template.json index 64f48e53ec831..59fc30d6fffd1 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/aws-cdk-codedeploy-ecs-dg.template.json @@ -18,9 +18,6 @@ "VPCPublicSubnet1SubnetB4246D30": { "Type": "AWS::EC2::Subnet", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "AvailabilityZone": { "Fn::Select": [ 0, @@ -44,21 +41,24 @@ "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet1" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPublicSubnet1RouteTableFEE4B781": { "Type": "AWS::EC2::RouteTable", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "Tags": [ { "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet1" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPublicSubnet1RouteTableAssociation0B0896DC": { @@ -75,12 +75,12 @@ "VPCPublicSubnet1DefaultRoute91CEF279": { "Type": "AWS::EC2::Route", "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet1RouteTableFEE4B781" - }, "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": { "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" } }, "DependsOn": [ @@ -102,15 +102,15 @@ "VPCPublicSubnet1NATGatewayE0556630": { "Type": "AWS::EC2::NatGateway", "Properties": { - "SubnetId": { - "Ref": "VPCPublicSubnet1SubnetB4246D30" - }, "AllocationId": { "Fn::GetAtt": [ "VPCPublicSubnet1EIP6AD938E8", "AllocationId" ] }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, "Tags": [ { "Key": "Name", @@ -126,9 +126,6 @@ "VPCPublicSubnet2Subnet74179F39": { "Type": "AWS::EC2::Subnet", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "AvailabilityZone": { "Fn::Select": [ 1, @@ -152,21 +149,24 @@ "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet2" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPublicSubnet2RouteTable6F1A15F1": { "Type": "AWS::EC2::RouteTable", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "Tags": [ { "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet2" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPublicSubnet2RouteTableAssociation5A808732": { @@ -183,12 +183,12 @@ "VPCPublicSubnet2DefaultRouteB7481BBA": { "Type": "AWS::EC2::Route", "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" - }, "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": { "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" } }, "DependsOn": [ @@ -210,15 +210,15 @@ "VPCPublicSubnet2NATGateway3C070193": { "Type": "AWS::EC2::NatGateway", "Properties": { - "SubnetId": { - "Ref": "VPCPublicSubnet2Subnet74179F39" - }, "AllocationId": { "Fn::GetAtt": [ "VPCPublicSubnet2EIP4947BC00", "AllocationId" ] }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, "Tags": [ { "Key": "Name", @@ -234,9 +234,6 @@ "VPCPrivateSubnet1Subnet8BCA10E0": { "Type": "AWS::EC2::Subnet", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "AvailabilityZone": { "Fn::Select": [ 0, @@ -260,21 +257,24 @@ "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet1" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPrivateSubnet1RouteTableBE8A6027": { "Type": "AWS::EC2::RouteTable", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "Tags": [ { "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet1" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPrivateSubnet1RouteTableAssociation347902D1": { @@ -291,21 +291,18 @@ "VPCPrivateSubnet1DefaultRouteAE1D6490": { "Type": "AWS::EC2::Route", "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" - }, "DestinationCidrBlock": "0.0.0.0/0", "NatGatewayId": { "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" } } }, "VPCPrivateSubnet2SubnetCFCDAA7A": { "Type": "AWS::EC2::Subnet", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "AvailabilityZone": { "Fn::Select": [ 1, @@ -329,21 +326,24 @@ "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet2" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPrivateSubnet2RouteTable0A19E10E": { "Type": "AWS::EC2::RouteTable", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "Tags": [ { "Key": "Name", "Value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet2" } - ] + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "VPCPrivateSubnet2RouteTableAssociation0C73D413": { @@ -360,12 +360,12 @@ "VPCPrivateSubnet2DefaultRouteF4F5CFD2": { "Type": "AWS::EC2::Route", "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" - }, "DestinationCidrBlock": "0.0.0.0/0", "NatGatewayId": { "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" } } }, @@ -383,11 +383,11 @@ "VPCVPCGW99B986DC": { "Type": "AWS::EC2::VPCGatewayAttachment", "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, "InternetGatewayId": { "Ref": "VPCIGWB7E252D3" + }, + "VpcId": { + "Ref": "VPCB9E5F0B4" } } }, @@ -528,7 +528,6 @@ "FargateServiceSecurityGroupfromawscdkcodedeployecsdgServiceLBSecurityGroupEC967688803C3B1119": { "Type": "AWS::EC2::SecurityGroupIngress", "Properties": { - "IpProtocol": "tcp", "Description": "Load balancer to target", "FromPort": 80, "GroupId": { @@ -537,6 +536,7 @@ "GroupId" ] }, + "IpProtocol": "tcp", "SourceSecurityGroupId": { "Fn::GetAtt": [ "ServiceLBSecurityGroup2EA7EDA1", @@ -659,13 +659,6 @@ "ServiceLBSecurityGrouptoawscdkcodedeployecsdgFargateServiceSecurityGroup64C2B62E8071D2502F": { "Type": "AWS::EC2::SecurityGroupEgress", "Properties": { - "GroupId": { - "Fn::GetAtt": [ - "ServiceLBSecurityGroup2EA7EDA1", - "GroupId" - ] - }, - "IpProtocol": "tcp", "Description": "Load balancer to target", "DestinationSecurityGroupId": { "Fn::GetAtt": [ @@ -674,6 +667,13 @@ ] }, "FromPort": 80, + "GroupId": { + "Fn::GetAtt": [ + "ServiceLBSecurityGroup2EA7EDA1", + "GroupId" + ] + }, + "IpProtocol": "tcp", "ToPort": 80 } }, @@ -781,9 +781,8 @@ "BlueUnhealthyHosts48919A97": { "Type": "AWS::CloudWatch::Alarm", "Properties": { - "ComparisonOperator": "GreaterThanOrEqualToThreshold", - "EvaluationPeriods": 2, "AlarmName": "aws-cdk-codedeploy-ecs-dg-Unhealthy-Hosts-Blue", + "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "LoadBalancer", @@ -846,6 +845,7 @@ } } ], + "EvaluationPeriods": 2, "MetricName": "UnHealthyHostCount", "Namespace": "AWS/ApplicationELB", "Period": 300, @@ -856,9 +856,8 @@ "Blue5xx7E9798A6": { "Type": "AWS::CloudWatch::Alarm", "Properties": { - "ComparisonOperator": "GreaterThanOrEqualToThreshold", - "EvaluationPeriods": 1, "AlarmName": "aws-cdk-codedeploy-ecs-dg-Http-500-Blue", + "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "LoadBalancer", @@ -921,6 +920,7 @@ } } ], + "EvaluationPeriods": 1, "MetricName": "HTTPCode_Target_5XX_Count", "Namespace": "AWS/ApplicationELB", "Period": 60, @@ -931,9 +931,8 @@ "GreenUnhealthyHosts8D9D09C1": { "Type": "AWS::CloudWatch::Alarm", "Properties": { - "ComparisonOperator": "GreaterThanOrEqualToThreshold", - "EvaluationPeriods": 2, "AlarmName": "aws-cdk-codedeploy-ecs-dg-Unhealthy-Hosts-Green", + "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "LoadBalancer", @@ -996,6 +995,7 @@ } } ], + "EvaluationPeriods": 2, "MetricName": "UnHealthyHostCount", "Namespace": "AWS/ApplicationELB", "Period": 300, @@ -1006,9 +1006,8 @@ "Green5xx1A511A06": { "Type": "AWS::CloudWatch::Alarm", "Properties": { - "ComparisonOperator": "GreaterThanOrEqualToThreshold", - "EvaluationPeriods": 1, "AlarmName": "aws-cdk-codedeploy-ecs-dg-Http-500-Green", + "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "LoadBalancer", @@ -1071,6 +1070,7 @@ } } ], + "EvaluationPeriods": 1, "MetricName": "HTTPCode_Target_5XX_Count", "Namespace": "AWS/ApplicationELB", "Period": 60, @@ -1137,15 +1137,6 @@ "BlueGreenDG373AB9B0": { "Type": "AWS::CodeDeploy::DeploymentGroup", "Properties": { - "ApplicationName": { - "Ref": "BlueGreenDGApplication3649479D" - }, - "ServiceRoleArn": { - "Fn::GetAtt": [ - "BlueGreenDGServiceRole33E3BCAC", - "Arn" - ] - }, "AlarmConfiguration": { "Alarms": [ { @@ -1169,7 +1160,10 @@ } } ], - "Enabled": true + "Enabled": false + }, + "ApplicationName": { + "Ref": "BlueGreenDGApplication3649479D" }, "AutoRollbackConfiguration": { "Enabled": true, @@ -1246,6 +1240,12 @@ } } ] + }, + "ServiceRoleArn": { + "Fn::GetAtt": [ + "BlueGreenDGServiceRole33E3BCAC", + "Arn" + ] } }, "DependsOn": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/cdk.out index f0b901e7c06e5..2313ab5436501 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/integ.json index d10ac3bae19ec..543faf986acd9 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "34.0.0", "testCases": { "EcsDeploymentGroupTest/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/manifest.json index 2ac61ce54d5a8..7bdb333ff5afc 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "34.0.0", "artifacts": { "aws-cdk-codedeploy-ecs-dg.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/54ea34edd18b9383781f88fd1ab5487b7d2a4ca076f0a365fa77e3b3a4b109d9.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/710f6bc445077db08ceffaf64861f978b37344d19f910739818890c51a58f0d9.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/tree.json index b5cdc1e7eed0e..8f35257767a2c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.js.snapshot/tree.json @@ -31,8 +31,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" } }, "PublicSubnet1": { @@ -45,9 +45,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "availabilityZone": { "Fn::Select": [ 0, @@ -71,20 +68,23 @@ "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet1" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" } }, "Acl": { "id": "Acl", "path": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet1/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -93,20 +93,20 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "tags": [ { "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet1" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" } }, "RouteTableAssociation": { @@ -124,8 +124,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" } }, "DefaultRoute": { @@ -134,18 +134,18 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Route", "aws:cdk:cloudformation:props": { - "routeTableId": { - "Ref": "VPCPublicSubnet1RouteTableFEE4B781" - }, "destinationCidrBlock": "0.0.0.0/0", "gatewayId": { "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" } }, "EIP": { @@ -164,8 +164,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" } }, "NATGateway": { @@ -174,15 +174,15 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", "aws:cdk:cloudformation:props": { - "subnetId": { - "Ref": "VPCPublicSubnet1SubnetB4246D30" - }, "allocationId": { "Fn::GetAtt": [ "VPCPublicSubnet1EIP6AD938E8", "AllocationId" ] }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, "tags": [ { "key": "Name", @@ -192,14 +192,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" } }, "PublicSubnet2": { @@ -212,9 +212,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "availabilityZone": { "Fn::Select": [ 1, @@ -238,20 +235,23 @@ "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet2" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" } }, "Acl": { "id": "Acl", "path": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet2/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -260,20 +260,20 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "tags": [ { "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PublicSubnet2" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" } }, "RouteTableAssociation": { @@ -291,8 +291,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" } }, "DefaultRoute": { @@ -301,18 +301,18 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Route", "aws:cdk:cloudformation:props": { - "routeTableId": { - "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" - }, "destinationCidrBlock": "0.0.0.0/0", "gatewayId": { "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" } }, "EIP": { @@ -331,8 +331,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" } }, "NATGateway": { @@ -341,15 +341,15 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", "aws:cdk:cloudformation:props": { - "subnetId": { - "Ref": "VPCPublicSubnet2Subnet74179F39" - }, "allocationId": { "Fn::GetAtt": [ "VPCPublicSubnet2EIP4947BC00", "AllocationId" ] }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, "tags": [ { "key": "Name", @@ -359,14 +359,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" } }, "PrivateSubnet1": { @@ -379,9 +379,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "availabilityZone": { "Fn::Select": [ 0, @@ -405,20 +402,23 @@ "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet1" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" } }, "Acl": { "id": "Acl", "path": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet1/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -427,20 +427,20 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "tags": [ { "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet1" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" } }, "RouteTableAssociation": { @@ -458,8 +458,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" } }, "DefaultRoute": { @@ -468,24 +468,24 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Route", "aws:cdk:cloudformation:props": { - "routeTableId": { - "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" - }, "destinationCidrBlock": "0.0.0.0/0", "natGatewayId": { "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" } }, "PrivateSubnet2": { @@ -498,9 +498,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "availabilityZone": { "Fn::Select": [ 1, @@ -524,20 +521,23 @@ "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet2" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" } }, "Acl": { "id": "Acl", "path": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet2/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -546,20 +546,20 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "tags": [ { "key": "Name", "value": "aws-cdk-codedeploy-ecs-dg/VPC/PrivateSubnet2" } - ] + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" } }, "RouteTableAssociation": { @@ -577,8 +577,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" } }, "DefaultRoute": { @@ -587,24 +587,24 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::Route", "aws:cdk:cloudformation:props": { - "routeTableId": { - "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" - }, "destinationCidrBlock": "0.0.0.0/0", "natGatewayId": { "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" } }, "IGW": { @@ -622,8 +622,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" } }, "VPCGW": { @@ -632,23 +632,23 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", "aws:cdk:cloudformation:props": { - "vpcId": { - "Ref": "VPCB9E5F0B4" - }, "internetGatewayId": { "Ref": "VPCIGWB7E252D3" + }, + "vpcId": { + "Ref": "VPCB9E5F0B4" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" } }, "EcsCluster": { @@ -663,14 +663,14 @@ "aws:cdk:cloudformation:props": {} }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.CfnCluster", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.Cluster", + "version": "0.0.0" } }, "TaskDef": { @@ -685,8 +685,8 @@ "id": "ImportTaskRole", "path": "aws-cdk-codedeploy-ecs-dg/TaskDef/TaskRole/ImportTaskRole", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "Resource": { @@ -710,14 +710,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" } }, "Resource": { @@ -755,22 +755,22 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.CfnTaskDefinition", + "version": "0.0.0" } }, "Container": { "id": "Container", "path": "aws-cdk-codedeploy-ecs-dg/TaskDef/Container", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.ContainerDefinition", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.FargateTaskDefinition", + "version": "0.0.0" } }, "FargateService": { @@ -830,8 +830,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.CfnService", + "version": "0.0.0" } }, "SecurityGroup": { @@ -858,8 +858,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" } }, "from awscdkcodedeployecsdgServiceLBSecurityGroupEC967688:80": { @@ -868,7 +868,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroupIngress", "aws:cdk:cloudformation:props": { - "ipProtocol": "tcp", "description": "Load balancer to target", "fromPort": 80, "groupId": { @@ -877,6 +876,7 @@ "GroupId" ] }, + "ipProtocol": "tcp", "sourceSecurityGroupId": { "Fn::GetAtt": [ "ServiceLBSecurityGroup2EA7EDA1", @@ -887,20 +887,20 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroupIngress", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.FargateService", + "version": "0.0.0" } }, "TaskDef2": { @@ -915,8 +915,8 @@ "id": "ImportTaskRole", "path": "aws-cdk-codedeploy-ecs-dg/TaskDef2/TaskRole/ImportTaskRole", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "Resource": { @@ -940,14 +940,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" } }, "Resource": { @@ -985,22 +985,22 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.CfnTaskDefinition", + "version": "0.0.0" } }, "Container": { "id": "Container", "path": "aws-cdk-codedeploy-ecs-dg/TaskDef2/Container", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.ContainerDefinition", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ecs.FargateTaskDefinition", + "version": "0.0.0" } }, "ServiceLB": { @@ -1040,8 +1040,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.CfnLoadBalancer", + "version": "0.0.0" } }, "SecurityGroup": { @@ -1077,8 +1077,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" } }, "to awscdkcodedeployecsdgFargateServiceSecurityGroup64C2B62E:80": { @@ -1087,13 +1087,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroupEgress", "aws:cdk:cloudformation:props": { - "groupId": { - "Fn::GetAtt": [ - "ServiceLBSecurityGroup2EA7EDA1", - "GroupId" - ] - }, - "ipProtocol": "tcp", "description": "Load balancer to target", "destinationSecurityGroupId": { "Fn::GetAtt": [ @@ -1102,18 +1095,25 @@ ] }, "fromPort": 80, + "groupId": { + "Fn::GetAtt": [ + "ServiceLBSecurityGroup2EA7EDA1", + "GroupId" + ] + }, + "ipProtocol": "tcp", "toPort": 80 } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroupEgress", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" } }, "ProdListener": { @@ -1142,8 +1142,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.CfnListener", + "version": "0.0.0" } }, "BlueTGGroup": { @@ -1182,20 +1182,20 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.CfnTargetGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationTargetGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationListener", + "version": "0.0.0" } }, "TestListener": { @@ -1224,20 +1224,20 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.CfnListener", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationListener", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationLoadBalancer", + "version": "0.0.0" } }, "GreenTG": { @@ -1276,14 +1276,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.CfnTargetGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationTargetGroup", + "version": "0.0.0" } }, "BlueUnhealthyHosts": { @@ -1296,9 +1296,8 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", "aws:cdk:cloudformation:props": { - "comparisonOperator": "GreaterThanOrEqualToThreshold", - "evaluationPeriods": 2, "alarmName": "aws-cdk-codedeploy-ecs-dg-Unhealthy-Hosts-Blue", + "comparisonOperator": "GreaterThanOrEqualToThreshold", "dimensions": [ { "name": "LoadBalancer", @@ -1361,6 +1360,7 @@ } } ], + "evaluationPeriods": 2, "metricName": "UnHealthyHostCount", "namespace": "AWS/ApplicationELB", "period": 300, @@ -1369,14 +1369,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnAlarm", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.Alarm", + "version": "0.0.0" } }, "Blue5xx": { @@ -1389,9 +1389,8 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", "aws:cdk:cloudformation:props": { - "comparisonOperator": "GreaterThanOrEqualToThreshold", - "evaluationPeriods": 1, "alarmName": "aws-cdk-codedeploy-ecs-dg-Http-500-Blue", + "comparisonOperator": "GreaterThanOrEqualToThreshold", "dimensions": [ { "name": "LoadBalancer", @@ -1454,6 +1453,7 @@ } } ], + "evaluationPeriods": 1, "metricName": "HTTPCode_Target_5XX_Count", "namespace": "AWS/ApplicationELB", "period": 60, @@ -1462,14 +1462,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnAlarm", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.Alarm", + "version": "0.0.0" } }, "GreenUnhealthyHosts": { @@ -1482,9 +1482,8 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", "aws:cdk:cloudformation:props": { - "comparisonOperator": "GreaterThanOrEqualToThreshold", - "evaluationPeriods": 2, "alarmName": "aws-cdk-codedeploy-ecs-dg-Unhealthy-Hosts-Green", + "comparisonOperator": "GreaterThanOrEqualToThreshold", "dimensions": [ { "name": "LoadBalancer", @@ -1547,6 +1546,7 @@ } } ], + "evaluationPeriods": 2, "metricName": "UnHealthyHostCount", "namespace": "AWS/ApplicationELB", "period": 300, @@ -1555,14 +1555,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnAlarm", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.Alarm", + "version": "0.0.0" } }, "Green5xx": { @@ -1575,9 +1575,8 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", "aws:cdk:cloudformation:props": { - "comparisonOperator": "GreaterThanOrEqualToThreshold", - "evaluationPeriods": 1, "alarmName": "aws-cdk-codedeploy-ecs-dg-Http-500-Green", + "comparisonOperator": "GreaterThanOrEqualToThreshold", "dimensions": [ { "name": "LoadBalancer", @@ -1640,6 +1639,7 @@ } } ], + "evaluationPeriods": 1, "metricName": "HTTPCode_Target_5XX_Count", "namespace": "AWS/ApplicationELB", "period": 60, @@ -1648,14 +1648,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnAlarm", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_cloudwatch.Alarm", + "version": "0.0.0" } }, "CanaryConfig": { @@ -1679,14 +1679,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_codedeploy.EcsDeploymentConfig", + "version": "0.0.0" } }, "BlueGreenDG": { @@ -1701,8 +1701,8 @@ "id": "ImportServiceRole", "path": "aws-cdk-codedeploy-ecs-dg/BlueGreenDG/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "Resource": { @@ -1740,14 +1740,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" } }, "Application": { @@ -1764,14 +1764,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_codedeploy.CfnApplication", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_codedeploy.EcsApplication", + "version": "0.0.0" } }, "Resource": { @@ -1780,15 +1780,6 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::CodeDeploy::DeploymentGroup", "aws:cdk:cloudformation:props": { - "applicationName": { - "Ref": "BlueGreenDGApplication3649479D" - }, - "serviceRoleArn": { - "Fn::GetAtt": [ - "BlueGreenDGServiceRole33E3BCAC", - "Arn" - ] - }, "alarmConfiguration": { "alarms": [ { @@ -1812,7 +1803,10 @@ } } ], - "enabled": true + "enabled": false + }, + "applicationName": { + "Ref": "BlueGreenDGApplication3649479D" }, "autoRollbackConfiguration": { "enabled": true, @@ -1889,88 +1883,94 @@ } } ] + }, + "serviceRoleArn": { + "Fn::GetAtt": [ + "BlueGreenDGServiceRole33E3BCAC", + "Arn" + ] } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.aws_codedeploy.EcsDeploymentGroup", + "version": "0.0.0" } }, "NewTaskDefinition": { "id": "NewTaskDefinition", "path": "aws-cdk-codedeploy-ecs-dg/NewTaskDefinition", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" } }, "Subnet1Id": { "id": "Subnet1Id", "path": "aws-cdk-codedeploy-ecs-dg/Subnet1Id", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" } }, "Subnet2Id": { "id": "Subnet2Id", "path": "aws-cdk-codedeploy-ecs-dg/Subnet2Id", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" } }, "SecurityGroupId": { "id": "SecurityGroupId", "path": "aws-cdk-codedeploy-ecs-dg/SecurityGroupId", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" } }, "CodeDeployApplicationName": { "id": "CodeDeployApplicationName", "path": "aws-cdk-codedeploy-ecs-dg/CodeDeployApplicationName", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" } }, "CodeDeployDeploymentGroupName": { "id": "CodeDeployDeploymentGroupName", "path": "aws-cdk-codedeploy-ecs-dg/CodeDeployDeploymentGroupName", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" } }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-cdk-codedeploy-ecs-dg/BootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "aws-cdk-codedeploy-ecs-dg/CheckBootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" } }, "EcsDeploymentGroupTest": { @@ -1986,7 +1986,7 @@ "path": "EcsDeploymentGroupTest/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.70" } }, "DeployAssert": { @@ -1997,22 +1997,22 @@ "id": "BootstrapVersion", "path": "EcsDeploymentGroupTest/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "EcsDeploymentGroupTest/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" } } }, @@ -2032,13 +2032,13 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.2.55" + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.ts index 2d93b158cd709..bef7582148d71 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.ts @@ -222,6 +222,7 @@ const dg = new codedeploy.EcsDeploymentGroup(stack, 'BlueGreenDG', { autoRollback: { stoppedDeployment: true, }, + ignoreAlarmConfiguration: true, }); // Outputs to use for manual testing diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts index 89345735db90f..a20a28088b47f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts @@ -43,6 +43,7 @@ new codedeploy.LambdaDeploymentGroup(stack, 'BlueGreenDeployment', { ], preHook, postHook, + ignoreAlarmConfiguration: false, }); const secondAlias = new lambda.Alias(stack, 'SecondAlias', { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts index 9126d4d7ef67e..c00d67e71bfef 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts @@ -40,6 +40,7 @@ new codedeploy.ServerDeploymentGroup(stack, 'CodeDeployGroup', { failedDeployment: false, deploymentInAlarm: false, }, + ignoreAlarmConfiguration: false, }); app.synth(); From 834c11b3927c40b5079bd9d2d17e8c87af53988c Mon Sep 17 00:00:00 2001 From: Nicholas Geil Date: Wed, 25 Oct 2023 06:45:09 -0400 Subject: [PATCH 3/8] Address PR comments - Update parameter ordering - Add missing unit tests for removeAlarms feature flag - Drop redundant integration test changes --- .../test/lambda/integ.deployment-group.ts | 1 - .../test/server/integ.deployment-group.ts | 1 - .../lib/ecs/deployment-group.ts | 2 +- .../lib/lambda/deployment-group.ts | 2 +- .../aws-codedeploy/lib/private/utils.ts | 2 +- .../lib/server/deployment-group.ts | 2 +- .../test/ecs/deployment-group.test.ts | 31 +++++++++++++++++++ .../test/lambda/deployment-group.test.ts | 27 ++++++++++++++++ .../test/server/deployment-group.test.ts | 25 +++++++++++++++ 9 files changed, 87 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts index a20a28088b47f..89345735db90f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-group.ts @@ -43,7 +43,6 @@ new codedeploy.LambdaDeploymentGroup(stack, 'BlueGreenDeployment', { ], preHook, postHook, - ignoreAlarmConfiguration: false, }); const secondAlias = new lambda.Alias(stack, 'SecondAlias', { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts index c00d67e71bfef..9126d4d7ef67e 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts @@ -40,7 +40,6 @@ new codedeploy.ServerDeploymentGroup(stack, 'CodeDeployGroup', { failedDeployment: false, deploymentInAlarm: false, }, - ignoreAlarmConfiguration: false, }); app.synth(); diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts index 597228d0c9f55..4c9f104690f4a 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts @@ -271,8 +271,8 @@ export class EcsDeploymentGroup extends DeploymentGroupBase implements IEcsDeplo produce: () => renderAlarmConfiguration( this.alarms, props.ignorePollAlarmsFailure, - removeAlarmsFromDeploymentGroup, props.ignoreAlarmConfiguration, + removeAlarmsFromDeploymentGroup, ), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts index b35eaf4f4fd92..ee73e81826da6 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts @@ -186,8 +186,8 @@ export class LambdaDeploymentGroup extends DeploymentGroupBase implements ILambd alarmConfiguration: cdk.Lazy.any({ produce: () => renderAlarmConfiguration( this.alarms, props.ignorePollAlarmsFailure, - removeAlarmsFromDeploymentGroup, props.ignoreAlarmConfiguration, + removeAlarmsFromDeploymentGroup, ), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index dc98e4b7c4cd9..60001e6d66c20 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -34,8 +34,8 @@ export function arnForDeploymentConfig(name: string, resource?: IResource): stri export function renderAlarmConfiguration( alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure: boolean | undefined, - removeAlarms = true, ignoreAlarmConfiguration: boolean = false, + removeAlarms = true, ): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { if (removeAlarms) { return { diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts index 3055d7edc5698..a2dceff17cbcd 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts @@ -295,8 +295,8 @@ export class ServerDeploymentGroup extends DeploymentGroupBase implements IServe alarmConfiguration: cdk.Lazy.any({ produce: () => renderAlarmConfiguration( this.alarms, props.ignorePollAlarmsFailure, - removeAlarmsFromDeploymentGroup, props.ignoreAlarmConfiguration, + removeAlarmsFromDeploymentGroup, ), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), diff --git a/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts b/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts index 5aa12881aea06..ff244b80f66fc 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/test/ecs/deployment-group.test.ts @@ -913,4 +913,35 @@ describe('CodeDeploy ECS DeploymentGroup', () => { }, }); }); + + test('alarms not enabled when removeAlarms is passed with ignoreAlarmConfiguration', () => { + const stack = new cdk.Stack(); + stack.node.setContext('@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup', true); + + new codedeploy.EcsDeploymentGroup(stack, 'MyDG', { + ignoreAlarmConfiguration: true, + alarms: [ + new cloudwatch.Alarm(stack, 'BlueTGUnHealthyHosts', { + metric: new cloudwatch.Metric({ + namespace: 'AWS/ApplicationELB', + metricName: 'UnHealthyHostCount', + }), + threshold: 1, + evaluationPeriods: 1, + }), + ], + service: mockEcsService(stack), + blueGreenDeploymentConfig: { + blueTargetGroup: mockTargetGroup(stack, 'blue'), + greenTargetGroup: mockTargetGroup(stack, 'green'), + listener: mockListener(stack, 'prod'), + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeDeploy::DeploymentGroup', { + AlarmConfiguration: { + Enabled: false, + }, + }); + }); }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts b/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts index a7bb7e9e57b52..c3a7c5110fa00 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/test/lambda/deployment-group.test.ts @@ -677,6 +677,33 @@ describe('CodeDeploy Lambda DeploymentGroup', () => { }, }); }); + + test('alarms not enabled when removeAlarms is passed with ignoreAlarmConfiguration', () => { + const stack = new cdk.Stack(); + stack.node.setContext('@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup', true); + + const application = new codedeploy.LambdaApplication(stack, 'MyApp'); + const alias = mockAlias(stack); + new codedeploy.LambdaDeploymentGroup(stack, 'MyDG', { + application, + alias, + postHook: mockFunction(stack, 'PostHook'), + deploymentConfig: codedeploy.LambdaDeploymentConfig.ALL_AT_ONCE, + ignoreAlarmConfiguration: true, + alarms: [new cloudwatch.Alarm(stack, 'Failures', { + metric: alias.metricErrors(), + comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD, + threshold: 1, + evaluationPeriods: 1, + })], + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeDeploy::DeploymentGroup', { + AlarmConfiguration: { + Enabled: false, + }, + }); + }); }); describe('imported with fromLambdaDeploymentGroupAttributes', () => { diff --git a/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts b/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts index a189bda4b3123..407c52363e38b 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts @@ -564,4 +564,29 @@ describe('CodeDeploy Server Deployment Group', () => { }, }); }); + + test('alarms not enabled when removeAlarms is passed with ignoreAlarmConfiguration', () => { + const stack = new cdk.Stack(); + stack.node.setContext('@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup', true); + + new codedeploy.ServerDeploymentGroup(stack, 'DeploymentGroup', { + alarms: [ + new cloudwatch.Alarm(stack, 'Alarm1', { + metric: new cloudwatch.Metric({ + metricName: 'Errors', + namespace: 'my.namespace', + }), + threshold: 1, + evaluationPeriods: 1, + }), + ], + ignoreAlarmConfiguration: true, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeDeploy::DeploymentGroup', { + AlarmConfiguration: { + Enabled: false, + }, + }); + }); }); From 0abaa82ae53798e483dd761718ba2d1f11eb5d64 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Fri, 27 Oct 2023 10:50:48 -0400 Subject: [PATCH 4/8] Apply suggestions from code review Co-authored-by: Luca Pizzini --- .../aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts | 2 +- .../aws-codedeploy/lib/lambda/deployment-group.ts | 5 +++-- packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts | 4 ++-- .../aws-codedeploy/lib/server/deployment-group.ts | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts index 4c9f104690f4a..0c479cbad82bf 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts @@ -182,7 +182,7 @@ export interface EcsDeploymentGroupProps { /** * Whether to skip the step of checking CloudWatch alarms during the deployment process * - * @default false + * @default - false */ readonly ignoreAlarmConfiguration?: boolean; } diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts index ee73e81826da6..0512ddf4d36d4 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts @@ -121,7 +121,7 @@ export interface LambdaDeploymentGroupProps { /** * Whether to skip the step of checking CloudWatch alarms during the deployment process * - * @default false + * @default - false */ readonly ignoreAlarmConfiguration?: boolean; } @@ -185,7 +185,8 @@ export class LambdaDeploymentGroup extends DeploymentGroupBase implements ILambd }, alarmConfiguration: cdk.Lazy.any({ produce: () => renderAlarmConfiguration( - this.alarms, props.ignorePollAlarmsFailure, + this.alarms, + props.ignorePollAlarmsFailure, props.ignoreAlarmConfiguration, removeAlarmsFromDeploymentGroup, ), diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index 60001e6d66c20..c2a2a9723769d 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -33,8 +33,8 @@ export function arnForDeploymentConfig(name: string, resource?: IResource): stri export function renderAlarmConfiguration( alarms: cloudwatch.IAlarm[], - ignorePollAlarmFailure: boolean | undefined, - ignoreAlarmConfiguration: boolean = false, + ignorePollAlarmFailure?: boolean, + ignoreAlarmConfiguration false, removeAlarms = true, ): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { if (removeAlarms) { diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts index a2dceff17cbcd..abb058a36b3ca 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts @@ -214,7 +214,7 @@ export interface ServerDeploymentGroupProps { /** * Whether to skip the step of checking CloudWatch alarms during the deployment process * - * @default false + * @default - false */ readonly ignoreAlarmConfiguration?: boolean; } @@ -294,7 +294,8 @@ export class ServerDeploymentGroup extends DeploymentGroupBase implements IServe onPremisesTagSet: this.onPremiseTagSet(props.onPremiseInstanceTags), alarmConfiguration: cdk.Lazy.any({ produce: () => renderAlarmConfiguration( - this.alarms, props.ignorePollAlarmsFailure, + this.alarms, + props.ignorePollAlarmsFailure, props.ignoreAlarmConfiguration, removeAlarmsFromDeploymentGroup, ), From 8d117431bad3a673aae4807ac0a7efcde1162a43 Mon Sep 17 00:00:00 2001 From: Nicholas Geil Date: Fri, 27 Oct 2023 15:07:20 -0400 Subject: [PATCH 5/8] fix mistake --- packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index c2a2a9723769d..5813e46addd2b 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -34,7 +34,7 @@ export function arnForDeploymentConfig(name: string, resource?: IResource): stri export function renderAlarmConfiguration( alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure?: boolean, - ignoreAlarmConfiguration false, + ignoreAlarmConfiguration = false, removeAlarms = true, ): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { if (removeAlarms) { From 59ffe2ee5b729a15de62ee8f846d5b9e05307e14 Mon Sep 17 00:00:00 2001 From: Nicholas Geil Date: Wed, 10 Jan 2024 07:33:55 -0500 Subject: [PATCH 6/8] Deprecate renderAlarmConfiguration and replace with renderAlarmConfigurationV2 - Create props class - Documentation updates - Update implementation to handle defaults --- .../lib/ecs/deployment-group.ts | 14 ++--- .../lib/lambda/deployment-group.ts | 14 ++--- .../aws-codedeploy/lib/private/utils.ts | 51 ++++++++++++++----- .../lib/server/deployment-group.ts | 14 ++--- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts index 0c479cbad82bf..fbbacc2f92b1a 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts @@ -9,7 +9,7 @@ import * as cdk from '../../../core'; import { CODEDEPLOY_REMOVE_ALARMS_FROM_DEPLOYMENT_GROUP } from '../../../cx-api'; import { CfnDeploymentGroup } from '../codedeploy.generated'; import { ImportedDeploymentGroupBase, DeploymentGroupBase } from '../private/base-deployment-group'; -import { renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../private/utils'; +import { renderAlarmConfigurationV2, renderAutoRollbackConfiguration } from '../private/utils'; import { AutoRollbackConfig } from '../rollback-config'; /** @@ -268,12 +268,12 @@ export class EcsDeploymentGroup extends DeploymentGroupBase implements IEcsDeplo }), loadBalancerInfo: cdk.Lazy.any({ produce: () => this.renderLoadBalancerInfo(props.blueGreenDeploymentConfig) }), alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfiguration( - this.alarms, - props.ignorePollAlarmsFailure, - props.ignoreAlarmConfiguration, - removeAlarmsFromDeploymentGroup, - ), + produce: () => renderAlarmConfigurationV2({ + alarms: this.alarms, + ignorePollAlarmFailure: props.ignorePollAlarmsFailure, + removeAlarms: removeAlarmsFromDeploymentGroup, + ignoreAlarmConfiguration: props.ignoreAlarmConfiguration, + }), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts index 0512ddf4d36d4..3c2683ef4ccb4 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts @@ -8,7 +8,7 @@ import * as cdk from '../../../core'; import { CODEDEPLOY_REMOVE_ALARMS_FROM_DEPLOYMENT_GROUP } from '../../../cx-api'; import { CfnDeploymentGroup } from '../codedeploy.generated'; import { ImportedDeploymentGroupBase, DeploymentGroupBase } from '../private/base-deployment-group'; -import { renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../private/utils'; +import { renderAlarmConfigurationV2, renderAutoRollbackConfiguration } from '../private/utils'; import { AutoRollbackConfig } from '../rollback-config'; /** @@ -184,12 +184,12 @@ export class LambdaDeploymentGroup extends DeploymentGroupBase implements ILambd deploymentOption: 'WITH_TRAFFIC_CONTROL', }, alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfiguration( - this.alarms, - props.ignorePollAlarmsFailure, - props.ignoreAlarmConfiguration, - removeAlarmsFromDeploymentGroup, - ), + produce: () => renderAlarmConfigurationV2({ + alarms: this.alarms, + ignorePollAlarmFailure: props.ignorePollAlarmsFailure, + removeAlarms: removeAlarmsFromDeploymentGroup, + ignoreAlarmConfiguration: props.ignoreAlarmConfiguration, + }), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), }); diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index 5813e46addd2b..e20785cb1e3a5 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -31,29 +31,56 @@ export function arnForDeploymentConfig(name: string, resource?: IResource): stri }); } -export function renderAlarmConfiguration( - alarms: cloudwatch.IAlarm[], - ignorePollAlarmFailure?: boolean, - ignoreAlarmConfiguration = false, - removeAlarms = true, -): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { +export interface renderAlarmConfigProps { + /** + * Array of Cloudwatch alarms + */ + readonly alarms: cloudwatch.IAlarm[], + /** + * Whether to ignore failure to fetch the status of alarms from CloudWatch + */ + readonly ignorePollAlarmFailure?: boolean, + /** + * When no alarms are provided on an update, removes previously existing alarms from the construct. + * @see https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cx-api/FEATURE_FLAGS.md#aws-cdkaws-codedeployremovealarmsfromdeploymentgroup + * + * @default true + */ + readonly removeAlarms?: boolean, + /** + * Whether to skip the step of checking CloudWatch alarms during the deployment process + * + * @default false + */ + ignoreAlarmConfiguration?: boolean +} + +export function renderAlarmConfigurationV2(props: renderAlarmConfigProps): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { + const ignoreAlarmConfiguration = props.ignoreAlarmConfiguration ?? false; + const removeAlarms = props.removeAlarms ?? true; if (removeAlarms) { return { - alarms: alarms.length > 0 ? alarms.map(a => ({ name: a.alarmName })) : undefined, - enabled: !ignoreAlarmConfiguration && alarms.length > 0, - ignorePollAlarmFailure, + alarms: props.alarms.length > 0 ? props.alarms.map(a => ({ name: a.alarmName })) : undefined, + enabled: !ignoreAlarmConfiguration && props.alarms.length > 0, + ignorePollAlarmFailure: props.ignorePollAlarmFailure, }; } - return alarms.length === 0 + return props.alarms.length === 0 ? undefined : { - alarms: alarms.map(a => ({ name: a.alarmName })), + alarms: props.alarms.map(a => ({ name: a.alarmName })), enabled: !ignoreAlarmConfiguration, - ignorePollAlarmFailure, + ignorePollAlarmFailure: props.ignorePollAlarmFailure, }; } +/** @deprecated Use renderAlarmConfigurationV2 instead */ +export function renderAlarmConfiguration(alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure: boolean | undefined, removeAlarms = true): +CfnDeploymentGroup.AlarmConfigurationProperty | undefined { + return renderAlarmConfigurationV2({ alarms, ignorePollAlarmFailure, removeAlarms }); +} + export function deploymentConfig(name: string): IBaseDeploymentConfig & IPredefinedDeploymentConfig { return { deploymentConfigName: name, diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts index e313860ebc6f3..91bb9944a3288 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts @@ -11,7 +11,7 @@ import * as cdk from '../../../core'; import { CODEDEPLOY_REMOVE_ALARMS_FROM_DEPLOYMENT_GROUP } from '../../../cx-api'; import { CfnDeploymentGroup } from '../codedeploy.generated'; import { ImportedDeploymentGroupBase, DeploymentGroupBase } from '../private/base-deployment-group'; -import { renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../private/utils'; +import { renderAlarmConfigurationV2, renderAutoRollbackConfiguration } from '../private/utils'; import { AutoRollbackConfig } from '../rollback-config'; export interface IServerDeploymentGroup extends cdk.IResource { @@ -310,12 +310,12 @@ export class ServerDeploymentGroup extends DeploymentGroupBase implements IServe ec2TagSet: this.ec2TagSet(props.ec2InstanceTags), onPremisesTagSet: this.onPremiseTagSet(props.onPremiseInstanceTags), alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfiguration( - this.alarms, - props.ignorePollAlarmsFailure, - props.ignoreAlarmConfiguration, - removeAlarmsFromDeploymentGroup, - ), + produce: () => renderAlarmConfigurationV2({ + alarms: this.alarms, + ignorePollAlarmFailure: props.ignorePollAlarmsFailure, + removeAlarms: removeAlarmsFromDeploymentGroup, + ignoreAlarmConfiguration: props.ignoreAlarmConfiguration, + }), }), autoRollbackConfiguration: cdk.Lazy.any({ produce: () => renderAutoRollbackConfiguration(this.alarms, props.autoRollback) }), }); From 32a8a27fdc93d1c672654ee892046ce6a2e12aae Mon Sep 17 00:00:00 2001 From: Nicholas Geil Date: Wed, 10 Jan 2024 07:41:14 -0500 Subject: [PATCH 7/8] Fix @see doc notation for external link --- packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index e20785cb1e3a5..d032994b8385b 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -42,7 +42,7 @@ export interface renderAlarmConfigProps { readonly ignorePollAlarmFailure?: boolean, /** * When no alarms are provided on an update, removes previously existing alarms from the construct. - * @see https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cx-api/FEATURE_FLAGS.md#aws-cdkaws-codedeployremovealarmsfromdeploymentgroup + * @see {@link https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cx-api/FEATURE_FLAGS.md#aws-cdkaws-codedeployremovealarmsfromdeploymentgroup} * * @default true */ From 9b3be1d929a17db262faf24a7afda8bf1604eb63 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:39:20 -0500 Subject: [PATCH 8/8] Apply suggestions from code review --- .../lib/ecs/deployment-group.ts | 4 ++-- .../lib/lambda/deployment-group.ts | 4 ++-- .../aws-codedeploy/lib/private/utils.ts | 19 ++++++++----------- .../lib/server/deployment-group.ts | 4 ++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts index fbbacc2f92b1a..9ff4b247952f4 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts @@ -9,7 +9,7 @@ import * as cdk from '../../../core'; import { CODEDEPLOY_REMOVE_ALARMS_FROM_DEPLOYMENT_GROUP } from '../../../cx-api'; import { CfnDeploymentGroup } from '../codedeploy.generated'; import { ImportedDeploymentGroupBase, DeploymentGroupBase } from '../private/base-deployment-group'; -import { renderAlarmConfigurationV2, renderAutoRollbackConfiguration } from '../private/utils'; +import { renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../private/utils'; import { AutoRollbackConfig } from '../rollback-config'; /** @@ -268,7 +268,7 @@ export class EcsDeploymentGroup extends DeploymentGroupBase implements IEcsDeplo }), loadBalancerInfo: cdk.Lazy.any({ produce: () => this.renderLoadBalancerInfo(props.blueGreenDeploymentConfig) }), alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfigurationV2({ + produce: () => renderAlarmConfiguration({ alarms: this.alarms, ignorePollAlarmFailure: props.ignorePollAlarmsFailure, removeAlarms: removeAlarmsFromDeploymentGroup, diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts index 3c2683ef4ccb4..86f6134e62151 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/lambda/deployment-group.ts @@ -8,7 +8,7 @@ import * as cdk from '../../../core'; import { CODEDEPLOY_REMOVE_ALARMS_FROM_DEPLOYMENT_GROUP } from '../../../cx-api'; import { CfnDeploymentGroup } from '../codedeploy.generated'; import { ImportedDeploymentGroupBase, DeploymentGroupBase } from '../private/base-deployment-group'; -import { renderAlarmConfigurationV2, renderAutoRollbackConfiguration } from '../private/utils'; +import { renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../private/utils'; import { AutoRollbackConfig } from '../rollback-config'; /** @@ -184,7 +184,7 @@ export class LambdaDeploymentGroup extends DeploymentGroupBase implements ILambd deploymentOption: 'WITH_TRAFFIC_CONTROL', }, alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfigurationV2({ + produce: () => renderAlarmConfiguration({ alarms: this.alarms, ignorePollAlarmFailure: props.ignorePollAlarmsFailure, removeAlarms: removeAlarmsFromDeploymentGroup, diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts index 80d4873e256e1..0b9ae20ae3df1 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts @@ -35,27 +35,30 @@ export interface renderAlarmConfigProps { /** * Array of Cloudwatch alarms */ - readonly alarms: cloudwatch.IAlarm[], + readonly alarms: cloudwatch.IAlarm[]; + /** * Whether to ignore failure to fetch the status of alarms from CloudWatch */ - readonly ignorePollAlarmFailure?: boolean, + readonly ignorePollAlarmFailure?: boolean; + /** * When no alarms are provided on an update, removes previously existing alarms from the construct. * @see {@link https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/cx-api/FEATURE_FLAGS.md#aws-cdkaws-codedeployremovealarmsfromdeploymentgroup} * * @default true */ - readonly removeAlarms?: boolean, + readonly removeAlarms?: boolean; + /** * Whether to skip the step of checking CloudWatch alarms during the deployment process * * @default false */ - ignoreAlarmConfiguration?: boolean + ignoreAlarmConfiguration?: boolean; } -export function renderAlarmConfigurationV2(props: renderAlarmConfigProps): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { +export function renderAlarmConfiguration(props: renderAlarmConfigProps): CfnDeploymentGroup.AlarmConfigurationProperty | undefined { const ignoreAlarmConfiguration = props.ignoreAlarmConfiguration ?? false; const removeAlarms = props.removeAlarms ?? true; if (removeAlarms) { @@ -75,12 +78,6 @@ export function renderAlarmConfigurationV2(props: renderAlarmConfigProps): CfnDe }; } -/** @deprecated Use renderAlarmConfigurationV2 instead */ -export function renderAlarmConfiguration(alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure: boolean | undefined, removeAlarms = true): -CfnDeploymentGroup.AlarmConfigurationProperty | undefined { - return renderAlarmConfigurationV2({ alarms, ignorePollAlarmFailure, removeAlarms }); -} - export function deploymentConfig(name: string): IBaseDeploymentConfig & IPredefinedDeploymentConfig { return { deploymentConfigName: name, diff --git a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts index df5bbbb4b4a31..f2ca41f1f74b8 100644 --- a/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts +++ b/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts @@ -11,7 +11,7 @@ import * as cdk from '../../../core'; import { CODEDEPLOY_REMOVE_ALARMS_FROM_DEPLOYMENT_GROUP } from '../../../cx-api'; import { CfnDeploymentGroup } from '../codedeploy.generated'; import { ImportedDeploymentGroupBase, DeploymentGroupBase } from '../private/base-deployment-group'; -import { renderAlarmConfigurationV2, renderAutoRollbackConfiguration } from '../private/utils'; +import { renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../private/utils'; import { AutoRollbackConfig } from '../rollback-config'; export interface IServerDeploymentGroup extends cdk.IResource { @@ -310,7 +310,7 @@ export class ServerDeploymentGroup extends DeploymentGroupBase implements IServe ec2TagSet: this.ec2TagSet(props.ec2InstanceTags), onPremisesTagSet: this.onPremiseTagSet(props.onPremiseInstanceTags), alarmConfiguration: cdk.Lazy.any({ - produce: () => renderAlarmConfigurationV2({ + produce: () => renderAlarmConfiguration({ alarms: this.alarms, ignorePollAlarmFailure: props.ignorePollAlarmsFailure, removeAlarms: removeAlarmsFromDeploymentGroup,