Deploy via CDK
Prerequisites
Section titled “Prerequisites”- Node.js and npm installed
- AWS CDK Toolkit:
npm install -g aws-cdk - Install the required packages:
npm install aws-cdk-lib @serverlessinbox/mailbox @serverlessinbox/mailbox-cognito constructsMinimal stack
Section titled “Minimal stack”bin/app.ts
Section titled “bin/app.ts”import * as cdk from 'aws-cdk-lib';import { MailboxStack } from '../lib/stack';
const app = new cdk.App();
new MailboxStack(app, 'MailboxStack', { env: { region: 'eu-west-1' },});lib/stack.ts
Section titled “lib/stack.ts”import * as cdk from 'aws-cdk-lib';import * as route53 from 'aws-cdk-lib/aws-route53';import { Construct } from 'constructs';import { MailboxUserPool } from '@serverlessinbox/mailbox-cognito';import { Mailbox } from '@serverlessinbox/mailbox';
export class MailboxStack extends cdk.Stack { constructor(scope: Construct, id: string, props?: cdk.StackProps) { super(scope, id, props);
const domainName = 'mail.example.com'; const hostedZoneId = 'Z1D633PJN98FT9';
const hostedZone = route53.HostedZone.fromHostedZoneId( this, 'HostedZone', hostedZoneId, );
const userPool = new MailboxUserPool(this, 'MailboxUserPool', { domainName, cognitoDomainPrefix: 'my-mailbox', });
new Mailbox(this, 'Mailbox', { domainName, hostedZone, userPool, }); }}Replace domainName, hostedZoneId, and cognitoDomainPrefix with values appropriate for your deployment.
Deploy
Section titled “Deploy”cdk deployCDK will display a summary of the IAM and security changes to be applied and prompt for confirmation before creating any resources.
Post-deploy steps
Section titled “Post-deploy steps”After deploying, follow the post-deploy steps in Deploy via CloudFormation.