Class Arn

java.lang.Object
software.amazon.awssdk.arns.Arn
All Implemented Interfaces:
ToCopyableBuilder<Arn.Builder,Arn>

public final class Arn extends Object implements ToCopyableBuilder<Arn.Builder,Arn>
The Arns generated and recognized by this code are the Arns described here: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html

The primary supported Arn format is: arn:<partition>:<service>:<region>:<account>:<resource>

resourceAsString() returns everything after the account section of the Arn as a single string.

However, the following Arn formats are supported where the values are present and well formatted through resource():

 arn:<partition>:<service>:<region>:<account>:<resourcetype>/resource
 arn:<partition>:<service>:<region>:<account>:<resourcetype>/resource/qualifier
 arn:<partition>:<service>:<region>:<account>:<resourcetype>/resource:qualifier
 arn:<partition>:<service>:<region>:<account>:<resourcetype>:resource
 arn:<partition>:<service>:<region>:<account>:<resourcetype>:resource:qualifier
 
resource() returns a ArnResource which has access to ArnResource.resourceType(), ArnResource.resource() and ArnResource.qualifier().

To parse an Arn from a string use Arn.fromString(). To convert an Arn to it's string representation use Arn.toString().

For instance, for a string s, containing a well-formed Arn the following should always be true:

 Arn theArn = Arn.fromString(s);
 s.equals(theArn.toString());
 
See Also:
  • Method Details

    • partition

      public String partition()
      Returns:
      The partition that the resource is in.
    • service

      public String service()
      Returns:
      The service namespace that identifies the AWS product (for example, Amazon S3, IAM, or Amazon RDS).
    • region

      public Optional<String> region()
      Returns:
      The Region that the resource resides in.
    • accountId

      public Optional<String> accountId()
      Returns:
      The ID of the AWS account that owns the resource, without the hyphens.
    • resource

      public ArnResource resource()
      Returns:
      ArnResource
    • resourceAsString

      public String resourceAsString()
      Returns:
      the resource as string
    • builder

      public static Arn.Builder builder()
      Returns:
      a builder for Arn.
    • fromString

      public static Arn fromString(String arn)
      Parses a given string into an Arn. The resource is accessible entirely as a string through resourceAsString(). Where correctly formatted, a parsed resource containing resource type, resource and qualifier is available through resource().
      Parameters:
      arn - - A string containing an Arn.
      Returns:
      Arn - A modeled Arn.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toBuilder

      public Arn.Builder toBuilder()
      Description copied from interface: ToCopyableBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToCopyableBuilder<Arn.Builder,Arn>
      Returns:
      a builder for type T