Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

tobytipton
Copy link
Contributor

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

Verified

This commit was signed with the committer’s verified signature.
connor4312 Connor Peet
@gitpod-io
Copy link

gitpod-io bot commented Jan 12, 2022

@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Jan 12, 2022
Copy link
Contributor

@madeline-k madeline-k left a 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

Comment on lines 50 to 52
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];
Copy link
Contributor

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.

Copy link
Contributor

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', () => {
Copy link
Contributor

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', () => {
Copy link
Contributor

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

Comment on lines 79 to 84
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);
Copy link
Contributor

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({
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 🙂.

Copy link
Contributor

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?

@mergify mergify bot dismissed madeline-k’s stale review January 25, 2022 13:37

Pull request has been modified.

@rix0rrr rix0rrr added bug This issue is a bug. p1 and removed @aws-cdk/aws-ecs Related to Amazon Elastic Container labels Mar 4, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the base branch from v1-main to main July 6, 2022 22:26
@github-actions github-actions bot added the effort/small Small work item – less than a day of effort label Jul 6, 2022
@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Jul 29, 2022

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 3d82774
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a 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.

@aws-cdk-automation
Copy link
Collaborator

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.

@aws-cdk-automation
Copy link
Collaborator

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.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(ecs): Base Service tokenized Service Arn doesn't contain region or account.
6 participants