There doesn't seem to be a way to build a ArnResource with useful output.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
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
Contributor guide
Assessment
This issue has not been assessed yet.