From be6074a67b68ec2f295196ad73ddb6e92984bdf3 Mon Sep 17 00:00:00 2001 From: Mitchell Valine Date: Wed, 19 Oct 2022 19:16:57 -0700 Subject: [PATCH] fix: breaking change to deployment config props (#22567) Change all `deploymentConfig` static method implementations on `EcsDeploymentConfig`, `LambdaDeploymentConfig`, and `ServerDeploymentConfig` to return their corresponding specific interfaces instead of `IBaseDeploymentConfig`. This reverts breaking changes to Java users introduced in https://github.com/aws/aws-cdk/pull/22159 Fixes #22566 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-codedeploy/lib/base-deployment-config.ts | 13 ------------- .../aws-codedeploy/lib/ecs/deployment-config.ts | 5 +++++ .../aws-codedeploy/lib/lambda/deployment-config.ts | 5 +++++ .../aws-codedeploy/lib/server/deployment-config.ts | 5 +++++ packages/@aws-cdk/aws-codedeploy/lib/utils.ts | 8 ++++++++ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/packages/@aws-cdk/aws-codedeploy/lib/base-deployment-config.ts b/packages/@aws-cdk/aws-codedeploy/lib/base-deployment-config.ts index 0cd04ae3628c5..35c0c453cc7c2 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/base-deployment-config.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/base-deployment-config.ts @@ -109,19 +109,6 @@ export abstract class BaseDeploymentConfig extends Resource implements IBaseDepl }; } - /** - * This method should be used only for static references to predefined deployment configurations, - * like EcsDeploymentConfig.ALL_AT_ONCE - * @param name the name of the referenced custom Deployment Configuration - * @returns a reference to an existing custom Deployment Configuration - */ - protected static deploymentConfig(name: string): IBaseDeploymentConfig { - return { - deploymentConfigName: name, - deploymentConfigArn: arnForDeploymentConfig(name), - }; - } - /** * The name of the deployment config * @attribute diff --git a/packages/@aws-cdk/aws-codedeploy/lib/ecs/deployment-config.ts b/packages/@aws-cdk/aws-codedeploy/lib/ecs/deployment-config.ts index cd1f96aa50945..be6204b4b10ad 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/ecs/deployment-config.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/ecs/deployment-config.ts @@ -1,6 +1,7 @@ import { Construct } from 'constructs'; import { BaseDeploymentConfig, BaseDeploymentConfigOptions, ComputePlatform, IBaseDeploymentConfig } from '../base-deployment-config'; import { TrafficRouting } from '../traffic-routing-config'; +import { deploymentConfig } from '../utils'; /** * The Deployment Configuration of an ECS Deployment Group. @@ -59,6 +60,10 @@ export class EcsDeploymentConfig extends BaseDeploymentConfig implements IEcsDep return this.fromDeploymentConfigName(scope, id, ecsDeploymentConfigName); } + private static deploymentConfig(name: string): IEcsDeploymentConfig { + return deploymentConfig(name); + } + public constructor(scope: Construct, id: string, props?: EcsDeploymentConfigProps) { super(scope, id, { ...props, diff --git a/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-config.ts b/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-config.ts index 18690f239d820..a86da3222b5f1 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-config.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-config.ts @@ -1,6 +1,7 @@ import { Construct } from 'constructs'; import { BaseDeploymentConfig, BaseDeploymentConfigOptions, ComputePlatform, IBaseDeploymentConfig } from '../base-deployment-config'; import { TrafficRouting } from '../traffic-routing-config'; +import { deploymentConfig } from '../utils'; /** * The Deployment Configuration of a Lambda Deployment Group. @@ -92,6 +93,10 @@ export class LambdaDeploymentConfig extends BaseDeploymentConfig implements ILam return this.fromLambdaDeploymentConfigName(_scope, _id, props.deploymentConfigName); } + private static deploymentConfig(name: string): ILambdaDeploymentConfig { + return deploymentConfig(name); + } + public constructor(scope: Construct, id: string, props?: LambdaDeploymentConfigProps) { super(scope, id, { ...props, diff --git a/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-config.ts b/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-config.ts index 97a9357cbe0bc..c3ae4a75ffb59 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-config.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-config.ts @@ -1,6 +1,7 @@ import { Construct } from 'constructs'; import { BaseDeploymentConfig, BaseDeploymentConfigOptions, IBaseDeploymentConfig } from '../base-deployment-config'; import { MinimumHealthyHosts } from '../host-health-config'; +import { deploymentConfig } from '../utils'; /** * The Deployment Configuration of an EC2/on-premise Deployment Group. @@ -63,6 +64,10 @@ export class ServerDeploymentConfig extends BaseDeploymentConfig implements ISer return this.fromDeploymentConfigName(scope, id, serverDeploymentConfigName); } + private static deploymentConfig(name: string): IServerDeploymentConfig { + return deploymentConfig(name); + } + constructor(scope: Construct, id: string, props: ServerDeploymentConfigProps) { super(scope, id, props); } diff --git a/packages/@aws-cdk/aws-codedeploy/lib/utils.ts b/packages/@aws-cdk/aws-codedeploy/lib/utils.ts index 834e5afb506e9..137998a23eb37 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/utils.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/utils.ts @@ -1,5 +1,6 @@ import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import { Aws, Token } from '@aws-cdk/core'; +import { IBaseDeploymentConfig } from './base-deployment-config'; import { CfnDeploymentGroup } from './codedeploy.generated'; import { AutoRollbackConfig } from './rollback-config'; @@ -26,6 +27,13 @@ CfnDeploymentGroup.AlarmConfigurationProperty | undefined { }; } +export function deploymentConfig(name: string): IBaseDeploymentConfig { + return { + deploymentConfigName: name, + deploymentConfigArn: arnForDeploymentConfig(name), + }; +} + enum AutoRollbackEvent { DEPLOYMENT_FAILURE = 'DEPLOYMENT_FAILURE', DEPLOYMENT_STOP_ON_ALARM = 'DEPLOYMENT_STOP_ON_ALARM',