Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizencc committed Feb 12, 2024
1 parent dbac7ef commit 9b3be1d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 8 additions & 11 deletions packages/aws-cdk-lib/aws-codedeploy/lib/private/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9b3be1d

Please sign in to comment.