Amazon-CloudFront-Thin
view release on metacpan or search on metacpan
lib/Amazon/CloudFront/Thin.pm view on Meta::CPAN
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.
=item * C<distribution_id> (B<required>)
The id of the L<< CloudFront distribution|/"Amazon CloudFront setup in a Nutshell" >>
you want to manage.
=item * C<ua> (Optional)
An LWP::UserAgent compatible object (otherwise, LWP::UserAgent will be used).
The object must provide a C<request()> method that receives an HTTP::Request
and returns a response. The responses, whatever they are, will be forwarded
to your call. Also, the object must be able to handle B<HTTPS>. If you don't
want to use LWP::UserAgent, there is a (highly incomplete) list of
alternatives below:
Compatible: L<Furl>, L<LWP::UserAgent>, L<HTTP::Thin>, L<WWW::Curl::Simple>.
Incompatible: L<HTTP::Lite>, L<Hijk>, L<HTTP::Lite>, L<HTTP::Tiny>.
=back
=head1 ACCESSORS
=head2 ua
Gets/Sets the current user agent object doing the requests to Amazon
CloudFront. Defaults to LWP::UserAgent. You can replace it either
using this accessor or during object construction (see above for an
example that loads C<Furl> instead of C<LWP::UserAgent>).
=head1 METHODS
=head2 create_invalidation( $path )
=head2 create_invalidation( @paths )
=head2 create_invalidation( \@paths )
B<Receives>: list of strings (or arrayref of strings), each specifying
a different path to invalidate.
B<Returns>: an L<HTTP::Response> object for the request. Use the C<content()>
method on the returned object to read the contents:
my $res = $cloudfront->create_invalidation( '/path/to/some/object.png' );
if ($res->is_success) {
my $content = $res->content;
}
This method creates a new invalidation batch request on Amazon CloudFront.
Please note that B<paths are case sensitive> and that
B<the leading '/' is optional>, meaning C<"foo/BAR"> and C<"FOO/bar">
are completely different, but C<"foo/bar"> and C<"/foo/bar"> (note the '/')
point to the same object.
Each path is wrapped under CDATA on the resulting XML, so it should be
safe for non-ASCII and unsafe characters in your paths.
For more information, please refer to
L<< Amazon's API documentation for CreateInvalidation|https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html >>.
For information on invalidations in general, including limitations,
please refer to L<< Amazon's CloudFront Developer Guide|https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html >>.
Finally, please refer to L<< Amazon's CloudFront error messages|https://docs.aws.amazon.com/cloudfront/latest/APIReference/CommonErrors.html >>
for more information on how to interpret errors returned as responses.
=head1 HANDLING UNICODE FILENAMES & PATHS
Amazon appears to reference filenames containing non ASCII characters
by URL Encoding the filenames. The following code takes a path such as
C<"events/Ø§ÙØ§Ø¨ØØ§Ø«"> which contains both a slash to indicate a directory
boundary and a non-ascii filename and creates an invalidation:
use Amazon::CloudFront::Thin;
use URL::Encode qw( url_encode_utf8 );
my $cloudfront = Amazon::CloudFront::Thin::->new( ... );
my $encoded_filename = url_encode_utf8($path);
# "/" will be encoded as %2F, but we want it as "/"
$encoded_filename =~ s!%2F!/!g;
$cloudfront->create_invalidation( '/' . $encoded_filename );
=head1 AUTHOR
Breno G. de Oliveira C<< garu at cpan.org >>
=head1 LICENSE AND COPYRIGHT
Copyright 2015-2019 Breno G. de Oliveira C<< <garu at cpan.org> >>. All rights reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself. See L<perlartistic>.
=head1 DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
( run in 1.138 second using v1.01-cache-2.11-cpan-df04353d9ac )