diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index 5a2983d9bdccf..8aa330f28597c 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.51.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.51.0-alpha.0...v2.51.1-alpha.0) (2022-11-18) + ## [2.51.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.50.0-alpha.0...v2.51.0-alpha.0) (2022-11-18) @@ -28,7 +30,7 @@ All notable changes to this project will be documented in this file. See [standa * **synthetics:** aws synthetics runtime version syn-nodejs-puppeteer-3.8 ([#22707](https://github.com/aws/aws-cdk/issues/22707)) ([228c865](https://github.com/aws/aws-cdk/commit/228c86532118b143e365b2268d06ee3a36fcf3a7)) -## [2.49.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.49.0-alpha.0...v2.49.1-alpha.0) (2022-10-31) +## [2.49.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.49.0-alpha.0...v2.49.1-alpha.0) (2022-10-31) ## [2.49.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.48.0-alpha.0...v2.49.0-alpha.0) (2022-10-27) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index 6cc1a3a654f8b..805bb39067fb3 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.51.1](https://github.com/aws/aws-cdk/compare/v2.51.0...v2.51.1) (2022-11-18) + + +### Bug Fixes + +* ECS service replacement regression ([#22978](https://github.com/aws/aws-cdk/issues/22978)) ([680e048](https://github.com/aws/aws-cdk/commit/680e048abc0c1e778b64c4e29fefcff0704f4d30)), closes [#22467](https://github.com/aws/aws-cdk/issues/22467) + ## [2.51.0](https://github.com/aws/aws-cdk/compare/v2.50.0...v2.51.0) (2022-11-18) diff --git a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts index fa8a757a4375d..e7a2b58d8855c 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts @@ -532,9 +532,16 @@ export abstract class BaseService extends Resource const disableCircuitBreakerEcsDeploymentControllerFeatureFlag = FeatureFlags.of(this).isEnabled(cxapi.ECS_DISABLE_EXPLICIT_DEPLOYMENT_CONTROLLER_FOR_CIRCUIT_BREAKER); - return disableCircuitBreakerEcsDeploymentControllerFeatureFlag ? undefined : { - type: DeploymentControllerType.ECS, - }; + if (!disableCircuitBreakerEcsDeploymentControllerFeatureFlag && props.circuitBreaker) { + // This is undesirable behavior (the controller is implicitly ECS anyway when left + // undefined, so specifying it is not necessary but DOES trigger a CFN replacement) + // but we leave it in for backwards compat. + return { + type: DeploymentControllerType.ECS, + }; + } + + return undefined; } private executeCommandLogConfiguration() { diff --git a/packages/@aws-cdk/aws-ecs/test/base-service.test.ts b/packages/@aws-cdk/aws-ecs/test/base-service.test.ts index 6e3b563cf4e1e..4aafd851984e9 100644 --- a/packages/@aws-cdk/aws-ecs/test/base-service.test.ts +++ b/packages/@aws-cdk/aws-ecs/test/base-service.test.ts @@ -1,13 +1,16 @@ +import { Template, Match } from '@aws-cdk/assertions'; +import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; import * as ecs from '../lib'; -let stack: cdk.Stack; +describe('When import an ECS Service', () => { + let stack: cdk.Stack; -beforeEach(() => { - stack = new cdk.Stack(); -}); + beforeEach(() => { + stack = new cdk.Stack(); + }); -describe('When import an ECS Service', () => { test('with serviceArnWithCluster', () => { // GIVEN const clusterName = 'cluster-name'; @@ -42,3 +45,40 @@ describe('When import an ECS Service', () => { }).toThrowError(/is not using the ARN cluster format/); }); }); + +test.each([ + /* breaker, flag => controller in template */ + /* Flag off => value present if circuitbreaker */ + [false, false, false], + [true, false, true], + /* Flag on => value never present */ + [false, true, false], + [true, true, false], +])('circuitbreaker is %p /\\ flag is %p => DeploymentController in output: %p', (circuitBreaker, flagValue, controllerInTemplate) => { + // GIVEN + const app = new App({ + context: { + '@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker': flagValue, + }, + }); + const stack = new Stack(app, 'Stack'); + const vpc = new ec2.Vpc(stack, 'Vpc'); + const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); + const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef'); + taskDefinition.addContainer('web', { + image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), + }); + + // WHEN + new ecs.FargateService(stack, 'FargateService', { + cluster, + taskDefinition, + circuitBreaker: circuitBreaker ? { } : undefined, + }); + + // THEN + const template = Template.fromStack(stack); + template.hasResourceProperties('AWS::ECS::Service', { + DeploymentController: controllerInTemplate ? { Type: 'ECS' } : Match.absent(), + }); +}); \ No newline at end of file diff --git a/version.v2.json b/version.v2.json index 13673036bf4cd..a0fe876f996a8 100644 --- a/version.v2.json +++ b/version.v2.json @@ -1,4 +1,4 @@ { - "version": "2.51.0", - "alphaVersion": "2.51.0-alpha.0" + "version": "2.51.1", + "alphaVersion": "2.51.1-alpha.0" } \ No newline at end of file