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
| 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', |
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
| import { | |
| getTableName, | |
| connect, | |
| } from './table'; | |
| const dynamodb = await connect(); | |
| await dynamodb.putItem({ | |
| TableName: await getTableName(), | |
| Item: {}, | |
| }).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
| // 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); | |
| } |
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
| 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'); |
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
| export const createMigrations = (): InputMigrations<DynamoDBContext> => { | |
| return [ | |
| { | |
| name: '00-dummy-migration', | |
| async up({ context }) { | |
| await context.client | |
| .putItem({ | |
| TableName: context.tableName, | |
| Item: marshall({ | |
| pk: '#DUMMY', |
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 res = client | |
| .createTable({ | |
| TableName: tableName, | |
| AttributeDefinitions: [ | |
| { | |
| AttributeName: 'pk', | |
| AttributeType: 'S', | |
| }, | |
| { | |
| AttributeName: 'sk', |
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
| 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}" | |
| } |
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
| 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.', | |
| }, |
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
| import SES from 'aws-sdk/clients/ses'; | |
| const awsUser = new AWS.SharedIniFileCredentials(); | |
| const ses = new SES({ | |
| apiVersion: '2010-12-01', | |
| credentials: awsUser, | |
| region: '[region]', | |
| }); |
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
| 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) |