AWS-ARN

 view release on metacpan or  search on metacpan

lib/AWS/ARN.pm  view on Meta::CPAN

	lazy => 1,
	builder => '_build_account_id',
	clearer => '_clear_account_id',
	trigger => sub { shift->_clear_arn },
);

has resource_id => (
	is => 'rw',
	isa => $ArnResourceID,
	lazy => 1,
	builder => '_build_resource_id',
	clearer => '_clear_resource_id',
	trigger => sub { shift->_clear_arn },
);

sub _build_arn {
	my $self = shift;
	my $arn = join( ':',
		'arn',
		$self->partition,
		$self->service,
		$self->region,
		$self->account_id,
		$self->resource_id,
	);
}

sub _build_partition {
	shift->_split_arn( 1 )
}
sub _build_service {
	shift->_split_arn( 2 )
}
sub _build_region {
	shift->_split_arn( 3 )
}
sub _build_account_id {
	shift->_split_arn( 4 )
}
sub _build_resource_id {
	shift->_split_arn( 5 )
}
sub _trigger_arn {
	my $self = shift;
	$self->_clear_partition;
	$self->_clear_service;
	$self->_clear_region;
	$self->_clear_account_id;
	$self->_clear_resource_id;
}

around BUILDARGS => sub {
	my ( $orig, $class, @args ) = @_;

	return { arn => $args[0] }
		if @args == 1 && !ref $args[0];

	return $class->$orig( @args );
};

no Try::Tiny;
no Type::Utils;
no Types::Standard;
no Moo;

1;

__END__

=pod

=encoding utf-8

=head1 NAME

AWS::ARN -  module to parse and generate ARNs

=head1 VERSION

0.007

=head1 DESCRIPTION

Parse, modify and generate AWS ARNs (Amazon Resource Names)

=head1 CONSTRUCTOR

=head2 new( C<$arn> );

Return a new L<AWS::ARN> object

=head2 new( partition => $part, service => $svc, region => $rgn, account_id => $acct, resource_id => $res );

Returns a new L<AWS::ARN> object, build from the provided attributes

=head1 ATTRIBUTES

=head2 partition 

The partition in which the resource is located. A partition is a group of AWS Regions. Each AWS account is scoped to one partition.

The following are the supported partitions:

=over

=item * aws - AWS Regions

=item * aws-cn - China Regions

=item * aws-us-gov - AWS GovCloud (US) Regions

=back

Defaults to "aws"

=head2 service

The service namespace that identifies the AWS product. For example, s3 for Amazon S3 resources.

=head2 region

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.924 second using v1.00-cache-2.02-grep-82fe00e-cpan-c30982ac1bc3 )