@wraps.dev/cdk package provides a WrapsEmail CDK construct that deploys SES infrastructure — IAM roles, configuration sets, event pipelines, and DNS records — directly into your CDK stack. Use it when you manage your AWS infrastructure as code with CDK.
Installation
aws-cdk-lib and constructs, which your CDK project already provides:
Prerequisites
- Node.js 20+
- AWS CDK 2.x installed and bootstrapped in your account
- AWS credentials configured
Quick start
AddWrapsEmail to any CDK stack. At minimum, provide an OIDC configuration so the SDK can authenticate with your infrastructure.
Configuration options
Authentication
Vercel OIDC configuration. Mutually exclusive with
oidc.Custom OIDC provider configuration for GitHub Actions, GitLab CI, or other OIDC-compatible platforms. Mutually exclusive with
vercel.Domain
Primary sending domain. Creates an SES domain identity with DKIM. DKIM CNAME records are output for manual DNS configuration, or automatically created if you provide
hostedZoneId.Route53 hosted zone ID for your domain. When provided, the construct automatically creates DKIM, SPF, DMARC, and MAIL FROM DNS records. If omitted, DNS records are printed as CloudFormation outputs.
Subdomain for the MAIL FROM domain. Combined with
domain — e.g. mail + example.com → mail.example.com. Improves deliverability.Open/click tracking
Open and click tracking configuration.
Event tracking
Enables the event pipeline: EventBridge → SQS → Lambda → DynamoDB. When set, email send, delivery, bounce, and complaint events are captured and optionally stored.
Email settings
Enable SES reputation metrics in CloudWatch.
Require TLS for all outbound connections.
Enable sending on the SES configuration set.
Provision a dedicated sending IP address. Adds approximately $25/month to AWS costs.
Bounce and complaint suppression.
SMTP
Create an IAM user with SMTP credentials for legacy systems (WordPress, PHP mailers, etc.).
Archiving
Archive full email content via AWS Mail Manager for compliance or debugging.
Infrastructure
Removal policy for stateful resources such as the DynamoDB history table. Defaults to
RETAIN so infrastructure persists when the stack is deleted.Forward events to the Wraps hosted dashboard via EventBridge API Destination. Only required if you use the Wraps platform.
Outputs
The construct automatically creates CloudFormation outputs for the most commonly referenced values (WrapsEmailRoleArn, WrapsEmailConfigSetName, etc.) that you can read in your CDK app or retrieve with the AWS CLI after deploying.
Access the underlying CDK resource objects directly via .resources:
| Property | Type | Description |
|---|---|---|
resources.role | iam.IRole | IAM role for SDK authentication |
resources.configSet | ses.IConfigurationSet | SES configuration set |
resources.emailIdentity | ses.IEmailIdentity | undefined | SES email identity (if domain configured) |
resources.oidcProvider | iam.IOpenIdConnectProvider | undefined | OIDC provider (if OIDC configured) |
resources.table | dynamodb.ITable | undefined | DynamoDB history table (if events enabled) |
resources.queue | sqs.IQueue | undefined | SQS event queue (if events configured) |
resources.dlq | sqs.IQueue | undefined | SQS dead-letter queue (if events configured) |
resources.eventProcessor | lambda.IFunction | undefined | Event processor Lambda (if history enabled) |
resources.eventRule | events.IRule | undefined | EventBridge rule (if events configured) |
resources.smtpUser | iam.IUser | undefined | SMTP IAM user (if SMTP enabled) |
resources.smtpAccessKey | iam.AccessKey | undefined | SMTP access key (if SMTP enabled) |
Grant methods
The construct provides CDK-style grant methods that returniam.Grant for chaining.
grantReadHistory() and grantConsumeEvents() throw if called when events is not configured.Accessing underlying resources
All CDK constructs are accessible via.resources for advanced customization such as adding tags, modifying removal policies, or wiring additional IAM grants:
