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

It would be nice if there were a way to create a canonical arn String from an Arn instance #2416

Closed
1 task done
youngm opened this issue Apr 16, 2021 · 3 comments · Fixed by #4944
Closed
1 task done
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@youngm
Copy link

youngm commented Apr 16, 2021

I love the software.amazon.awssdk.arns.Arn class that exists and use it heavily. with fromString(). However, the toString() method does not create an arn that can then be consumed with fromString() and be equal to eachother if fields are missing.

System.out.println(
        Arn.builder().resource("groovy").partition("partition").service("service").build());

Produces the output:

arn:partition:service:null:null:groovy

which when parsed again produces null values for region and such.

Describe the Feature

It would be nice if there were a method (perhaps toString()?) that could produce a properly formatted arn string taking into account null values.

  • I may be able to implement this feature request

I'd like to have some guidance though. Should I just modify toString() or make another method?

My Arn syntax knowledge isn't great. Can I just put an empty value between the : for all the non-required fields?

@youngm youngm added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 16, 2021
@debora-ito
Copy link
Member

Hi @youngm, thank you for reaching out.

The nulls in arn:partition:service:null:null:groovy do not look good, I'm changing this to a bug report.
Yes, it would be empty values, e.g. this is a valid Arn for an S3 bucket called my-bucket: arn:aws:s3:::my-bucket.

Changing the current toString() method should work.

@debora-ito debora-ito added bug This issue is a bug. and removed feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 21, 2021
@yasminetalby yasminetalby added the p2 This is a standard priority issue label Nov 12, 2022
aws-sdk-java-automation added a commit that referenced this issue Mar 13, 2023
…637ac8675

Pull request: release <- staging/f326f82a-b566-4ebc-8a30-608637ac8675
@rtatton
Copy link

rtatton commented Dec 20, 2023

@debora-ito Is there any plan to fix this?

Madrigal pushed a commit to Madrigal/aws-sdk-java-v2 that referenced this issue Feb 20, 2024
cenedhryn added a commit that referenced this issue Mar 7, 2024
…ountId (#4944)

* Modify ARN toString to print a valid ARN when there's no region or accountId

Fixes #2416

* Run  script

---------

Co-authored-by: Luis Madrigal 🐧 <lmadrig@amazon.com>
Co-authored-by: Anna-Karin Salander <salande@amazon.com>
Copy link

github-actions bot commented Mar 7, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

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. p2 This is a standard priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants