AWS-Lambda-Quick
view release on metacpan or search on metacpan
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.
We configure an AWS\_PROXY integration routing to our new Lambda
function. This essentially means everything is passed "as is"
through to our handler as the first argument.
Upload and GET the following to see what is being passed in
your environment:
#!/usr/bin/perl
use strict;
use warnings;
use JSON::PP;
use AWS::Lambda::Quick (
name => 'echo',
);
sub handler {
my $data = shift;
return {
statusCode => 200,
headers => {
'Content-Type' => 'application/json',
},
body => encode_json($data),
};
}
1;
### Create a new integration-response and method-response
The integration response and method response are analogous to the
integration and method - but instead of getting data from HTTP to
Lambda, they get Lambda data back to HTTP.
Because we want our handler to have complete control over the output
we don't do anything special with what we create.
### Deploying the Code.
Once all the above is done the module finally deploys the code
so it's web accessible.
By default this is to the `quick`, though you can reconfigure that
with the `stage_name` parameter.
## Parameters
This is a full list of parameters you can currently configure. Only
one parameter - `name` - is required and all other parameters are
optional and will have hopefully sensible defaults.
It is not the intent of the author to provide a complete and exhaustive
list of all possibilities - you have the power of the AWS Management
console and AWS API to make any further tweaks you may desire.
- name
The name of the Lambda function. Required.
This will become part of the URL that can be used to call this
function so you are strongly encouraged not to use any non-url
safe characters (including `/`, `?`, etc) in the name.
- description
The description of the Lambda function (shown in the AWS console, etc.)
- extra\_files
An array of extra files and directories that you wish to upload in
addition to the script itself.
For example, to upload the `lib` directory, you would write:
use AWS::Lambda::Quick (
name => 'some-script-that-needs-modules',
extra_files => [ 'lib' ],
);
These filenames must be relative and will be expected to be in the
same directory as the script itself. Passing a directory name will
cause the directory contents to be recursively uploaded. If a named
file/directory is not present at the passed location it will be
silently ignored.
- region
The region you wish to deploy the lamda function to. By default
this will be `us-east-1`.
- memory\_size
The amount of memory that your function has access to. Increasing
the function's memory also increases its CPU allocation. The default
value is 128 MB. The value must be a multiple of 64 MB.
- timeout
The amount of time that Lambda allows a function to run before stopping
it. The default is 3 seconds. The maximum allowed value is 900 seconds.
- role
The AWS role you want to run the Lambda function as. This can
either be a full arn, or the name of the role to use (which will
be automatically created with permissions to run Lambda functions
if it does not exist).
If you do not pass a role argument the role with the name
( run in 0.810 second using v1.01-cache-2.11-cpan-f56aa216473 )