- Create a highly-available Serverless architecture on AWS using Terraform. The architecture consists of:
- Cloudfront
- API Gateway
- Lambda
- RDS (MySQL)
- Create a Lambda function in JavaScript and host it on the above infrastructure. The function returns a simple message in JSON and a 200 HTTP status code.
Once the database is created, the database schema is set up using a second lambda function:
- Make sure you have access to AWS via your Access Key ID and Secret Access Key.
- Go to the staging folder and do
terraform init
and thenterraform apply
. - At the end of the
terraform apply
it will output the CloudFront domain name. Use this domain name to access the API as decribed below.
Endpoint | HTTP Method | Result |
---|---|---|
/helloworld | any | Returns "Hello World" |
/message | POST | Adds a message to the message table in the database |
/message | anything except POST | Returns messages in database |
anything else | any | Returns 404 not found error |
The Cloud Front distribution is set up to cache the response to GET requests, so if you do GET /message, then POST /message, then GET /message again, the response will not contain the new message unless the TTL has expired.
- Allowing more than 2 AZs
- Tests
- Better descriptions of variables
- More consistent naming
- Readme for each module