fix(ecs): fix serviceArn token to have region/account in serviceArn#18382
fix(ecs): fix serviceArn token to have region/account in serviceArn#18382tobytipton wants to merge 5 commits intoaws:mainfrom
Conversation
madeline-k
left a comment
There was a problem hiding this comment.
See my comment on #18140 (comment) as well
| name = stack.splitArn(arn, ArnFormat.SLASH_RESOURCE_NAME).resourceName as string; | ||
| const resourceName = stack.splitArn(arn, ArnFormat.SLASH_RESOURCE_NAME).resourceName as string; | ||
| const resourceNameSplit = resourceName.split('/'); | ||
| name = resourceNameSplit.length === 1 ? resourceName : resourceNameSplit[1]; |
There was a problem hiding this comment.
This part is overlapping with the changes that @jumic is making in this PR https://github.com/aws/aws-cdk/pull/18140/files.
Let's keep this PR to only changing serviceArn public property for Ec2 and Fargate Service that are created with the BaseService constructor. And we can leave the necessary changes for the serviceArn and serviceName public props for fromXXX() services to @jumic 's PR.
There was a problem hiding this comment.
Same comment for the changes in ec2-service.ts and fargate-service.ts
|
|
||
| describe('When import an EC2 Service', () => { | ||
| test('with serviceArn', () => { | ||
| test('with old serviceArn', () => { |
There was a problem hiding this comment.
Testing the new vs old service ARN format should be a part of #18140. It is out of scope for this one.
|
|
||
| describe('When import a Fargate Service', () => { | ||
| test('with serviceArn', () => { | ||
| test('with old serviceArn', () => { |
There was a problem hiding this comment.
These tests are also out of scope
| const importService = ecs.Ec2Service.fromEc2ServiceAttributes(stack, 'importService', { | ||
| cluster: cluster, | ||
| serviceArn: service.serviceArn, | ||
| }); | ||
| expect(importService.serviceArn).toContain(`service/${cluster.clusterName}/${service.serviceName}`); | ||
| expect(importService.serviceName).toEqual(service.serviceName); |
There was a problem hiding this comment.
this should be it's own test once the fromXXX() issues are fixed in #18140
|
|
||
| this.serviceArn = this.getResourceArnAttribute(this.resource.ref, { | ||
| this.serviceName = this.getResourceNameAttribute(this.resource.attrName); | ||
| this.serviceArn = Stack.of(this).formatArn({ |
There was a problem hiding this comment.
Note: this needs to keep using the getResourceArnAttribute() helper - otherwise, things will break.
There was a problem hiding this comment.
Is there a better approach? The getResourceArnAttribute() generates a token which can't be parsed for region, account, clusterName or serviceName. Which means when creating the new service to get the ARN which can be leveraged to be imported you have to do this to generate the code.
There was a problem hiding this comment.
The problem here is most likely the ${cluster.clusterName} part we are referencing here. We are investigating right now to confirm that 🙂.
There was a problem hiding this comment.
@madeline-k did you ever conclude your investigation about that suspicious ${cluster.clusterName} expression causing problems?
Pull request has been modified.
|
@Mergifyio update |
✅ Branch has been successfully updated |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
@tobytipton We'll need the build to be passing before we can provide another review of this. It looks like your update broke the tests in another package so please take a look at those.
Additionally, please make sure that your PR title confirms to the conventional commit standard (fix, feat, chore) and that it is written in a style that will reflect correctly in the change log (See Contributing Guide, Pull Requests). In a fix, the title should state the problem that is being fixed, now what the fix itself is.
|
This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
|
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
This fixes #18246 by changing the serviceArn to token each part vs creating one token which allows for using the serviceArn to get the environment.
Fixes #18246
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license