From 1e8105315b022eb521551e8328c1fe423d47aa8c Mon Sep 17 00:00:00 2001 From: Penghao He Date: Thu, 22 Aug 2019 17:58:43 -0700 Subject: [PATCH] feat(ecs): support ecs tag propagation and ecs managed tags (#3420) * Added two new properties for ECS Service * Fix comment for PropagateTags * Remove Name-path tag for ECS Service * Fix properties discription * Add unit test and fix integ test * Fix integ test for ecs-pattern * fix pipeline ecs integ test * Update snapshot for synth.test.js * Change enum type name and add no_propagate option * Change enum name and fix no propagate setting in fargate service * Change default value for propagateTags in comment * Add design doc * Fix comments and tests and refactor propagatetags logic * Fix propagateTags and enableECSManagedTags comments * Sync design doc --- design/aws-ecs/aws-ecs-tagging-support.md | 266 ++++++++++++++++++ .../integ.pipeline-ecs-deploy.expected.json | 4 +- .../fargate/integ.asset-image.expected.json | 4 +- .../fargate/integ.executionrole.expected.json | 4 +- .../fargate/integ.l3-autocreate.expected.json | 8 +- .../fargate/integ.l3-vpconly.expected.json | 12 +- .../test/fargate/integ.l3.expected.json | 2 + .../@aws-cdk/aws-ecs/lib/base/base-service.ts | 39 +++ .../@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts | 14 +- .../aws-ecs/lib/fargate/fargate-service.ts | 12 +- .../test/ec2/integ.lb-awsvpc-nw.expected.json | 4 +- .../test/ec2/integ.lb-bridge-nw.expected.json | 4 +- .../test/ec2/integ.sd-awsvpc-nw.expected.json | 2 + .../test/ec2/integ.sd-bridge-nw.expected.json | 2 + .../aws-ecs/test/ec2/test.ec2-service.ts | 6 +- .../fargate/integ.lb-awsvpc-nw.expected.json | 4 +- .../test/fargate/test.fargate-service.ts | 4 +- .../test/__snapshots__/synth.test.js.snap | 2 + 18 files changed, 376 insertions(+), 17 deletions(-) create mode 100644 design/aws-ecs/aws-ecs-tagging-support.md diff --git a/design/aws-ecs/aws-ecs-tagging-support.md b/design/aws-ecs/aws-ecs-tagging-support.md new file mode 100644 index 0000000000000..b783f7ffb0cd2 --- /dev/null +++ b/design/aws-ecs/aws-ecs-tagging-support.md @@ -0,0 +1,266 @@ +# AWS ECS - Tagging Support + +Amazon ECS supports tagging for all the ECS resources (see [here](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html)). Note that ECS provides a property of ECS service named `PropagateTags` to support propagating tags from either task definitions or services to tasks (tasks cannot be tagged using CDK without setting this parameter). Currently this property is not supported in CDK so that the tags are not propagated by default. + +In addition, `EnableECSManagedTags` is provided as another property so that ECS managed tags can be supported and used to tag ECS tasks. However, currently users cannot set `EnableECSManagedTags` and the default value is `false`. + +## General approach + +The new `BaseService` class will include two more base properties: + +* propagateTags +* enableECSManagedTags + +`propagateTags` specifies whether to propagate the tags from the task definition or the service to ECS tasks and `enableECSManagedTags` specifies whether to enable Amazon ECS managed tags for the tasks within the service. Also, for `Ec2Service` and `FargateService` we will have the corresponding two new properties exposed to users: + +* propagateTaskTagsFrom (`SERVICE` | `TASK_DEFINITION` | `NONE`) +* enableECSManagedTags (`true` | `false`) + +\*`propagateTaskTagsFrom` has a default value of `SERVICE` and `enableECSManagedTags` has a default value of `true` \ +\*`propagateTaskTagsFrom` takes enum type `PropagatedTagSource`.\ +\*Note that the reason why we define `propagateTaskTagsFrom` is because we want to have a different name for `propagateTags` to eliminate the naming confusion. + +In addition, for the `aws-ecs-patterns` module we want it to be convenient, but in this case, the `aws-ecs-patterns` module is opinionated. As a result, we want `SERVICE` and `true` to be set by default, not just for constructs in the `aws-ecs-patterns` module. + +## Code changes + +Given the above, we should make the following changes on ECS: + + 1. Add an enum type `PropagatedTagSource` to support `propagateTaskTagsFrom`. + 2. Add `propagateTags` and `enableECSManagedTags` properties to `BaseServiceOptions`. + 3. Add `propagateTaskTagsFrom` properties to `Ec2ServiceProps` and `FargateServiceProps`. + +### Part 1: Add enum type `PropagatedTagSource` to support `propagateTaskTagsFrom` + +``` ts +export enum PropagatedTagSource { + /** + * Propagate tags from service + */ + SERVICE = 'SERVICE', + + /** + * Propagate tags from task definition + */ + TASK_DEFINITION = 'TASK_DEFINITION', + + /** + * Do not propagate + */ + NONE = 'NONE' +} +``` + +### Part 2: Add `propagateTags` and `enableECSManagedTags` properties to `BaseServiceOptions` + +```ts +export interface BaseServiceOptions { + + ... + + /** + * Specifies whether to propagate the tags from the task definition or the service to the tasks in the service + * + * Valid values are: PropagateTagFromType.SERVICE or PropagateTagFromType.TASK_DEFINITION + * + * @default - PropagatedTagSource.SERVICE if EC2 or Fargate Service, otherwise PropagatedTagSource.NONE. + */ + readonly propagateTags?: PropagatedTagSource; + + /** + * Specifies whether to enable Amazon ECS managed tags for the tasks within the service. For more information, see + * [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) + * + * @default true + */ + readonly enableECSManagedTags?: boolean; +} +``` + +``` ts +/** + * The base class for Ec2Service and FargateService services. + */ +export abstract class BaseService extends Resource + implements IService, elbv2.IApplicationLoadBalancerTarget, elbv2.INetworkLoadBalancerTarget { + + ... + + /** + * Constructs a new instance of the BaseService class. + */ + constructor(scope: Construct, + id: string, + props: BaseServiceProps, + additionalProps: any, + taskDefinition: TaskDefinition) { + + ... + + this.resource = new CfnService(this, "Service", { + desiredCount: props.desiredCount, + serviceName: this.physicalName, + loadBalancers: Lazy.anyValue({ produce: () => this.loadBalancers }), + deploymentConfiguration: { + maximumPercent: props.maxHealthyPercent || 200, + minimumHealthyPercent: props.minHealthyPercent === undefined ? 50 : props.minHealthyPercent + }, + propagateTags: props.propagateTags === PropagatedTagSource.NONE ? undefined : props.propagateTags, + enableEcsManagedTags: props.enableECSManagedTags === undefined ? true : props.enableECSManagedTags, + launchType: props.launchType, + healthCheckGracePeriodSeconds: this.evaluateHealthGracePeriod(props.healthCheckGracePeriod), + /* role: never specified, supplanted by Service Linked Role */ + networkConfiguration: Lazy.anyValue({ produce: () => this.networkConfiguration }), + serviceRegistries: Lazy.anyValue({ produce: () => this.serviceRegistries }), + ...additionalProps + }); + + ... + + } + + ... + +} +``` + +### Part 3: Add `propagateTaskTagsFrom` properties to `Ec2ServiceProps` and `FargateServiceProps` + +``` ts +export interface Ec2ServiceProps extends BaseServiceOptions { + + ... + + /** + * Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. + * Tags can only be propagated to the tasks within the service during service creation. + * + * @default PropagatedTagSource.SERVICE + */ + readonly propagateTaskTagsFrom?: PropagatedTagSource; +} +``` + +``` ts +/** + * This creates a service using the EC2 launch type on an ECS cluster. + * + * @resource AWS::ECS::Service + */ +export class Ec2Service extends BaseService implements IEc2Service, elb.ILoadBalancerTarget { + + ... + + /** + * Constructs a new instance of the Ec2Service class. + */ + constructor(scope: Construct, id: string, props: Ec2ServiceProps) { + + ... + + super(scope, id, { + ...props, + // If daemon, desiredCount must be undefined and that's what we want. Otherwise, default to 1. + desiredCount: props.daemon || props.desiredCount !== undefined ? props.desiredCount : 1, + maxHealthyPercent: props.daemon && props.maxHealthyPercent === undefined ? 100 : props.maxHealthyPercent, + minHealthyPercent: props.daemon && props.minHealthyPercent === undefined ? 0 : props.minHealthyPercent, + launchType: LaunchType.EC2, + propagateTags: props.propagateTaskTagsFrom === undefined ? PropagatedTagSource.SERVICE : props.propagateTaskTagsFrom, + enableECSManagedTags: props.enableECSManagedTags, + }, + { + cluster: props.cluster.clusterName, + taskDefinition: props.taskDefinition.taskDefinitionArn, + placementConstraints: Lazy.anyValue({ produce: () => this.constraints }, { omitEmptyArray: true }), + placementStrategies: Lazy.anyValue({ produce: () => this.strategies }, { omitEmptyArray: true }), + schedulingStrategy: props.daemon ? 'DAEMON' : 'REPLICA', + }, props.taskDefinition); + + ... + + } + + ... + +} +``` + +``` ts +export interface FargateServiceProps extends BaseServiceOptions { + + ... + + /** + * Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. + * Tags can only be propagated to the tasks within the service during service creation. + * + * @default PropagatedTagSource.SERVICE + */ + readonly propagateTaskTagsFrom?: PropagatedTagSource; +} +``` + + +``` ts +/** + * This creates a service using the Fargate launch type on an ECS cluster. + * + * @resource AWS::ECS::Service + */ +export class FargateService extends BaseService implements IFargateService { + + ... + + /** + * Constructs a new instance of the FargateService class. + */ + constructor(scope: cdk.Construct, id: string, props: FargateServiceProps) { + + ... + + super(scope, id, { + ...props, + desiredCount: props.desiredCount !== undefined ? props.desiredCount : 1, + launchType: LaunchType.FARGATE, + propagateTags: props.propagateTaskTagsFrom === undefined ? PropagatedTagSource.SERVICE : props.propagateTaskTagsFrom, + enableECSManagedTags: props.enableECSManagedTags, + }, { + cluster: props.cluster.clusterName, + taskDefinition: props.taskDefinition.taskDefinitionArn, + platformVersion: props.platformVersion, + }, props.taskDefinition); + + ... + + } + + ... + +} +``` + +The `Ec2Service` and `FargateService` constructs will have two new properties: + +* propagateTaskTagsFrom - Propagate tags from either ECS Task Definition or Service to Task. +* enableECSManagedTags - Enable ECS managed tags to ECS Task. + +An example use case to create an EC2/Fargate service: + +```ts +// Create Service +const service = new ecs.Ec2Service(stack, "Service", { + cluster, + taskDefinition, + propagateTaskTagsFrom: ecs.PropagatedTagSource.TASK_DEFINITION, + enableECSManagedTags: true, +}); +``` + +``` ts +const service = new ecs.FargateService(stack, "Service", { + cluster, + taskDefinition, + propagateTaskTagsFrom: ecs.PropagatedTagSource.TASK_DEFINITION, + enableECSManagedTags: false, +}); +``` diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json index a9cfee49efd07..7d388dac81acb 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json @@ -272,7 +272,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" } }, "FargateServiceSecurityGroup0A0E79CB": { diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json index fe095f05c3227..b7e0f7670f1b6 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json @@ -776,7 +776,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "FargateServiceLBPublicListenerECSGroupBE57E081", diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.executionrole.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.executionrole.expected.json index 43713ef37810e..a5477069c7197 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.executionrole.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.executionrole.expected.json @@ -606,7 +606,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "L3LBPublicListenerECSGroup648EEA11", diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-autocreate.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-autocreate.expected.json index 31118fc10e949..4f9967df7547b 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-autocreate.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-autocreate.expected.json @@ -257,7 +257,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "L3LBPublicListenerECSGroup648EEA11", @@ -904,7 +906,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "L3bLBPublicListenerECSGroup0070C5CA", diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-vpconly.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-vpconly.expected.json index 29674d69aeb73..0590455fe1fd2 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-vpconly.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3-vpconly.expected.json @@ -600,7 +600,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "L3LBPublicListenerECSGroup648EEA11", @@ -1247,7 +1249,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "L3bLBPublicListenerECSGroup0070C5CA", @@ -1551,7 +1555,9 @@ } ] } - } + }, + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE" }, "DependsOn": [ "L3cLBPublicListenerECSGroup62D7B705", diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.expected.json index 19ea5d5a8b942..730e4617fe0f9 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.expected.json @@ -583,6 +583,8 @@ } } ], + "EnableECSManagedTags": true, + "PropagateTags": "SERVICE", "NetworkConfiguration": { "AwsvpcConfiguration": { "AssignPublicIp": "DISABLED", 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 6e84fd8fc84c5..c9e7ece92de70 100644 --- a/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/base/base-service.ts @@ -77,6 +77,23 @@ export interface BaseServiceOptions { * @default - AWS Cloud Map service discovery is not enabled. */ readonly cloudMapOptions?: CloudMapOptions; + + /** + * Specifies whether to propagate the tags from the task definition or the service to the tasks in the service + * + * Valid values are: PropagateTagFromType.SERVICE, PropagateTagFromType.TASK_DEFINITION or PropagateTagFromType.NONE + * + * @default - PropagatedTagSource.SERVICE if EC2 or Fargate Service, otherwise PropagatedTagSource.NONE. + */ + readonly propagateTags?: PropagatedTagSource; + + /** + * Specifies whether to enable Amazon ECS managed tags for the tasks within the service. For more information, see + * [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) + * + * @default true + */ + readonly enableECSManagedTags?: boolean; } /** @@ -173,6 +190,8 @@ export abstract class BaseService extends Resource maximumPercent: props.maxHealthyPercent || 200, minimumHealthyPercent: props.minHealthyPercent === undefined ? 50 : props.minHealthyPercent }, + propagateTags: props.propagateTags === PropagatedTagSource.NONE ? undefined : props.propagateTags, + enableEcsManagedTags: props.enableECSManagedTags === undefined ? true : props.enableECSManagedTags, launchType: props.launchType, healthCheckGracePeriodSeconds: this.evaluateHealthGracePeriod(props.healthCheckGracePeriod), /* role: never specified, supplanted by Service Linked Role */ @@ -496,4 +515,24 @@ export enum LaunchType { * The service will be launched using the FARGATE launch type */ FARGATE = 'FARGATE' +} + +/** + * Propagate tags from either service or task definition + */ +export enum PropagatedTagSource { + /** + * Propagate tags from service + */ + SERVICE = 'SERVICE', + + /** + * Propagate tags from task definition + */ + TASK_DEFINITION = 'TASK_DEFINITION', + + /** + * Do not propagate + */ + NONE = 'NONE' } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts index 49615cd008f33..ea6af62ead6a8 100644 --- a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import elb = require('@aws-cdk/aws-elasticloadbalancing'); import { Construct, Lazy, Resource } from '@aws-cdk/core'; -import { BaseService, BaseServiceOptions, IService, LaunchType } from '../base/base-service'; +import { BaseService, BaseServiceOptions, IService, LaunchType, PropagatedTagSource } from '../base/base-service'; import { NetworkMode, TaskDefinition } from '../base/task-definition'; import { CfnService } from '../ecs.generated'; import { PlacementConstraint, PlacementStrategy } from '../placement'; @@ -70,6 +70,14 @@ export interface Ec2ServiceProps extends BaseServiceOptions { * @default false */ readonly daemon?: boolean; + + /** + * Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. + * Tags can only be propagated to the tasks within the service during service creation. + * + * @default PropagatedTagSource.SERVICE + */ + readonly propagateTaskTagsFrom?: PropagatedTagSource; } /** @@ -125,8 +133,10 @@ export class Ec2Service extends BaseService implements IEc2Service, elb.ILoadBal // If daemon, desiredCount must be undefined and that's what we want. Otherwise, default to 1. desiredCount: props.daemon || props.desiredCount !== undefined ? props.desiredCount : 1, maxHealthyPercent: props.daemon && props.maxHealthyPercent === undefined ? 100 : props.maxHealthyPercent, - minHealthyPercent: props.daemon && props.minHealthyPercent === undefined ? 0 : props.minHealthyPercent , + minHealthyPercent: props.daemon && props.minHealthyPercent === undefined ? 0 : props.minHealthyPercent, launchType: LaunchType.EC2, + propagateTags: props.propagateTaskTagsFrom === undefined ? PropagatedTagSource.SERVICE : props.propagateTaskTagsFrom, + enableECSManagedTags: props.enableECSManagedTags, }, { cluster: props.cluster.clusterName, diff --git a/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts b/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts index a79e9da935177..078ab6368184a 100644 --- a/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import cdk = require('@aws-cdk/core'); import { Construct, Resource } from '@aws-cdk/core'; -import { BaseService, BaseServiceOptions, IService, LaunchType } from '../base/base-service'; +import { BaseService, BaseServiceOptions, IService, LaunchType, PropagatedTagSource } from '../base/base-service'; import { TaskDefinition } from '../base/task-definition'; /** @@ -48,6 +48,14 @@ export interface FargateServiceProps extends BaseServiceOptions { * @default Latest */ readonly platformVersion?: FargatePlatformVersion; + + /** + * Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. + * Tags can only be propagated to the tasks within the service during service creation. + * + * @default PropagatedTagSource.SERVICE + */ + readonly propagateTaskTagsFrom?: PropagatedTagSource; } /** @@ -86,6 +94,8 @@ export class FargateService extends BaseService implements IFargateService { ...props, desiredCount: props.desiredCount !== undefined ? props.desiredCount : 1, launchType: LaunchType.FARGATE, + propagateTags: props.propagateTaskTagsFrom === undefined ? PropagatedTagSource.SERVICE : props.propagateTaskTagsFrom, + enableECSManagedTags: props.enableECSManagedTags, }, { cluster: props.cluster.clusterName, taskDefinition: props.taskDefinition.taskDefinitionArn, diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json index d0979e122eed1..9e1ebaf6764d0 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json @@ -858,7 +858,9 @@ ] } }, - "SchedulingStrategy": "REPLICA" + "SchedulingStrategy": "REPLICA", + "PropagateTags": "SERVICE", + "EnableECSManagedTags": true }, "DependsOn": [ "LBPublicListenerECSGroupD6A32205", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json index 8152f54473c3f..fb4f2d2e4ccb1 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json @@ -859,7 +859,9 @@ } } ], - "SchedulingStrategy": "REPLICA" + "SchedulingStrategy": "REPLICA", + "PropagateTags": "SERVICE", + "EnableECSManagedTags": true }, "DependsOn": [ "LBPublicListenerECSGroupD6A32205", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json index d91e20b04d502..51eada3b0ae68 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json @@ -859,6 +859,8 @@ } }, "SchedulingStrategy": "REPLICA", + "PropagateTags": "SERVICE", + "EnableECSManagedTags": true, "ServiceRegistries": [ { "RegistryArn": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json index 24d16697146db..dc64e8f7411dc 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json @@ -838,6 +838,8 @@ "DesiredCount": 1, "LaunchType": "EC2", "SchedulingStrategy": "REPLICA", + "PropagateTags": "SERVICE", + "EnableECSManagedTags": true, "ServiceRegistries": [ { "ContainerName": "frontend", diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts index 3d58b9294dccf..87230b70e54dd 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts @@ -7,7 +7,7 @@ import cdk = require('@aws-cdk/core'); import { Test } from 'nodeunit'; import ecs = require('../../lib'); import { BinPackResource, BuiltInAttributes, ContainerImage, NetworkMode } from '../../lib'; -import { LaunchType } from '../../lib/base/base-service'; +import { LaunchType, PropagatedTagSource } from '../../lib/base/base-service'; import { PlacementConstraint, PlacementStrategy } from '../../lib/placement'; export = { @@ -44,7 +44,9 @@ export = { }, DesiredCount: 1, LaunchType: LaunchType.EC2, - SchedulingStrategy: "REPLICA" + SchedulingStrategy: "REPLICA", + EnableECSManagedTags: true, + PropagateTags: PropagatedTagSource.SERVICE })); test.done(); diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json index 97ac671ec78ef..4c39dbe36c02b 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.expected.json @@ -439,7 +439,9 @@ } ] } - } + }, + "PropagateTags": "SERVICE", + "EnableECSManagedTags": true }, "DependsOn": [ "LBPublicListenerFargateGroup5EE2FBAF", diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts index df8c20de5059f..545120df5ee85 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts @@ -8,7 +8,7 @@ import cdk = require('@aws-cdk/core'); import { Test } from 'nodeunit'; import ecs = require('../../lib'); import { ContainerImage } from '../../lib'; -import { LaunchType } from '../../lib/base/base-service'; +import { LaunchType, PropagatedTagSource } from '../../lib/base/base-service'; export = { "When creating a Fargate Service": { @@ -42,6 +42,8 @@ export = { }, DesiredCount: 1, LaunchType: LaunchType.FARGATE, + EnableECSManagedTags: true, + PropagateTags: PropagatedTagSource.SERVICE, NetworkConfiguration: { AwsvpcConfiguration: { AssignPublicIp: "DISABLED", diff --git a/packages/decdk/test/__snapshots__/synth.test.js.snap b/packages/decdk/test/__snapshots__/synth.test.js.snap index 9ad8747ce87da..1332df02cd1ae 100644 --- a/packages/decdk/test/__snapshots__/synth.test.js.snap +++ b/packages/decdk/test/__snapshots__/synth.test.js.snap @@ -646,6 +646,7 @@ Object { "MinimumHealthyPercent": 50, }, "DesiredCount": 1, + "EnableECSManagedTags": true, "LaunchType": "FARGATE", "NetworkConfiguration": Object { "AwsvpcConfiguration": Object { @@ -665,6 +666,7 @@ Object { ], }, }, + "PropagateTags": "SERVICE", "TaskDefinition": Object { "Ref": "MyTaskDef01F0D39B", },