This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require("aws-sdk"); | |
const documentClient = new AWS.DynamoDB.DocumentClient(); | |
exports.handler = async event => { | |
const params = { | |
TableName: "books" // The name of your DynamoDB table | |
}; | |
try { | |
// Utilising the scan method to get all items in the table | |
const data = await documentClient.scan(params).promise(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require("aws-sdk"); | |
const documentClient = new AWS.DynamoDB.DocumentClient(); | |
exports.handler = async event => { | |
const { | |
pathParameters: { id } | |
} = event; // Extracting an id from the request path | |
const params = { | |
TableName: "books", // The name of your DynamoDB table | |
Key: { id } // They key of the item you wish to find. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require("aws-sdk"); | |
const documentClient = new AWS.DynamoDB.DocumentClient(); | |
exports.handler = async event => { | |
const { | |
pathParameters: { id } | |
} = event; | |
const params = { | |
TableName: "books", | |
Key: { id } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require("aws-sdk"); | |
const documentClient = new AWS.DynamoDB.DocumentClient(); | |
exports.handler = async event => { | |
const { | |
pathParameters: { id } | |
} = event; | |
const { title } = JSON.parse(event.body); | |
const params = { | |
TableName: "books", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" # (1) | |
Transform: AWS::Serverless-2016-10-31 # (1) | |
Resources: # (2) | |
DynamoBooksTable: # (3) | |
Type: AWS::Serverless::SimpleTable # (4) | |
Properties: | |
TableName: books # (5) | |
PrimaryKey: | |
Name: id # (6) | |
Type: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" # (1) | |
Transform: AWS::Serverless-2016-10-31 # (1) | |
Resources: # (2) | |
DynamoBooksTable: # (3) | |
Type: AWS::Serverless::SimpleTable # (4) | |
Properties: | |
TableName: books # Naming our table | |
PrimaryKey: | |
Name: id # Setting the primary key of each item in our database as id | |
Type: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
DynamoBooksTable: | |
Type: AWS::Serverless::SimpleTable | |
Properties: | |
TableName: books | |
PrimaryKey: | |
Name: id | |
Type: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
DynamoBooksTable: | |
Type: AWS::Serverless::SimpleTable | |
Properties: | |
TableName: books | |
PrimaryKey: | |
Name: id | |
Type: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: 2010-09-09 # (1) | |
Resources: # (2) | |
VPC: # (3) | |
Type: AWS::EC2::VPC # (4) | |
Properties: | |
CidrBlock: 10.0.0.0/16 # (5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PublicSubnetA: # (1) | |
Type: AWS::EC2::Subnet # (2) | |
Properties: | |
VpcId: !Ref VPC # (3) | |
CidrBlock: 10.0.0.0/24 # (4) | |
AvailabilityZone: !Select [0, !GetAZs ] # (5) | |
PublicSubnetB: | |
Type: AWS::EC2::Subnet | |
Properties: |