Skip to content

Arn

Static Functions

Name Description
extract_resource_name Extract the full resource name from an ARN.
format Creates an ARN from components.
split Splits the provided ARN into its components.

extract_resource_name

import ros_cdk_core
ros_cdk_core.Arn.extract_resource_name(
  arn: str,
  resource_type: str
)

Extract the full resource name from an ARN.

Necessary for resource names (paths) that may contain the separator, like acs:ram::123456789012****:role/adminrole/alice.

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 ROS 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 /.

arnRequired

  • Type: str

resource_typeRequired

  • Type: str

format

import ros_cdk_core
ros_cdk_core.Arn.format(
  resource: str,
  service: str,
  account: str = None,
  arn_format: ArnFormat = None,
  partition: str = None,
  region: str = None,
  resource_name: str = None,
  stack: Stack = None
)

Creates an ARN from components.

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:

{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'.

resourceRequired

  • Type: str

Resource type (e.g. "instance", "functions", "role"). For some resource types, e.g. OSS buckets, this field defines the bucket name.


serviceRequired

  • Type: str

The service namespace that identifies the ACS product (for example, 'ecs', 'fc', 'ram').


accountOptional

  • Type: str
  • Default: The account the stack is deployed to.

The ID of the ACS account that owns the resource, without the hyphens.

For example, 123456789012. Note that the ARNs for some resources don't require an account number, so this component might be omitted.


arn_formatOptional

  • Type: ArnFormat
  • Default: uses value of sep as the separator for formatting, ArnFormat.SLASH_RESOURCE_NAME if that property was also not provided

The specific ARN format to use for this ARN value.


partitionOptional

  • Type: str
  • Default: acs

The partition that the resource is in.


regionOptional

  • Type: str
  • Default: The region the stack is deployed to.

The region the resource resides in.

Note that the ARNs for some resources do not require a region, so this component might be omitted.


resource_nameOptional

  • Type: str

Resource name or path within the resource (i.e. OSS bucket object key) or a wildcard such as "*". This is service-dependent.


stackOptional


split

import ros_cdk_core
ros_cdk_core.Arn.split(
  arn: typing.Union[str, IResolvable],
  arn_format: ArnFormat
)

Splits the provided ARN into its components.

Works both if 'arn' is a string like 'acs:oss:::bucket', and a Token representing a dynamic CloudFormation expression (in which case the returned components will also be dynamic ROS expressions, encoded as Tokens).

arnRequired

the ARN to split into its components.


arn_formatRequired

the expected format of 'arn' - depends on what format the service 'arn' represents uses.