Hi everyone,
This will just be a living cheat sheet or quick reference for using AWS SAM with nodejs. I’ll add to it as I find things that are useful or I might need again.
General AWS SAM Info:
Description | Example | More |
---|---|---|
Validate template | sam validate | |
Start AWS Sam Locally | https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html | |
Access config variable in Lambda | const CAT_BREED_TABLE = process.env.CAT_BREED_TABLE; | https://stackoverflow.com/a/48491845/522859 |
Dynamically reference another resource in template.yml | CAT_BREED_TABLE: !Ref DynamoDbCatBreedTable | https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html |
Dynamo DB Local Info:
Description | Example | More |
---|---|---|
Create table |
aws dynamodb create-table –table-name CatBreeds –attribute-definitions AttributeName=CatBreedId,AttributeType=S –key-schema AttributeName=CatBreedId,KeyType=HASH –provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 –endpoint-url http://192.168.0.31:8000 |
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.CLI.html |
List Tables | aws dynamodb list-tables –endpoint-url http://192.168.0.31:8000 | https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.CLI.html |
List All Rows in Table | aws dynamodb scan –table-name PestinatorTable –endpoint-url http://192.168.0.31:8000 | https://stackoverflow.com/a/52236600/522859 |
Node.js Info:
Description | Example | More |
---|---|---|
Run tests | npm test | – |