-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.ts
49 lines (42 loc) · 1.06 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { CfnTemplate } from 'aws-cdk-lib/aws-ses';
import { Construct } from 'constructs';
import mjml2html = require('mjml'); // eslint-disable-line @typescript-eslint/no-require-imports
/**
* Properties for a MjmlTemplate
*/
export interface MjmlTemplateProps {
/**
* The name of the template
*
* @default - a CloudFormation generated name
*/
readonly templateName?: string;
/**
* The subject line of the email
*/
readonly subject: string;
/**
* The MJML for the email
*/
readonly mjml: string;
}
/**
* SES email template from [MJML](https://mjml.io/)
*/
export class MjmlTemplate extends Construct {
/**
* The name of the template
*/
public readonly templateName: string;
constructor(scope: Construct, id: string, props: MjmlTemplateProps) {
super(scope, id);
const template = new CfnTemplate(this, 'Resource', {
template: {
templateName: props.templateName,
subjectPart: props.subject,
htmlPart: mjml2html(props.mjml).html,
},
});
this.templateName = template.attrId;
}
}