Skip to content

Commit

Permalink
fix(codedeploy): unable to remove alarms from deployment group
Browse files Browse the repository at this point in the history
  • Loading branch information
cecheta committed Feb 14, 2023
1 parent 6a9e43f commit bb38e36
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 66 deletions.
16 changes: 7 additions & 9 deletions packages/@aws-cdk/aws-codedeploy/lib/private/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ export function arnForDeploymentConfig(name: string, resource?: IResource): stri
}

export function renderAlarmConfiguration(alarms: cloudwatch.IAlarm[], ignorePollAlarmFailure?: boolean):
CfnDeploymentGroup.AlarmConfigurationProperty | undefined {
return alarms.length === 0
? undefined
: {
alarms: alarms.map(a => ({ name: a.alarmName })),
enabled: true,
ignorePollAlarmFailure,
};
CfnDeploymentGroup.AlarmConfigurationProperty {
return {
alarms: alarms.length > 0 ? alarms.map(a => ({ name: a.alarmName })) : undefined,
enabled: alarms.length > 0,
ignorePollAlarmFailure,
};
}

export function deploymentConfig(name: string): IBaseDeploymentConfig & IPredefinedDeploymentConfig {
Expand Down Expand Up @@ -114,4 +112,4 @@ export function validateName(type: 'Application' | 'Deployment group' | 'Deploym
}

return ret;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Template } from '@aws-cdk/assertions';
import { Match, Template } from '@aws-cdk/assertions';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as iam from '@aws-cdk/aws-iam';
import * as lambda from '@aws-cdk/aws-lambda';
Expand Down Expand Up @@ -44,6 +44,10 @@ describe('CodeDeploy Lambda DeploymentGroup', () => {
'Arn',
],
},
AlarmConfiguration: {
Enabled: false,
Alarms: Match.absent(),
},
AutoRollbackConfiguration: {
Enabled: true,
Events: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "22.0.0",
"files": {
"edb7466707eb899fbaee22c1e67f9443e9edcc2eeda0b58d8448f7c4157746b3": {
"source": {
Expand Down Expand Up @@ -40,15 +40,15 @@
}
}
},
"f2bf64943c8612dfbd52471095c4b141d6c458592f9416621609658bc7935827": {
"209ced6e70ec9b3c3a5387896ca7c4942afced90ed5eb6045cc8f392776ae7ce": {
"source": {
"path": "aws-cdk-codedeploy-lambda.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "f2bf64943c8612dfbd52471095c4b141d6c458592f9416621609658bc7935827.json",
"objectKey": "209ced6e70ec9b3c3a5387896ca7c4942afced90ed5eb6045cc8f392776ae7ce.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,6 @@
"Threshold": 1
}
},
"BlueGreenDeploymentApplication36C892C0": {
"Type": "AWS::CodeDeploy::Application",
"Properties": {
"ComputePlatform": "Lambda"
}
},
"BlueGreenDeploymentServiceRole225851FB": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -427,6 +421,12 @@
]
}
},
"BlueGreenDeploymentApplication36C892C0": {
"Type": "AWS::CodeDeploy::Application",
"Properties": {
"ComputePlatform": "Lambda"
}
},
"BlueGreenDeployment5C188134": {
"Type": "AWS::CodeDeploy::DeploymentGroup",
"Properties": {
Expand Down Expand Up @@ -462,6 +462,96 @@
"DeploymentType": "BLUE_GREEN"
}
}
},
"SecondAlias33D63566": {
"Type": "AWS::Lambda::Alias",
"Properties": {
"FunctionName": {
"Ref": "Handler886CB40B"
},
"FunctionVersion": {
"Fn::GetAtt": [
"HandlerCurrentVersion93FB80BF4a6a6623436a0664df4549c4c809c243",
"Version"
]
},
"Name": "secondAlias"
},
"UpdatePolicy": {
"CodeDeployLambdaAliasUpdate": {
"ApplicationName": {
"Ref": "SecondDeploymentApplication1F8C51FE"
},
"DeploymentGroupName": {
"Ref": "SecondDeploymentC270A23D"
}
}
}
},
"SecondDeploymentServiceRoleAFF1ECD5": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "codedeploy.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSCodeDeployRoleForLambdaLimited"
]
]
}
]
}
},
"SecondDeploymentApplication1F8C51FE": {
"Type": "AWS::CodeDeploy::Application",
"Properties": {
"ComputePlatform": "Lambda"
}
},
"SecondDeploymentC270A23D": {
"Type": "AWS::CodeDeploy::DeploymentGroup",
"Properties": {
"ApplicationName": {
"Ref": "SecondDeploymentApplication1F8C51FE"
},
"ServiceRoleArn": {
"Fn::GetAtt": [
"SecondDeploymentServiceRoleAFF1ECD5",
"Arn"
]
},
"AlarmConfiguration": {
"Enabled": false
},
"AutoRollbackConfiguration": {
"Enabled": true,
"Events": [
"DEPLOYMENT_FAILURE"
]
},
"DeploymentConfigName": "CodeDeployDefault.LambdaCanary10Percent5Minutes",
"DeploymentStyle": {
"DeploymentOption": "WITH_TRAFFIC_CONTROL",
"DeploymentType": "BLUE_GREEN"
}
}
}
},
"Parameters": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"22.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "22.0.0",
"testCases": {
"integ.deployment-group": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "22.0.0",
"artifacts": {
"aws-cdk-codedeploy-lambda.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -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}/f2bf64943c8612dfbd52471095c4b141d6c458592f9416621609658bc7935827.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/209ced6e70ec9b3c3a5387896ca7c4942afced90ed5eb6045cc8f392776ae7ce.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -99,12 +99,6 @@
"data": "BlueGreenErrors60C27452"
}
],
"/aws-cdk-codedeploy-lambda/BlueGreenDeployment/Application/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "BlueGreenDeploymentApplication36C892C0"
}
],
"/aws-cdk-codedeploy-lambda/BlueGreenDeployment/ServiceRole/Resource": [
{
"type": "aws:cdk:logicalId",
Expand All @@ -117,12 +111,42 @@
"data": "BlueGreenDeploymentServiceRoleDefaultPolicy7008FB0A"
}
],
"/aws-cdk-codedeploy-lambda/BlueGreenDeployment/Application/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "BlueGreenDeploymentApplication36C892C0"
}
],
"/aws-cdk-codedeploy-lambda/BlueGreenDeployment/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "BlueGreenDeployment5C188134"
}
],
"/aws-cdk-codedeploy-lambda/SecondAlias/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "SecondAlias33D63566"
}
],
"/aws-cdk-codedeploy-lambda/SecondDeployment/ServiceRole/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "SecondDeploymentServiceRoleAFF1ECD5"
}
],
"/aws-cdk-codedeploy-lambda/SecondDeployment/Application/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "SecondDeploymentApplication1F8C51FE"
}
],
"/aws-cdk-codedeploy-lambda/SecondDeployment/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "SecondDeploymentC270A23D"
}
],
"/aws-cdk-codedeploy-lambda/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
Expand Down
Loading

0 comments on commit bb38e36

Please sign in to comment.