Class Arn
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
extractResourceName
(String arn, String resourceType) Extract the full resource name from an ARN.static String
format
(ArnComponents components) Creates an ARN from components.static String
format
(ArnComponents components, Stack stack) Creates an ARN from components.static ArnComponents
Deprecated.use split insteadstatic ArnComponents
Deprecated.use split insteadstatic ArnComponents
Deprecated.use split insteadstatic ArnComponents
Splits the provided ARN into its components.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Arn
protected Arn(software.amazon.jsii.JsiiObjectRef objRef) -
Arn
protected Arn(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
extractResourceName
@Stability(Stable) @NotNull public static String extractResourceName(@NotNull String arn, @NotNull String resourceType) Extract the full resource name from an ARN.Necessary for resource names (paths) that may contain the separator, like
arn:aws:iam::111111111111:role/path/to/role/name
.Only works if we statically know the expected
resourceType
beforehand, since we're going to use that to split the string on ':/' (and take the right-hand side). We can't extract the 'resourceType' from the ARN at hand, because CloudFormation Expressions only allow literals in the 'separator' argument to
{ Fn::Split }
, and so it can't be{ Fn::Select: [5, { Fn::Split: [':', ARN] }}
.Only necessary for ARN formats for which the type-name separator is
/
.- Parameters:
arn
- This parameter is required.resourceType
- This parameter is required.
-
format
@Stability(Stable) @NotNull public static String format(@NotNull ArnComponents components, @Nullable Stack stack) Creates an ARN from components.If
partition
,region
oraccount
are not specified, the stack's partition, region and account will be used.If any component is the empty string, an empty string will be inserted into the generated ARN at the location that component corresponds to.
The ARN will be formatted as follows:
arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
The required ARN pieces that are omitted will be taken from the stack that the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope can be 'undefined'.
- Parameters:
components
- This parameter is required.stack
-
-
format
Creates an ARN from components.If
partition
,region
oraccount
are not specified, the stack's partition, region and account will be used.If any component is the empty string, an empty string will be inserted into the generated ARN at the location that component corresponds to.
The ARN will be formatted as follows:
arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
The required ARN pieces that are omitted will be taken from the stack that the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope can be 'undefined'.
- Parameters:
components
- This parameter is required.
-
parse
@Stability(Deprecated) @Deprecated @NotNull public static ArnComponents parse(@NotNull String arn, @Nullable String sepIfToken, @Nullable Boolean hasName) Deprecated.use split instead(deprecated) Given an ARN, parses it and returns components.IF THE ARN IS A CONCRETE STRING...
...it will be parsed and validated. The separator (
sep
) will be set to '/' if the 6th component includes a '/', in which case,resource
will be set to the value before the '/' andresourceName
will be the rest. In case there is no '/',resource
will be set to the 6th components andresourceName
will be set to the rest of the string.IF THE ARN IS A TOKEN...
...it cannot be validated, since we don't have the actual value yet at the time of this function call. You will have to supply
sepIfToken
and whether or not ARNs of the expected format usually have resource names in order to parse it properly. The resultingArnComponents
object will contain tokens for the subexpressions of the ARN, not string literals.If the resource name could possibly contain the separator char, the actual resource name cannot be properly parsed. This only occurs if the separator char is '/', and happens for example for S3 object ARNs, IAM Role ARNs, IAM OIDC Provider ARNs, etc. To properly extract the resource name from a Tokenized ARN, you must know the resource type and call
Arn.extractResourceName
.- Parameters:
arn
- The ARN to parse. This parameter is required.sepIfToken
- The separator used to separate resource from resourceName.hasName
- Whether there is a name component in the ARN at all.- Returns:
- an ArnComponents object which allows access to the various components of the ARN.
-
parse
@Stability(Deprecated) @Deprecated @NotNull public static ArnComponents parse(@NotNull String arn, @Nullable String sepIfToken) Deprecated.use split instead(deprecated) Given an ARN, parses it and returns components.IF THE ARN IS A CONCRETE STRING...
...it will be parsed and validated. The separator (
sep
) will be set to '/' if the 6th component includes a '/', in which case,resource
will be set to the value before the '/' andresourceName
will be the rest. In case there is no '/',resource
will be set to the 6th components andresourceName
will be set to the rest of the string.IF THE ARN IS A TOKEN...
...it cannot be validated, since we don't have the actual value yet at the time of this function call. You will have to supply
sepIfToken
and whether or not ARNs of the expected format usually have resource names in order to parse it properly. The resultingArnComponents
object will contain tokens for the subexpressions of the ARN, not string literals.If the resource name could possibly contain the separator char, the actual resource name cannot be properly parsed. This only occurs if the separator char is '/', and happens for example for S3 object ARNs, IAM Role ARNs, IAM OIDC Provider ARNs, etc. To properly extract the resource name from a Tokenized ARN, you must know the resource type and call
Arn.extractResourceName
.- Parameters:
arn
- The ARN to parse. This parameter is required.sepIfToken
- The separator used to separate resource from resourceName.- Returns:
- an ArnComponents object which allows access to the various components of the ARN.
-
parse
Deprecated.use split instead(deprecated) Given an ARN, parses it and returns components.IF THE ARN IS A CONCRETE STRING...
...it will be parsed and validated. The separator (
sep
) will be set to '/' if the 6th component includes a '/', in which case,resource
will be set to the value before the '/' andresourceName
will be the rest. In case there is no '/',resource
will be set to the 6th components andresourceName
will be set to the rest of the string.IF THE ARN IS A TOKEN...
...it cannot be validated, since we don't have the actual value yet at the time of this function call. You will have to supply
sepIfToken
and whether or not ARNs of the expected format usually have resource names in order to parse it properly. The resultingArnComponents
object will contain tokens for the subexpressions of the ARN, not string literals.If the resource name could possibly contain the separator char, the actual resource name cannot be properly parsed. This only occurs if the separator char is '/', and happens for example for S3 object ARNs, IAM Role ARNs, IAM OIDC Provider ARNs, etc. To properly extract the resource name from a Tokenized ARN, you must know the resource type and call
Arn.extractResourceName
.- Parameters:
arn
- The ARN to parse. This parameter is required.- Returns:
- an ArnComponents object which allows access to the various components of the ARN.
-
split
@Stability(Stable) @NotNull public static ArnComponents split(@NotNull String arn, @NotNull ArnFormat arnFormat) Splits the provided ARN into its components.Works both if 'arn' is a string like 'arn:aws:s3:::bucket', and a Token representing a dynamic CloudFormation expression (in which case the returned components will also be dynamic CloudFormation expressions, encoded as Tokens).
- Parameters:
arn
- the ARN to split into its components. This parameter is required.arnFormat
- the expected format of 'arn' - depends on what format the service 'arn' represents uses. This parameter is required.
-