Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Aws Serverless Workshops | 3,883 | 2 months ago | 1 | July 08, 2020 | 70 | apache-2.0 | JavaScript | |||
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops | ||||||||||
Aws Serverless Auth Reference App | 725 | 4 years ago | 14 | other | TypeScript | |||||
Serverless reference app and backend API, showcasing authentication and authorization patterns using Amazon Cognito, Amazon API Gateway, AWS Lambda, and AWS IAM. | ||||||||||
Serverless Photo Recognition | 308 | 3 years ago | 2 | apache-2.0 | Kotlin | |||||
A collection of 3 lambda functions that are invoked by Amazon S3 or Amazon API Gateway to analyze uploaded images with Amazon Rekognition and save picture labels to ElasticSearch (written in Kotlin) | ||||||||||
S3auth | 254 | 8 months ago | 38 | other | Java | |||||
Amazon S3 HTTP Basic Auth Gateway | ||||||||||
Serverless Analytics | 199 | 5 years ago | 6 | mit | CSS | |||||
Track website visitors with Serverless Analytics using Kinesis, Lambda, and TypeScript. | ||||||||||
Amazon Apigateway Ingress Controller | 101 | 2 years ago | 1 | October 08, 2019 | 21 | apache-2.0 | Go | |||
A Kubernetes controller for managing Amazon API Gateways | ||||||||||
Lambda Java8 Dynamodb | 101 | 6 years ago | apache-2.0 | Java | ||||||
Serverless Hotdog Detector | 92 | 4 years ago | apache-2.0 | Python | ||||||
This example shows you how to build a serverless hotdog detecting application on AWS using Amazon Rekognition, AWS Lambda, and Amazon API Gateway. | ||||||||||
Awesome Aws Lambda | 88 | 4 years ago | 1 | |||||||
Curated list of Awesome AWS Lambda seed repos, starters, boilerplates, examples, tutorials, components, modules, videos, and anything else in the AWS Lambda ecosystem | ||||||||||
Til | 74 | 6 days ago | ||||||||
Today I Learned |
This example uses Twilio to save an image from your mobile phone to the AWS cloud. A user sends an image using MMS to a Twilio phone number which sends a request to an Amazon API Gateway endpoint that triggers a Lambda function. The app then returns a publicly accessible link to the image in AWS S3. This app uses AWS Lambda, API Gateway, DynamoDB & S3. It is also 100% serverless!
Read the blog post!
Lambda is a compute service that runs your code in response to events. Events are triggered or invoked by resources in your AWS environment or via API Gateway. Here our Lambda function is triggered by an API Gateway endpoint that Twilio hits after an MMS is received. The Lambda function is responsible for writing user info to DynamoDB, writing the image to S3 with meta data and returning a response to Twilio.
API Gateway is a fully managed API as a service where you can create, publish, maintain, monitor, and secure APIs at any scale. In this app, we use API Gateway to create an endpoint for Twilio to make a GET request. API Gateway transforms Twilio's URL encoded request into a JSON object, so that Lambda can process it. Lastly, API Gateway takes Lambda's response and builds an XML object for Twilio.
DynamoDB is Amazon's non-relational database service. This app leverages DynamoDB to store user data. S3 provides developers with object level storage that is endlessly scalable. We use S3 to store images received via MMS.
Try it by sending an MMS to (650) 200-1944.
Step-by-step on how to configure, develop & deploy this app on AWS.
us-east-1
, us-west-2
& eu-west-1
.lambda_function.py
. Read through the module and provide a few variables: Twilio credentials, DynamoDB table name & region and S3 ingest bucket. We will upload as a .zip because our function requires a few external libraries, such as Twilio Python SDK. Compress httplib2, pytz, twilio & lambda_function.py and upload as a .zip file.main_function.lambda_handler
would call the method def lambda_handler()
inside main_function.py
. Let's call it lambda_function.lambda_handler
to match lambda_function.py
./addphoto
, for example.application-x-www-form-urlencoded
. This Integration step will map this type to a JSON object, which Lambda requires. In the Integration Requests page create a mapping template. Content-type is application/json
and template:{
"body" : "$input.params('Body')",
"fromNumber" : "$input.params('From')",
"image" : "$input.params('MediaUrl0')",
"numMedia" : "$input.params('NumMedia')"
}
More on Intergration Requests.
$input.params()
parse the request object for the corresponding variable and allows the mapping template to build a JSON object.
Screenshot
5. Let's ensure the response is correct. Twilio requires valid XML. Change the response model for 200 to Content-type: application/xml
. Leave models empty.
Screenshot
6. Lambda cannot return proper XML, so API Gateway needs to build this. This is done in Integration response as another mapping template. This time we want to create Content-type: application/xml and template:
#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>
<Body>
$inputRoot
</Body>
</Message>
</Response>
Our Lambda function solely returns a string of the SMS body. Here we build the XML object and use $inputRoot
as the string. Screenshot
7. Now let's deploy this API, so we can test it! Click the Deploy API button.
https://xxxx.execute-api.us-west-2.amazonaws.com/prod/addphoto
{
"body" : "hello",
"fromNumber" : "+19145554224" ,
"image" : "https://api.twilio.com/2010-04-01/Accounts/AC361180d5a1fc4530bdeefb7fbba22338/Messages/MM7ab00379ec67dd1391a2b13388dfd2c0/Media/ME7a70cb396964e377bab09ef6c09eda2a",
"numMedia" : "1"
}
Click Test. At the bottom of the page you view Execution result and the log output in Cloudwatch logs. This is very helpful for debugging.
5. Testing API Gateway requires a client that sends requests to the endpoint. I personally like the Chrome Extension Advanced Rest Client Send the endpoint a GET request and view its response. Ensure the S3 link works. You can also test by sending an MMS to phone number and checking the Twilio logs.