AWS-Lambda-Quick
view release on metacpan or search on metacpan
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
"version" : "1.0002"
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/2shortplanks/aws-lambda-quick/issues"
},
"homepage" : "http://metacpan.org/release/AWS-Lambda-Quick",
"repository" : {
"type" : "git",
"url" : "git://github.com/2shortplanks/aws-lambda-quick.git",
"web" : "https://github.com/2shortplanks/aws-lambda-quick"
}
},
"version" : 1.0002,
"x_Dist_Zilla" : {
"perl" : {
"version" : "5.028001"
},
"plugins" : [
{
"class" : "Dist::Zilla::Plugin::NextRelease",
"name" : "@MAXMIND/NextRelease",
"version" : "6.012"
},
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "test",
"type" : "requires"
}
},
"name" : "@MAXMIND/Test::More with Test2",
"version" : "6.012"
},
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "develop",
"type" : "requires"
}
},
"name" : "@MAXMIND/Modules for use with tidyall",
"version" : "6.012"
},
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "develop",
"type" : "requires"
}
},
"name" : "@MAXMIND/Test::Version which fixes https://github.com/plicease/Test-Version/issues/7",
"version" : "6.012"
},
{
"class" : "Dist::Zilla::Plugin::PromptIfStale",
"config" : {
"Dist::Zilla::Plugin::PromptIfStale" : {
"check_all_plugins" : 0,
version: '6.012'
-
class: Dist::Zilla::Plugin::NextRelease
name: '@MAXMIND/NextRelease'
version: '6.012'
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: test
type: requires
name: '@MAXMIND/Test::More with Test2'
version: '6.012'
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: develop
type: requires
name: '@MAXMIND/Modules for use with tidyall'
version: '6.012'
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: develop
type: requires
name: '@MAXMIND/Test::Version which fixes https://github.com/plicease/Test-Version/issues/7'
version: '6.012'
-
class: Dist::Zilla::Plugin::PromptIfStale
config:
Dist::Zilla::Plugin::PromptIfStale:
check_all_plugins: 0
check_all_prereqs: 0
modules:
- Dist::Zilla::PluginBundle::MAXMIND
resource (i.e. off of "/") and will be named after the name of the
Lambda function (i.e. calling `use AWS::Lambda::Quick (name =` "foo")>
will create a resource `/foo`)
### Create a new method
Each Lambda function we create gets its own method, which is where
AWS specifies what HTTP method it accepts (`GET`,`POST`,`PUT`,
etc.) and how it decides who can access it.
This module always sets the type of method to `ANY` (i.e. we always
call the lambda function and let it figure out what it wants to accept
or not.)
We setup the `NONE` authentication, meaning anyone can call the API
over the internet - i.e. it's configured as a public API.
### Create a new integration
Integrations are how AWS decides both where a request is routed to
and what extracted from that HTTP request is passed on and how.
lib/AWS/Lambda/Quick.pm view on Meta::CPAN
resource (i.e. off of "/") and will be named after the name of the
Lambda function (i.e. calling C<use AWS::Lambda::Quick (name => "foo")>
will create a resource C</foo>)
=head3 Create a new method
Each Lambda function we create gets its own method, which is where
AWS specifies what HTTP method it accepts (C<GET>,C<POST>,C<PUT>,
etc.) and how it decides who can access it.
This module always sets the type of method to C<ANY> (i.e. we always
call the lambda function and let it figure out what it wants to accept
or not.)
We setup the C<NONE> authentication, meaning anyone can call the API
over the internet - i.e. it's configured as a public API.
=head3 Create a new integration
Integrations are how AWS decides both where a request is routed to
and what extracted from that HTTP request is passed on and how.
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
return AWS::CLIWrapper->new(
region => $self->region,
);
};
has zip_file_blob => sub { 'fileb://' . shift->zip_filename };
# should we create the function from scratch or just update it?
# by default we interogate the api to see if it exists already
has update_type => sub {
my $self = shift;
my $aws = $self->aws;
my $result = $aws->lambda(
'get-function',
{
'function-name' => $self->name,
}
);
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
$self->debug('found existing method');
return ();
}
$self->debug('putting new method');
$self->aws_do(
'apigateway',
'put-method',
{
@identifiers,
'authorization-type' => 'NONE',
},
);
$self->debug('new method put');
return ();
}
sub _create_method_response {
my $self = shift;
my $resource_id = shift;
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
$self->debug('found existing integration');
return ();
}
$self->debug('putting new integration');
$self->aws_do(
'apigateway',
'put-integration',
{
%{$identifiers},
type => 'AWS_PROXY',
'integration-http-method' => 'POST',
'credential' => $self->_role_arn,
uri => $uri,
}
);
$self->debug('new integration put');
return ();
}
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
}
);
$self->debug('new integration put');
return ();
}
sub _upload_function {
my $self = shift;
my $update_type = $self->update_type;
my $region = $self->region;
# compute the arn based on the list in the AWS::Lambda 0.0.11
# documentation
my $v = $region eq 'me-south-1' ? 3 : 5;
my $layers = [
"arn:aws:lambda:$region:445285296882:layer:perl-5-30-runtime:$v",
];
for my $layer ( @{ $self->extra_layers } ) {
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
# documentation
my $pv = $region eq 'me-south-1' ? 3 : 4;
push @{$layers},
"arn:aws:lambda:$region:445285296882:layer:perl-5-30-paws:$pv";
next;
}
die "Layer '$layer' is neither a known named layer nor a layer arn";
}
if ( $update_type eq 'create-function' ) {
$self->debug('creating new function');
my $result = $self->aws_do(
'lambda',
'create-function',
{
'function-name' => $self->name,
'role' => $self->_role_arn,
'region' => $region,
'runtime' => 'provided',
'zip-file' => $self->zip_file_blob,
perlcriticrc view on Meta::CPAN
# No need for /xsm everywhere
[-RegularExpressions::RequireDotMatchAnything]
[-RegularExpressions::RequireExtendedFormatting]
[-RegularExpressions::RequireLineBoundaryMatching]
# by concensus in standup 2015-05-12 we decided to allow return undef
# this is mainly so bar can be written to return undef so that
# foo( bar => bar(), bazz => baz() ) won't cause problems
[-Subroutines::ProhibitExplicitReturnUndef]
# This incorrectly thinks signatures are prototypes.
[-Subroutines::ProhibitSubroutinePrototypes]
# http://stackoverflow.com/questions/2275317/why-does-perlcritic-dislike-using-shift-to-populate-subroutine-variables
[-Subroutines::RequireArgUnpacking]
[-Subroutines::RequireFinalReturn]
# "use v5.14" is more readable than "use 5.014"
[-ValuesAndExpressions::ProhibitVersionStrings]
t/00-report-prereqs.t view on Meta::CPAN
# CPAN::Meta::Prereqs object
if (ref $collector eq $cpan_meta_pre) {
return $collector->with_merged_prereqs(
CPAN::Meta::Prereqs->new( $prereqs )
);
}
# Raw hashrefs
for my $phase ( keys %$prereqs ) {
for my $type ( keys %{ $prereqs->{$phase} } ) {
for my $module ( keys %{ $prereqs->{$phase}{$type} } ) {
$collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module};
}
}
}
return $collector;
}
my @include = qw(
);
t/00-report-prereqs.t view on Meta::CPAN
# Add static includes into a fake section
for my $mod (@include) {
$req_hash->{other}{modules}{$mod} = 0;
}
for my $phase ( qw(configure build test runtime develop other) ) {
next unless $req_hash->{$phase};
next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING});
for my $type ( qw(requires recommends suggests conflicts modules) ) {
next unless $req_hash->{$phase}{$type};
my $title = ucfirst($phase).' '.ucfirst($type);
my @reports = [qw/Module Want Have/];
for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) {
next if $mod eq 'perl';
next if grep { $_ eq $mod } @exclude;
my $file = $mod;
$file =~ s{::}{/}g;
$file .= ".pm";
my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC;
my $want = $req_hash->{$phase}{$type}{$mod};
$want = "undef" unless defined $want;
$want = "any" if !$want && $want == 0;
my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required";
if ($prefix) {
my $have = MM->parse_version( File::Spec->catfile($prefix, $file) );
$have = "undef" unless defined $have;
push @reports, [$mod, $want, $have];
if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) {
if ( $have !~ /\A$lax_version_re\z/ ) {
push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)";
}
elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) {
push @dep_errors, "$mod version '$have' is not in required range '$want'";
}
}
}
else {
push @reports, [$mod, $want, "missing"];
if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) {
push @dep_errors, "$mod is not installed ($req_string)";
}
}
}
if ( @reports ) {
push @full_reports, "=== $title ===\n\n";
my $ml = _max( map { length $_->[0] } @reports );
my $wl = _max( map { length $_->[1] } @reports );
my $hl = _max( map { length $_->[2] } @reports );
if ($type eq 'modules') {
splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports;
}
else {
splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports;
}
push @full_reports, "\n";
}
( run in 1.682 second using v1.01-cache-2.11-cpan-bbb979687b5 )