|
| 1 | +{ |
| 2 | + "title": "Integrate AWS Lambda SnapStart function with Amazon API Gateway", |
| 3 | + "description": "This pattern demonstrates how to create a REST API using Amazon API Gateway, AWS Lambda with SnapStart, and Amazon DynamoDB.", |
| 4 | + "language": "Python", |
| 5 | + "level": "200", |
| 6 | + "framework": "AWS CDK", |
| 7 | + "introBox": { |
| 8 | + "headline": "How it works", |
| 9 | + "text": [ |
| 10 | + "This pattern creates a REST API for managing car records using API Gateway and Lambda with SnapStart enabled.", |
| 11 | + "The Lambda function is Python 3.12-based and includes a live alias that's integrated with API Gateway for seamless deployments.", |
| 12 | + "Lambda SnapStart persists the initialized state of the Lambda runtime, significantly reducing cold start times for function initialization.", |
| 13 | + "DynamoDB stores car records with a partition key of 'id', providing a scalable NoSQL database backend for the REST API." |
| 14 | + ] |
| 15 | + }, |
| 16 | + "gitHub": { |
| 17 | + "template": { |
| 18 | + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-python-cdk-lambda-snapstart", |
| 19 | + "templateURL": "serverless-patterns/apigw-python-cdk-lambda-snapstart", |
| 20 | + "projectFolder": "apigw-python-cdk-lambda-snapstart", |
| 21 | + "templateFile": "app.py" |
| 22 | + } |
| 23 | + }, |
| 24 | + "resources": { |
| 25 | + "bullets": [ |
| 26 | + { |
| 27 | + "text": "AWS Lambda SnapStart", |
| 28 | + "link": "https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html" |
| 29 | + }, |
| 30 | + { |
| 31 | + "text": "API Gateway REST API", |
| 32 | + "link": "https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html" |
| 33 | + }, |
| 34 | + { |
| 35 | + "text": "AWS CDK Python Reference", |
| 36 | + "link": "https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-python.html" |
| 37 | + } |
| 38 | + ] |
| 39 | + }, |
| 40 | + "deploy": { |
| 41 | + "text": [ |
| 42 | + "python3 -m venv .venv", |
| 43 | + "source .venv/bin/activate", |
| 44 | + "pip install -r requirements.txt", |
| 45 | + "cdk bootstrap", |
| 46 | + "cdk deploy" |
| 47 | + ] |
| 48 | + }, |
| 49 | + "testing": { |
| 50 | + "text": [ |
| 51 | + "Get the CarEndpoint from stack outputs, then test the endpoint to create a new car record:", |
| 52 | + "curl --location --request POST \"$ENDPOINT/cars\" --header 'Content-Type: application/json' --data-raw '{\"make\":\"Porsche\",\"model\":\"992\",\"year\":\"2022\",\"color\":\"White\"}'", |
| 53 | + "Change the endpoint and HTTP method to test other operations:", |
| 54 | + "GET /cars/{carId} - Retrieve a car", |
| 55 | + "PUT /cars/{carId} - Update a car", |
| 56 | + "DELETE /cars/{carId} - Delete a car" |
| 57 | + ] |
| 58 | + }, |
| 59 | + "cleanup": { |
| 60 | + "text": [ |
| 61 | + "Delete the stack: <code>cdk destroy</code>." |
| 62 | + ] |
| 63 | + }, |
| 64 | + "authors": [ |
| 65 | + { |
| 66 | + "name": "Matia Rasetina", |
| 67 | + "image": "https://media.licdn.com/dms/image/v2/C4D03AQEpZLzvymfGyA/profile-displayphoto-shrink_800_800/profile-displayphoto-shrink_800_800/0/1612951581132?e=1772668800&v=beta&t=m8AkoSUFICMRk5-Gd0hEAji0N4gFSfFGuv4lbBuXcJY", |
| 68 | + "bio": "Senior Software Engineer @ Elixirr Digital", |
| 69 | + "linkedin": "matiarasetina", |
| 70 | + "twitter": "" |
| 71 | + } |
| 72 | + ], |
| 73 | + "patternArch": { |
| 74 | + "icon1": { |
| 75 | + "x": 20, |
| 76 | + "y": 50, |
| 77 | + "service": "apigw", |
| 78 | + "label": "API Gateway REST API" |
| 79 | + }, |
| 80 | + "icon2": { |
| 81 | + "x": 50, |
| 82 | + "y": 50, |
| 83 | + "service": "lambda", |
| 84 | + "label": "AWS Lambda" |
| 85 | + }, |
| 86 | + "icon3": { |
| 87 | + "x": 80, |
| 88 | + "y": 50, |
| 89 | + "service": "dynamodb", |
| 90 | + "label": "Amazon DynamoDB" |
| 91 | + }, |
| 92 | + "line1": { |
| 93 | + "from": "icon1", |
| 94 | + "to": "icon2" |
| 95 | + }, |
| 96 | + "line2": { |
| 97 | + "from": "icon2", |
| 98 | + "to": "icon3" |
| 99 | + } |
| 100 | + } |
| 101 | +} |
0 commit comments