AWS-Lambda-Quick
view release on metacpan or search on metacpan
### Create a new Lambda Function
Execution uploads the script (and any extra files specified, see
the `extra_files` parameter below) as a new Lambda function with the
passed name. Subsequent uploads will replace and update that Lambda
function
The function will be assigned the previously created role.
### Create a API Gateway For All Quick Functions
This will create a REST API API Gateway that we use for accessing
any quick functions created on that account. If you're not familiar
with AWS, this can we considered somewhat like a top level domain where
all the APIs we create will be "mounted".
If you want you can pass in an alternative existing rest API to
be used instead, either with the `rest_api_id` parameter to specify
by id, or by passing in the name via the `rest_api` parameter.
### Create a new resource
Executing will create a new resource for each Lambda function (If you're
not familiar with AWS this is somewhat like specifying a path for the
API to be callable on.) This will be created directly off the top level
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.
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
( run in 1.303 second using v1.01-cache-2.11-cpan-140bd7fdf52 )