Skip to content
v2.275.0

Arn Class ​

Methods ​

extractResourceName(arn: string, resourceType: string): string@staticmethod def extract_resource_name(arn: str, resource_type: str) -> strpublic static String extractResourceName(String arn, String resourceType)public static string ExtractResourceName(string arn, string resourceType)func ExtractResourceName(Arn *string, ResourceType *string) *stringstatic#
Extract the full resource name from an ARN.
notes

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 ':<resourceType>/' (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 /.

format(components: ArnComponents, stack?: Stack): string@staticmethod def format(components: ArnComponents, stack: typing.Optional[Stack] = None) -> strpublic static String format(ArnComponents components, Stack stack)public static string Format(ArnComponents components, Stack? stack = null)func Format(Components ArnComponents, Stack Stack) *stringstatic#
Creates an ARN from components.
notes

If partition, region or account 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'.

split(arn: string, arnFormat: ArnFormat): ArnComponents@staticmethod def split(arn: str, arn_format: ArnFormat) -> ArnComponentspublic static ArnComponents split(String arn, ArnFormat arnFormat)public static ArnComponents Split(string arn, ArnFormat arnFormat)func Split(Arn *string, ArnFormat ArnFormat) ArnComponentsstatic#
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).

2 parameters

Parameters

  • arnarnarnarnArn — the ARN to split into its components.
  • arnFormatarn_formatarnFormatarnFormatArnFormat — the expected format of 'arn' - depends on what format the service 'arn' represents uses.