Skip to content

Commit 9fdb63f

Browse files
piradeepkElad Ben-Israel
authored andcommitted
fix(ecs): remove temporary workaround for long arn support (#3072)
Remove the temporary workaround implemented to allow long arns support: #2176 Removing the temporary workaround does not break anything for my account which has long arns enabled.
1 parent 05a49f0 commit 9fdb63f

File tree

2 files changed

+6
-36
lines changed

2 files changed

+6
-36
lines changed

packages/@aws-cdk/aws-ecs/lib/base/base-service.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ec2 = require('@aws-cdk/aws-ec2');
44
import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
55
import iam = require('@aws-cdk/aws-iam');
66
import cloudmap = require('@aws-cdk/aws-servicediscovery');
7-
import { Construct, Duration, Fn, IResolvable, IResource, Lazy, Resource, Stack } from '@aws-cdk/core';
7+
import { Construct, Duration, IResolvable, IResource, Lazy, Resource, Stack } from '@aws-cdk/core';
88
import { NetworkMode, TaskDefinition } from '../base/task-definition';
99
import { ICluster } from '../cluster';
1010
import { CfnService } from '../ecs.generated';
@@ -73,21 +73,6 @@ export interface BaseServiceProps {
7373
* @default - AWS Cloud Map service discovery is not enabled.
7474
*/
7575
readonly cloudMapOptions?: CloudMapOptions;
76-
77-
/**
78-
* Whether the new long ARN format has been enabled on ECS services.
79-
* NOTE: This assumes customer has opted into the new format for the IAM role used for the service, and is a
80-
* workaround for a current bug in Cloudformation in which the service name is not correctly returned when long ARN is
81-
* enabled.
82-
*
83-
* Old ARN format: arn:aws:ecs:region:aws_account_id:service/service-name
84-
* New ARN format: arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name
85-
*
86-
* See: https://docs.aws.amazon.com/AmazonECS/latest/userguide/ecs-resource-ids.html
87-
*
88-
* @default false
89-
*/
90-
readonly longArnEnabled?: boolean;
9176
}
9277

9378
/**
@@ -157,19 +142,12 @@ export abstract class BaseService extends Resource
157142
...additionalProps
158143
});
159144

160-
// This is a workaround for CFN bug that returns the cluster name instead of the service name when long ARN formats
161-
// are enabled for the principal in a given region.
162-
const longArnEnabled = props.longArnEnabled !== undefined ? props.longArnEnabled : false;
163-
const serviceName = longArnEnabled
164-
? Fn.select(2, Fn.split('/', this.resource.ref))
165-
: this.resource.attrName;
166-
167145
this.serviceArn = this.getResourceArnAttribute(this.resource.ref, {
168146
service: 'ecs',
169147
resource: 'service',
170148
resourceName: `${props.cluster.clusterName}/${this.physicalName}`,
171149
});
172-
this.serviceName = this.getResourceNameAttribute(serviceName);
150+
this.serviceName = this.getResourceNameAttribute(this.resource.attrName);
173151

174152
this.cluster = props.cluster;
175153

packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ export = {
273273

274274
const service = new ecs.FargateService(stack, 'Service', {
275275
cluster,
276-
taskDefinition,
277-
longArnEnabled: true
276+
taskDefinition
278277
});
279278

280279
const lb = new elbv2.ApplicationLoadBalancer(stack, "lb", { vpc });
@@ -305,16 +304,9 @@ export = {
305304
},
306305
"/",
307306
{
308-
"Fn::Select": [
309-
2,
310-
{
311-
"Fn::Split": [
312-
"/",
313-
{
314-
Ref: "ServiceD69D759B"
315-
}
316-
]
317-
}
307+
"Fn::GetAtt": [
308+
"ServiceD69D759B",
309+
"Name"
318310
]
319311
}
320312
]

0 commit comments

Comments
 (0)