Amazon-CloudFront-Thin
view release on metacpan or search on metacpan
lib/Amazon/CloudFront/Thin.pm view on Meta::CPAN
return qq{<?xml version="1.0" encoding="UTF-8"?><InvalidationBatch xmlns="http://cloudfront.amazonaws.com/doc/2018-11-05/"><Paths><Quantity>$total_paths</Quantity><Items>$path_content</Items></Paths><CallerReference>$identifier</CallerReference><...
}
42;
__END__
=encoding utf8
=head1 NAME
Amazon::CloudFront::Thin - A thin, lightweight, low-level Amazon CloudFront client
=head1 SYNOPSIS
use Amazon::CloudFront::Thin;
my $cloudfront = Amazon::CloudFront::Thin->new({
aws_access_key_id => $key_id,
aws_secret_access_key => $access_key,
distribution_id => 'my-cloudfront-distribution',
});
my $res = $cloudfront->create_invalidation(
'/path/to/some/object.jpg',
'/path/to/another/object.bin',
);
=head1 DESCRIPTION
Amazon::CloudFront::Thin is a thin, lightweight, low level client for Amazon CloudFront.
It is designed for only ONE purpose: send a request and get a response.
It offers the following features:
=over 4
=item Low Level
Every request returns an L<HTTP::Response> object so you can easily inspect
what's happening inside, and can handle errors as you like.
=item Low Dependency
It has very few dependencies, so installation is easy and bloat-free
for your application. Aside from core modules like Digest::SHA, we
only rely on basic web modules like URI and HTTP::Message, which
you're probably already loaded from within your preferred web framework
or application.
=item Low Learning Cost
The interface is designed to follow Amazon CloudFront's official REST APIs.
So it is easy to learn and use by following the official documentation.
=back
=head2 Comparison to alternative modules
There are several useful modules for CloudFront on CPAN, like
L<Paws::CloudFront>, who provide a nice interface. You are welcome
to check them out to see if they suit your needs best. The reason
I wrote Amazon::CloudFront::Thin is because I needed to invalidate
CloudFront paths quickly and easily, and the alternatives felt either
like an "all or nothing" approach or lacked the documentation or
features I needed.
=head2 Amazon CloudFront setup in a Nutshell
Amazon CloudFront is the content-delivery (CDN) service of Amazon Web
Services (AWS). You use it by
L<< creating distributions|https://console.aws.amazon.com/cloudfront/home?region=us-east-1#distributions: >>
(each with its own "distribution id" which we use below). To manage
your distributions with this module, you need to provide credentials
allowed to access/change your CloudFront distributions. You do this
by going to L<< AWS's Identity and Access Management (IAM) console|https://console.aws.amazon.com/iam/home >>
and creating a new user. When you do that, the user's C<Access Key ID>
and C<Secret Access Key> credentials will be shown to you. You'll also
need to pass those to Amazon::CloudFront::Thin's constructor as shown
in the SYNOPSIS and below, as C<aws_access_key_id> and
C<aws_secret_access_key>, respectively. Finally, please note that
B<the provided IAM credentials must have the rights to change your CloudFront>.
You can do that by clicking on the user (in the Amazon IAM console where
you created it) and attaching a policy to it, such as the
C<CloudFrontFullAccess> standard policy. Otherwise you'll get errors when
trying to invalidate your CloudFront distributions.
=head1 CONSTRUCTOR
=head2 new( \%params )
B<Receives>: hashref with options.
B<Returns>: Amazon::CloudFront::Thin object.
use Amazon::CloudFront::Thin;
use IO::Socket::SSL;
use Furl;
my $cloudfront = Amazon::CloudFront::Thin->new(
aws_access_key_id => 'my_key_id',
aws_secret_access_key => 'my_key_secret',
distribution_id => 'my-cloudfront-distribution-id',
# optional
ua => Furl->new(
ssl_opts => { SSL_verify_mode => SSL_VERIFY_PEER()
},
);
Available arguments are:
=over
=item * C<aws_access_key_id> (B<required>)
Your L<< CloudFront credential|/"Amazon CloudFront setup in a Nutshell" >> key id.
=item * C<aws_secret_access_key> (B<required>)
Your L<< CloudFront credential|/"Amazon CloudFront setup in a Nutshell" >> secret.
( run in 1.670 second using v1.01-cache-2.11-cpan-98e64b0badf )