robertsonsamuel / serverless-ses-template

Serverless template sync plugin for Amazon Simple Email Service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serverless NPM npm Build Status

Template sync plugin for Amazon Simple Email Service

A serverless plugin that allows automatically creating, updating and removing AWS SES Templates using a configuration file and keeps your AWS SES Templates synced with your configuration file.

REQUIRES nodejs 8.10+


⚡ Features

  • Allows declaring email templates that will be synced in pre-deploy phase
  • Allows you to optionally add stage to template names while syncing
  • Allows you to list and delete SES template by specified name

Installation

npm install @haftahave/serverless-ses-template

Configuration

  • All @haftahave/serverless-ses-template configuration parameters are optional
# add to your serverless.yml

plugins:
  - '@haftahave/serverless-ses-template'

custom:
  sesTemplatesAddStageAlias: true                        # Specifies whether to add stage and alias (if present) to template name (default false)
  sesTemplatesConfigFile: './custom-config-file/path.js' # Config file path (default './ses-email-templates/index.js')
  sesTemplatesRegion: 'us-west-2'                        # Specifies AWS region for SES templates

Template configuration file

Template configuration file should be an array of objects:

module.exports = [{
    name: 'example_name',
    subject: 'Your subject',
    html: '<h1>Hello world!</h1>',
    text: 'Hello world!',
}];

Real world example see here.

Plugin resolves region in the following order:

  • CLI argument named sesTemplatesRegion - top priority
  • serverless.yml custom key named sesTemplatesRegion
  • CLI argument named region
  • fallback to default region resolving (first region in first stage defined in serverless.yml)

Plugin resolves template configuration file path in the following order:

  • CLI argument named sesTemplateConfig - top priority
  • serverless.yml custom key named sesTemplatesConfigFile
  • fallback to default ./ses-email-templates/index.js

Usage and command line options

Deploy

Run sls ses-template deploy in order to sync your email templates.

Optional CLI options:

--sesTemplatesRegion The region used to populate your templates. Default: see "Region fallback sequence" in readme.md. [OPTIONAL]
--sesTemplateConfig  Template configuration file path. Default: see "Template configuration file sequence" in readme.md. [OPTIONAL]
--stage        The stage used to populate your templates. Default: the first stage found in your project. [OPTIONAL]
--alias        Template alias, works only with sesTemplatesAddStageAlias option enabled. [OPTIONAL]
--removeMissed Set this flag in order to remove templates those are not present in your configuration file. [OPTIONAL]

List templates

Run sls ses-template list in order to list your email templates.

CLI options:

--sesTemplatesRegion The region used to list your templates. Default: see "Region fallback sequence" in readme.md. [OPTIONAL]
--filter <string>    Display templates that contain <string>. [OPTIONAL]

Delete template

Run sls ses-template delete --template template_name_goes_here in order to delete your email template.

CLI options:

--template    The template name you are going to delete [REQUIRED]
--sesTemplatesRegion The region used to populate your templates. Default: see "Region fallback sequence" in readme.md. [OPTIONAL]
--stage       The stage used to populate your templates. Default: the first stage found in your project. [OPTIONAL]
--alias       Template alias, works only with sesTemplatesAddStageAlias option enabled. [OPTIONAL]

Links

License

MIT

About

Serverless template sync plugin for Amazon Simple Email Service

License:MIT License


Languages

Language:JavaScript 99.9%Language:HTML 0.1%