AWS-ARN
view release on metacpan or search on metacpan
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.
6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.
7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.
8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
The ID of the AWS account that owns the resource, without the hyphens.
For example, 123456789012.
resource_id
The resource identifier. This part of the ARN can be the name or ID of
the resource or a resource path. For example, user/Bob for an IAM user
or instance/i-1234567890abcdef0 for an EC2 instance. Some resource
identifiers include a parent resource
(sub-resource-type/parent-resource/sub-resource) or a qualifier such as
a version (resource-type:resource-name:qualifier).
NOTES
* Needs tests
* Needs more validation
AUTHOR
requires 'Moo' => '2.0';
requires 'Try::Tiny';
requires 'Type::Utils';
requires 'Types::Standard';
on configure => sub {
requires 'Module::Build::Tiny', '0.034';
requires 'perl', '5.006';
};
lib/AWS/ARN.pm view on Meta::CPAN
package AWS::ARN;
use strict;
use warnings;
use Moo;
use Types::Standard qw/Str/;
use Type::Utils;
our $VERSION = '0.007';
use overload '""' => sub {
shift->arn;
};
my $partitionRe = my $serviceRe = qr{[\w-]+};
my $regionRe = qr{[\w-]*};
my $account_idRe = qr{\d*};
my $resource_idRe = qr{.+};
my $arnRe = qr{arn:$partitionRe:$serviceRe:$regionRe:$account_idRe:$resource_idRe};
my $Arn = declare(
as Str,
lib/AWS/ARN.pm view on Meta::CPAN
as Str,
where { m{^$account_idRe$} },
message { "$_ is not a valid AWS Account ID" }
);
my $ArnResourceID = declare(
as Str,
where { m{^$resource_idRe$} },
message { "$_ is not a valid AWS Resource" },
);
sub _split_arn {
my $self = shift;
my ($index) = @_;
return "" unless $self->_has_arn;
my @parts = split( /:/, $self->arn, 6 );
return $parts[$index||0]||"";
}
has arn => (
is => 'rw',
isa => $Arn,
lib/AWS/ARN.pm view on Meta::CPAN
trigger => 1,
);
has partition => (
is => 'rw',
isa => $ArnPartition,
lazy => 1,
builder => '_build_partition',
clearer => '_clear_partition',
default => 'aws',
trigger => sub { shift->_clear_arn },
);
has service => (
is => 'rw',
isa => $ArnService,
lazy => 1,
required => 1,
builder => '_build_service',
clearer => '_clear_service',
trigger => sub { shift->_clear_arn },
);
has region => (
is => 'rw',
isa => $ArnRegion,
lazy => 1,
builder => '_build_region',
clearer => '_clear_region',
trigger => sub { shift->_clear_arn },
);
has account_id => (
is => 'rw',
isa => $ArnAccountID,
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;
lib/AWS/ARN.pm view on Meta::CPAN
The Region. For example, us-east-2 for US East (Ohio).
=head2 account_id
The ID of the AWS account that owns the resource, without the hyphens. For example, 123456789012.
=head2 resource_id
The resource identifier. This part of the ARN can be the name or ID of the resource or a resource path.
For example, user/Bob for an IAM user or instance/i-1234567890abcdef0 for an EC2 instance. Some resource
identifiers include a parent resource (sub-resource-type/parent-resource/sub-resource) or a qualifier such
as a version (resource-type:resource-name:qualifier).
=head1 NOTES
=over
=item * Needs tests
=item * Needs more validation
( run in 1.511 second using v1.01-cache-2.11-cpan-88abd93f124 )