Currently using AWS region ap-southeast-2
- SAM CLI - https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html
- AWS-VAULT CLI - https://github.com/99designs/aws-vault
- Docker - required for local testing of the api - https://hub.docker.com/search/?type=edition&offering=community
- Configure
~/.aws/config
Create one simpledb table in the same region as the lambdas
- wombletech
Using AWS Cognito
Using AWS SES
- you'll need access to your DNS to enter records from the current region (sending) and us-east-1 (receiving)
NOTE:
- incoming email support is only suppported in a few regions e.g. us-east-1
- to avoid messing with current MX configuration use a subdomain to send emails to and from eg mailer.<yourdomain.com>
yarn build
aws-vault exec <profile> -- sam local start-api --env-vars env.json
yarn build
aws-vault exec <profile> -- sam local start-api --env-vars env.json -d 5858
- Trigger lambda ie use something like postman if function handles web requests
- In VSCode - use
Attach to SAM CLI
option (details inlaunch.json
)
aws-vault exec <profile> -- yarn deploy
aws cloudformation delete-stack --stack-name <Stack-Name>
- non-Prod: remove the dynamodb tables
path: /donation/
The initial submitted donation, supports GET(list), POST(create), PUT(update)
{
donationId?: string, // UUID, optional only for POST requests
name: string,
email: string,
phoneNumber: string,
suburb: string,
region: string,
donationType: string,
description: string,
submitDate?: string, // UTC-Datetime, read-only
}
Supports paging using a cursor (see DynamoDB and ExclusiveStartKey)
{
items: [],
cursor: string // pass this to the next GET via querystring to support paging ie ?cursor=...
}
path: /donation/{id}/item
The items that make up a donation, supports GET(list), POST(create), PUT(update)
{
itemId: string, // UUID, optional only for POST requests
description: string
}
The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in the SAM specification, you can use standard AWS CloudFormation resource types.
To simplify troubleshooting, SAM CLI has a command called sam logs
. sam logs
lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.
NOTE
: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
WombletechRHoK$ sam logs -n HelloWorldFunction --stack-name WombletechRHoK --tail
You can find more information and examples about filtering Lambda function logs in the SAM CLI Documentation.
Tests are defined in the hello-world/tests
folder in this project. Use NPM to install the Mocha test framework and run unit tests.
WombletechRHoK$ cd hello-world
hello-world$ npm install
hello-world$ npm run test
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:
aws cloudformation delete-stack --stack-name WombletechRHoK
See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: AWS Serverless Application Repository main page