-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ecs): fix serviceArn token to have region/account in serviceArn #18382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment for the changes in ec2-service.ts
and fargate-service.ts
@@ -3280,24 +3307,61 @@ describe('ec2 service', () => { | |||
}); | |||
|
|||
describe('When import an EC2 Service', () => { | |||
test('with serviceArn', () => { | |||
test('with old serviceArn', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing the new vs old service ARN format should be a part of #18140. It is out of scope for this one.
@@ -2111,24 +2111,64 @@ describe('fargate service', () => { | |||
}); | |||
|
|||
describe('When import a Fargate Service', () => { | |||
test('with serviceArn', () => { | |||
test('with old serviceArn', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be it's own test once the fromXXX() issues are fixed in #18140
@@ -426,12 +426,12 @@ export abstract class BaseService extends Resource | |||
Annotations.of(this).addWarning('taskDefinition and launchType are blanked out when using external deployment controller.'); | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this needs to keep using the getResourceArnAttribute()
helper - otherwise, things will break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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