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

aws-batch-alpha: EcsJobDefinition.jobDefinitionName returns the ARN #25197

Closed
gael-ft opened this issue Apr 19, 2023 · 2 comments · Fixed by #25207
Closed

aws-batch-alpha: EcsJobDefinition.jobDefinitionName returns the ARN #25197

gael-ft opened this issue Apr 19, 2023 · 2 comments · Fixed by #25207
Labels
@aws-cdk/aws-batch Related to AWS Batch bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1

Comments

@gael-ft
Copy link

gael-ft commented Apr 19, 2023

Describe the bug

In EcsJobDefinition, looks like at the end of the constructor you override the field "jobDefinitionName" with the CfnJobDefinition ref.
Meaning if we try to access it later, we'll get a different value of what it has been created with.

Expected Behavior

EcsJobDefinition.jobDefinitionName to return the CfnJobDefinition.jobDefinitionName and not the ARN of the resource

Current Behavior

EcsJobDefinition.jobDefinitionNam returns the ARN (+ revision)

Reproduction Steps

const jobDef = new EcsJobDefinition(this, 'Resource', {
  // ...
  jobDefinitionName: 'toto'
  //...
});

jobDef.jobDefinitionName; // a Token which resolves to arn:aws:...:job-definition:toto:1

Possible Solution

Just remove this.jobDefinitionName = this.getResourceNameAttribute(resource.ref);

github link

Additional Information/Context

No response

CDK CLI Version

2.74.0 (build 70e2a33)

Framework Version

No response

Node.js Version

v16.13.0

OS

MacOS

Language

Typescript

Language Version

No response

Other information

No response

@gael-ft gael-ft added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 19, 2023
@github-actions github-actions bot added the @aws-cdk/aws-batch Related to AWS Batch label Apr 19, 2023
@peterwoodworth
Copy link
Contributor

Similar to #25093, ref returns the arn instead of the name. Here's the actual fix in the linked PR for the similar issue:

this.jobQueueName = Stack.of(this).splitArn(this.jobQueueArn, ArnFormat.SLASH_RESOURCE_NAME).resourceName!;

We'll want to do the exact same thing, given this is the same exact bug just on a different construct. We don't want to remove this altogether because then customers who don't specify the name cannot reference it. Thanks for reporting!

@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 19, 2023
lpizzinidev added a commit to lpizzinidev/aws-cdk that referenced this issue Apr 20, 2023
lpizzinidev added a commit to lpizzinidev/aws-cdk that referenced this issue Apr 21, 2023
mergify bot added a commit to lpizzinidev/aws-cdk that referenced this issue Apr 24, 2023
@mergify mergify bot closed this as completed in #25207 Apr 24, 2023
mergify bot pushed a commit that referenced this issue Apr 24, 2023
`EcsJobDefinition.jobDefinitionName` returns the ARN.
This fix will return the name.

Closes #25197.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-batch Related to AWS Batch bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants