-
-
Save tmclaugh/0d4f4838d909e0e0e623194b7e3f50e6 to your computer and use it in GitHub Desktop.
This file contains 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
import { Handler, Context, APIGatewayEvent, APIGatewayProxyResult } from 'aws-lambda'; | |
import DynamoDB = require('@aws-sdk/client-dynamodb'); | |
const helloWorldTableName = process.env.DDB_TABLE_NAME as string; | |
const helloWorldTablePk = process.env.DDB_TABLE_PK as string; | |
const ddbClient = new DynamoDB.DynamoDBClient({}); | |
const handler: Handler = async function(event: APIGatewayEvent, context: Context) { | |
const getItemParams: DynamoDB.GetItemCommandInput = { | |
TableName: helloWorldTableName, | |
Key: { | |
[helloWorldTablePk]: { | |
'S': 'foo' | |
} | |
} | |
}; | |
const getItem = new DynamoDB.GetItemCommand(getItemParams); | |
const item = await ddbClient.send(getItem); | |
const resp: APIGatewayProxyResult = { | |
statusCode: 200, | |
body: JSON.stringify({'message': 'hello world'}) | |
} | |
return resp; | |
} | |
export { handler } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment