Skip to content

Latest commit

 

History

History
130 lines (92 loc) · 4.65 KB

README.md

File metadata and controls

130 lines (92 loc) · 4.65 KB

Currently using AWS region ap-southeast-2

pre-requisites (TODO)

AWS prep

Create one simpledb table in the same region as the lambdas

  1. wombletech

security

Using AWS Cognito

Email handling

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>

Developer flow

local testing (build and local testing)

  1. yarn build
  2. aws-vault exec <profile> -- sam local start-api --env-vars env.json

debugging

  1. yarn build
  2. aws-vault exec <profile> -- sam local start-api --env-vars env.json -d 5858
  3. Trigger lambda ie use something like postman if function handles web requests
  4. In VSCode - use Attach to SAM CLI option (details in launch.json)

instructions (deploy)

  1. aws-vault exec <profile> -- yarn deploy

clean up

  1. aws cloudformation delete-stack --stack-name <Stack-Name>
  2. non-Prod: remove the dynamodb tables

APIs

donation

path: /donation/

The initial submitted donation, supports GET(list), POST(create), PUT(update)

schema

{
    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
}

GET (list)

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=...
}

item

path: /donation/{id}/item

The items that make up a donation, supports GET(list), POST(create), PUT(update)

schema

{
    itemId: string, // UUID, optional only for POST requests
    description: string
}

Useful information from original SAM guidance

Add a resource to your application

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.

Fetch, tail, and filter Lambda function logs

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.

Unit tests

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

Cleanup

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

Resources

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