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

There doesn't seem to be a way to build a ArnResource with useful output. #2453

Open
spiffy2manics opened this issue May 3, 2021 · 1 comment
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@spiffy2manics
Copy link

spiffy2manics commented May 3, 2021

The ArnResource.toString() returns - this.resourceType + ":" + this.resource + ":" + this.qualifier
However, the resourceType isn't always required and neither is the qualifer. If these values are not provided, you end up with "null:resource:null". This is particularly an issue with things like lambda arns, where you can't use the resource, or you get "function:my_lambda:null", which makes the ArnResource almost completely useless.

ArnResource resource = ArnResource.builder().resourceType("function").resource("my_lambda").build();
Arn arn = Arn.builder()
.partition("aws")
.service("lambda")
.region(oktaRegion)
.accountId(oktaAccount)
.resource(resource.toString()) //Does not work
.build();

Also, there are several resources where the resourceType is followed by a slash, like with roles, where again, this resource builder is not helpful or even useful.

Describe the bug

The ArnResource.toString() function does not return a useful value.

Expected Behavior

I would expect the ArnResource to return something meaningful so that the Arn.Builder is able to use the output.
I would also expect the Arn.Builder to accept the ArnResource as an input, instead of being required to convert it to a string.
I would also expect the ArnResource.Builder (or another implementation of this) to be able to understand how to build a lambda or role resource, or other variants, without having to specify all of the values where they are already known and constant ("function:", "role/", etc).

Current Behavior

ArnResource.builder().resource("lambda").build().toString() returns "null:lambda:null", when it should be either "function:lambda" or at least just "lambda".
ArnResource.builder().resourceType("role").resource("my_role").build().toString() returns "role:my_role:null", when it should be "role/my_role".

Steps to Reproduce

System.out.println(ArnResource.builder().resource("lambda").build().toString());

Possible Solution

Update the toString() method to not output the null values.
Create other implementations, such as a LambdaResource and RoleResource, which have known values.

Context

I am trying to use the tools given in the SDK to build my ARNs, but these are not extremely useful at the moment.

Your Environment

  • AWS Java SDK version used: 2.16.13
  • JDK version used: 11
  • Operating System and version: Windows 10
@spiffy2manics spiffy2manics added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 3, 2021
@spiffy2manics spiffy2manics changed the title There doesn't seem to be a way to build a ArnResource with a useful output. There doesn't seem to be a way to build a ArnResource with useful output. May 3, 2021
@debora-ito
Copy link
Member

@spiffy2manics thank you for your detailed report. Related to #2416.

We've had a pull request that added some improvements to ArnResource, I'm not sure why it wasn't merged, I'll try to give it traction.

@debora-ito debora-ito removed the needs-triage This issue or PR still needs to be triaged. label May 4, 2021
@yasminetalby yasminetalby added the p2 This is a standard priority issue label Nov 12, 2022
aws-sdk-java-automation pushed a commit that referenced this issue Apr 11, 2023
…93728dfd8

Pull request: release <- staging/56f3828c-d139-464d-b157-83f93728dfd8
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

No branches or pull requests

3 participants