az-cdk Constructs for the AWS CDK (AmaZon)
az-cdk implements some constructs for use with the fantastic AWS CDK tool.
Installation
yarn add @cpmech/az-cdk
Examples
Cognito
import { App, Stack } from '@aws-cdk/core';
import { CognitoConstruct } from '@cpmech/az-cdk';
const app = new App();
const stack = new Stack(app, 'CognitoStack');
const construct = new CognitoConstruct(stack, 'Cognito', {
emailSendingAccount: 'info@mydomain.com',
poolName: 'my-users',
});
Receive Emails (SES, SNS, and SQS)
import { App, Stack } from '@aws-cdk/core';
import { ReceiveEmailSQSConstruct } from '@cpmech/az-cdk';
const app = new App();
const stack = new Stack(app, 'EmailsStack');
new ReceiveEmailSQSConstruct(stack, 'EmailSQS', {
ruleSetName: 'my-emails',
emails: [
{
email: envars.TESTER_EMAIL,
topic: 'my-emails',
},
],
});
Lambda and API Gateway
import { App, Stack } from '@aws-cdk/cdk';
import { LambdaApi } from '@cpmech/az-cdk';
const app = new App();
const stack = new Stack(app, 'ServiceStack');
new LambdaApiConstruct(stack, 'API', {
gatewayName: 'TestAPI',
assetsDir: 'dist',
cognitoId: '<cognito-user-pool-id>',
lambdas: [
{
filenameKey: 'open',
handlerName: 'open',
httpMethods: ['GET'],
route: 'open',
unprotected: true,
},
{
filenameKey: 'closed',
handlerName: 'closed',
httpMethods: ['GET'],
route: 'closed',
},
],
});