Skip to content

Instantly share code, notes, and snippets.

View mxro's full-sized avatar

Max Rohde mxro

View GitHub Profile
import { Table, Entity } from 'dynamodb-toolbox';
export function createTable<Name extends string>(
dynamoDB: DynamoDB.DocumentClient,
tableName: string
): Table<Name, 'pk', 'sk'> {
return new Table({
name: tableName,
partitionKey: 'pk',
sortKey: 'sk',
import {
getTableName,
connect,
} from './table';
const dynamodb = await connect();
await dynamodb.putItem({
TableName: await getTableName(),
Item: {},
}).promise();
// ensure table initialisation and migrations are only performed once per cold start
const coldStartKey = getColdStartKey(packageConfig, deploymentName);
if (!coldStart.has(coldStartKey)) {
await assertTable(packageConfig, deploymentName, client);
await performMigrations(packageConfig, deploymentName, migrations, client);
coldStart.set(coldStartKey, true);
}
it('Should connect to local table', async () => {
const tableName = await getTableName();
assert(tableName);
const dynamoDB = await connect();
assert(dynamoDB);
const tableInfo = await dynamoDB
.describeTable({ TableName: tableName })
.promise();
assert(tableInfo.Table?.TableStatus === 'ACTIVE');
export const createMigrations = (): InputMigrations<DynamoDBContext> => {
return [
{
name: '00-dummy-migration',
async up({ context }) {
await context.client
.putItem({
TableName: context.tableName,
Item: marshall({
pk: '#DUMMY',
const res = client
.createTable({
TableName: tableName,
AttributeDefinitions: [
{
AttributeName: 'pk',
AttributeType: 'S',
},
{
AttributeName: 'sk',
resource "aws_ses_domain_identity" "ses_domain" {
domain = var.domain
}
resource "aws_ses_domain_mail_from" "main" {
domain = aws_ses_domain_identity.ses_domain.domain
mail_from_domain = "mail.${var.domain}"
}
await ses
.sendEmail({
Destination: { ToAddresses: ['[email protected]'] },
Message: {
Subject: { Charset: 'UTF-8', Data: 'Test email' },
Body: {
Text: {
Charset: 'UTF-8',
Data: 'This is the message body in text format.',
},
import SES from 'aws-sdk/clients/ses';
const awsUser = new AWS.SharedIniFileCredentials();
const ses = new SES({
apiVersion: '2010-12-01',
credentials: awsUser,
region: '[region]',
});
resource "aws_route53_record" "amazonses_verification_record" {
zone_id = data.aws_route53_zone.main.zone_id
name = "_amazonses.${var.domain}"
type = "TXT"
ttl = "600"
records = [join("", aws_ses_domain_identity.ses_domain.*.verification_token)]
}
resource "aws_ses_domain_dkim" "ses_domain_dkim" {
domain = join("", aws_ses_domain_identity.ses_domain.*.domain)