Campr is an application that checks for campsite availability at certain Minnesota State parks every 6 hours for summer weekends and emails me if they're available. The app has a built in ci/cd pipeline via github actions to deploy it as an AWS Lambda function, and it uses Sendgrid to send me emails.
The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.
To use the SAM CLI, you need the following tools.
- SAM CLI - Install the SAM CLI
- Python 3 installed
- Docker - Install Docker community edition
To build the application, run the following in your shell:
sam build
You can test it with sam local invoke
But you will need aws credentials configured already, and they would need permissions to read my AWS SecretsManager, which they probably won't. Otherwise you'll get an error.
The .github/workflows/sam-pipeline.yml
defines the github workflow. You will need credentials for aws configured in your github environment or the
The SAM CLI can also emulate your application's API. Use the sam local start-api
to run the API locally on port 3000.
sam-campr$ sam local start-api
sam-campr$ curl http://localhost:3000/
Things to set up:
- sendgrid creds and store them in aws secretsmanager
- configure the lambda function role to read from aws secrets manager
- an aws user with permissions to deploy the lambda function
- store creds for that user in a github environment