- More info about Globals
- More info about Function Resource "AWS::Serverless::Function"
- More info about API Event Source
- More info about Env Vars
- Root document AWS Serverless Application Model (SAM)
- Swagger Specification
make install
Run local API Gateway Server
To make http requests to your serverless API run make start
, this uses SAM CLI to emulate
both Lambda and API Gateway locally. SAM CLI takes our Events:
from template.yaml
to
bootstrap the server on http://localhost:3000/
make start
- AWS Lambda requires a flat folder with all dependencies
- In
template.yaml
, theCodeUri:
property points at our application and dependencies - We need an
S3 bucket
to upload packaged lamdba function (this can either be a bucket that you have created in the past or through runningmake config init
)
aws s3 mb s3://BUCKET_NAME
Next, run the following command to package our Lambda function to S3:
sam package \
--template-file template.yaml \
--output-template-file packaged.yaml \
--s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME
Next, the following command will create a Cloudformation Stack and deploy your SAM resources.
sam deploy \
--template-file packaged.yaml \
--stack-name sam-app \
--capabilities CAPABILITY_IAM
See Serverless Application Model (SAM) HOWTO Guide for more details in how to get started.
After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:
aws cloudformation describe-stacks \
--stack-name sam-app \
--query 'Stacks[].Outputs'
make test
# See what other make commands are available:
make help
# You can always view this readme again:
make readme
# Or if your really stuck and don't know what to do:
shutdown -h now
AWS CLI commands to package, deploy and describe outputs defined within the cloudformation stack:
make package
make deploy
make describe-stacks
NOTE: Alternatively this could be part of package.json scripts section.
Here are a few ideas that you can use to get more acquainted as to how this overall process works: