aws-sdk-java-v2 icon indicating copy to clipboard operation
aws-sdk-java-v2 copied to clipboard

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

Open youngm opened this issue 4 years ago • 2 comments

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.

  • [X] 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 avatar Apr 16 '21 21:04 youngm

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 avatar Apr 21 '21 21:04 debora-ito

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

rtatton avatar Dec 20 '23 16:12 rtatton

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.

github-actions[bot] avatar Mar 07 '24 16:03 github-actions[bot]