AWS Amazon SES Template

This page shows how to write Terraform and CloudFormation for Amazon SES Template and write them securely.

aws_ses_template (Terraform)

The Template in Amazon SES can be configured in Terraform with the resource name aws_ses_template. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

ses.tf#L1
resource "aws_ses_template" "mfa_false" {
  name    = var.mfa_false_template
  subject = "The MFA for the user {user_name} is not set yet!"
  html    = "<h1>Hello,</h1><p>The MFA for the user {user_name} is not set yet!</p>"
  text    = "The MFA for the user {user_name} is not set yet!"
}
ses.tf#L5
resource "aws_ses_template" "airflow_success" {
  name    = "AirflowSuccess"
  subject = "{{dag}} finished!"
  html    = "<p>Airflow {{dag}} DAG has finished succesfully.</p>"
  text    = "Airflow {{dag}} DAG has finished succesfully."
}
main.tf#L5
resource "aws_ses_template" "templates" {
  count   = length(local.templates)
  name    = local.templates[count.index].name
  subject = file(local.templates[count.index].subject)
  html    = file(local.templates[count.index].html)
  text    = file(local.templates[count.index].text)
main.tf#L2
resource "aws_ses_template" "MyTemplate" {
  name    = "MyTemplate"
  subject = "Greetings, {{name}}!"
  html    = "<h1>Hello {{name}},</h1><p>Your favorite animal is {{favoriteanimal}}.</p>"
  text    = "Hello {{name}},\r\nYour favorite animal is {{favoriteanimal}}."

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

  • arn optional computed - string
  • html optional - string
  • id optional computed - string
  • name required - string
  • subject optional - string
  • text optional - string

Explanation in Terraform Registry

Provides a resource to create a SES template.

AWS::SES::Template (CloudFormation)

The Template in SES can be configured in CloudFormation with the resource name AWS::SES::Template. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

ses.yml#L59
    Type: AWS::SES::Template
    Properties:
      Template:
        TemplateName: ${self:provider.requestDailyIdeaEmailTemplateName}
        SubjectPart: '[Daily Idea] Idea for {{ TODAY }}'
        TextPart: ${file(mail_templates/request_daily_idea/daily_idea.txt)}
email-template.yml#L5
    Type: 'AWS::SES::Template'
    Properties:
      Template:
        TemplateName: UsersList
        SubjectPart: UsersList
        TextPart:
ses-templates.yml#L3
    Type: AWS::SES::Template
    Properties:
      Template:
        TemplateName: DailyMoodSurveyEmailTemplate
        SubjectPart: How was work today?
        TextPart: How was work at {{companyName}} today? Rate your day
serverless.yml#L23
      Type: AWS::SES::Template
      Properties:
contact_template.yml#L1
Type: AWS::SES::Template
Properties:
  Template:
    TemplateName: OhlawContactTemplate-${self:provider.stage}
    SubjectPart: 'OHLaw Contact Form Submission'
    TextPart: ${file(api/resources/contact_template.txt)}
SESTemplateSpecification.json#L3
    "AWS::SES::Template.Template": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html",
      "Properties": {
        "HtmlPart": {
          "Required": false,
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html#cfn-ses-template-template-htmlpart",
SESTemplateSpecification.json#L3
    "AWS::SES::Template.Template": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html",
      "Properties": {
        "HtmlPart": {
          "Required": false,
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html#cfn-ses-template-template-htmlpart",
SESTemplateSpecification.json#L3
    "AWS::SES::Template.Template": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html",
      "Properties": {
        "HtmlPart": {
          "Required": false,
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html#cfn-ses-template-template-htmlpart",
SESTemplateSpecification.json#L3
    "AWS::SES::Template.Template": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html",
      "Properties": {
        "HtmlPart": {
          "Required": false,
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ses-template-template.html#cfn-ses-template-template-htmlpart",
ses.json#L24
      "Type" : "AWS::SES::Template",
      "Properties" : {
        "Template" : {
          "TemplateName": "double-opt-in",
          "SubjectPart": {
              "Ref": "SESSubjectPart"

Parameters

Template The content of the email, composed of a subject line, an HTML part, and a text-only part.
Required: No
Type: Template
Update requires: No interruption

Explanation in CloudFormation Registry

Specifies an email template. Email templates enable you to send personalized email to one or more destinations in a single API operation.

Frequently asked questions

What is AWS Amazon SES Template?

AWS Amazon SES Template is a resource for Amazon SES of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon SES Template?

For Terraform, the GSA/grace-cloudcustodian, AdastraCZ/aws_data_platform and inextensodigital/terraform-aws-ses-templates source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the dailyidea/dailyidea.com, s-beats/cdk-sample and johnkueh/dynamodb-graphql source code examples are useful. See the CloudFormation Example section for further details.