Skip to content

Instantly share code, notes, and snippets.

View mxro's full-sized avatar

Max Rohde mxro

View GitHub Profile
import { build } from 'esbuild';
import { pnpPlugin } from '@yarnpkg/esbuild-plugin-pnp';
build({
plugins: [pnpPlugin()],
bundle: true,
entryPoints: ['src/lambda.ts'],
external: ['aws-sdk'],
minify: true,
format: 'cjs',
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
const withPlugins = require('next-compose-plugins');
const getLocalPackages = require('./scripts/getLocalPackages');
const localPackages = getLocalPackages.getLocalPackages();
const withTM = require('next-transpile-modules')(localPackages);
resource "aws_lambda_function" "main" {
function_name = var.lambda_name
filename = data.archive_file.empty_lambda.output_path
handler = "lambda.handler"
runtime = "nodejs12.x"
memory_size = 2048
timeout = 900
awsCli({
credentials: await getAWSUser(params.deployment.awsUser),
region: params.deployment.awsRegion,
command: `lambda update-function-code --function-name ${readTerraformStateVariable(
params.deploymentState,
'lambda_function_name'
)} --zip-file fileb://${targetArchive}`,
});
{
"$schema": "./schemas/package.schema.json",
"name": "lambda-express-template",
"template": "lambda-express",
"templateVersion": "0.1.0",
"configuration": {},
"deployments": [
{
"name": "prod",
"awsRegion": "us-west-2",
data "aws_route53_zone" "main" {
name = var.hosted_zone_domain
private_zone = false
}
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)
import SES from 'aws-sdk/clients/ses';
const awsUser = new AWS.SharedIniFileCredentials();
const ses = new SES({
apiVersion: '2010-12-01',
credentials: awsUser,
region: '[region]',
});
await ses
.sendEmail({
Destination: { ToAddresses: ['test@test.com'] },
Message: {
Subject: { Charset: 'UTF-8', Data: 'Test email' },
Body: {
Text: {
Charset: 'UTF-8',
Data: 'This is the message body in text format.',
},
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}"
}