AWS Urns

A dataclass for building and querying AWS URNs.

AWS URNs are a standardised string format (name borrowed from Pulumi) which provide all the information required to find a resource in AWS, whereas AWS ARNs do not always provide this information.

# Format
'urn:aws:<account_id>:<region>:<service>:<resource_type>:<resource_id>'
# e.g.
'urn:aws:111111111111:eu-west-2:ec2:vpc:vpc-11111111'

Example

>>> from cloudwanderer import AwsUrn
>>> AwsUrn.from_string('urn:aws:111111111111:eu-west-2:ec2:vpc:vpc-11111111')
AwsUrn(account_id='111111111111', region='eu-west-2', service='ec2', resource_type='vpc', resource_id='vpc-11111111')
class AwsUrn(account_id, region, service, resource_type, resource_id)

A dataclass for building and querying AWS URNs.

__init__(account_id, region, service, resource_type, resource_id)

Initialise an AWS Urn.

Parameters
  • account_id (str) – AWS Account ID (e.g. 111111111111).

  • region (str) – AWS region (e.g. eu-west-1).

  • service (str) – AWS Service (e.g. ec2).

  • resource_type (str) – AWS Resource Type (e.g. instance)

  • resource_id (str) – AWS Resource Id (e.g. i-11111111)

Return type

None

classmethod from_string(urn_string)

Create an AwsUrn Object from an AwsUrn string.

Parameters

urn_string (str) – The string version of an AWSUrn to convert into an object.

Returns

The instantiated AWS URN.

Return type

AwsUrn