AWS-Networks
view release on metacpan or search on metacpan
Instance an object, and use it to filter information of interest to you
with the attributes and methods provided.
METHODS
new([ url => 'http....' ])
Standard Moose constructor. Can specify a custom URL to download a
document that follows the same schema
url
Returns the URL from which the information was retrieved. Returns undef
on filtered datasets
sync_token
Returns a DateTime object created from the current timestamp of the
syncToken reported from the service
networks
Returns an ArrayRef with HashRefs following the following structure:
{ ip_prefix => '0.0.0.0/0', region => '...', service => '...' }
service can be one of: AMAZON | EC2 | CLOUDFRONT | ROUTE53 |
ROUTE53_HEALTHCHECKS, but expect new values to appear
region can be one of: ap-northeast-1 | ap-southeast-1 | ap-southeast-2 |
cn-north-1 | eu-central-1 | eu-west-1 | sa-east-1 | us-east-1 |
us-gov-west-1 | us-west-1 | us-west-2 | GLOBAL, but expect new values to
appear
services
Returns an ArrayRef of the different services present in the current
dataset
regions
Returns an ArrayRef of the different regions present in the current
dataset
cidrs
Returns an ArrayRef with the CIDR blocks in the dataset
by_region($region)
Returns a new AWS::Networks object with the data filtered to only the
objects in the specified region
by_service($service)
Returns a new AWS::Networks object with the data filtered to only the
services specified
CONTRIBUTE
bin/aws_ips_for_service view on Meta::CPAN
use AWS::Networks;
use Net::CIDR::Set;
my $service = $ARGV[0] or die "Usage $0 AMAZON|CLOUDFRONT|...|ROUTE53\n";
my $nets = AWS::Networks->new;
my $cidrs = $nets->by_service(uc($service))->cidrs;
my $set = Net::CIDR::Set->new(@$cidrs);
my $count = 0;
my $iter = $set->iterate_cidr;
while ( my $cidr = $iter->() ) {
my ($net, $bits) = split /\//, $cidr;
if ($bits == 32) {
$count += 1;
} elsif ($bits == 31) {
$count += 2;
} else {
$count += (( 2 ** (32 - $bits) ) - 2);
}
}
lib/AWS/Networks.pm view on Meta::CPAN
Instance an object, and use it to filter information of interest to you with the attributes and methods provided.
=head1 METHODS
=head2 new([ url => 'http....' ])
Standard Moose constructor. Can specify a custom URL to download a document that follows the same schema
=head2 url
Returns the URL from which the information was retrieved. Returns undef on filtered datasets
=head2 sync_token
Returns a DateTime object created from the current timestamp of the syncToken reported from the service
=head2 networks
Returns an ArrayRef with HashRefs following the following structure:
{ ip_prefix => '0.0.0.0/0', region => '...', service => '...' }
The keys and values in the HashRefs are the ones returned by the Network service
service can be one of: AMAZON | EC2 | CLOUDFRONT | ROUTE53 | ROUTE53_HEALTHCHECKS, but expect
new values to appear
region can be one of: ap-northeast-1 | ap-southeast-1 | ap-southeast-2 | cn-north-1 | eu-central-1 | eu-west-1 | sa-east-1 | us-east-1 | us-gov-west-1 | us-west-1 | us-west-2 | GLOBAL, but expect new values to appear
=head2 services
Returns an ArrayRef of the different services present in the current dataset
=head2 regions
Returns an ArrayRef of the different regions present in the current dataset
=head2 cidrs
Returns an ArrayRef with the CIDR blocks in the dataset
=head2 by_region($region)
Returns a new AWS::Networks object with the data filtered to only the objects in the
specified region
=head2 by_service($service)
Returns a new AWS::Networks object with the data filtered to only the services specified
t/02_tests.t view on Meta::CPAN
);
is_deeply(
[ sort @{ $net->services } ],
[ sort qw/AMAZON EC2 CLOUDFRONT ROUTE53 ROUTE53_HEALTHCHECKS/],
'Services OK'
);
my $by_region = $net->by_region('GLOBAL');
cmp_ok($by_region->sync_token->iso8601, 'eq', '2014-11-20T22:47:08', 'Sync Token in filtered dataset');
ok(not(defined($by_region->url)), 'URL not defined in filtered dataset');
is_deeply(
[ sort @{ $by_region->services } ],
[ sort (
'CLOUDFRONT',
'ROUTE53',
'AMAZON'
) ],
'Global region services'
);
( run in 0.663 second using v1.01-cache-2.11-cpan-49f99fa48dc )