亚马逊简易电子邮件服务模板同步插件
允许自动创建、更新和删除的无服务器插件 AWS SES 模板使用配置文件并保存您的 AWS SES 模板 与您的配置文件同步 .
需求 节点20+
: zap: 特性
- 允许宣布在部署前阶段同步的电子邮件模板
- 允许您在同步时在模板名称中选择添加舞台
- 允许您按指定名称列出和删除 SES 模板
实例
🚨 重要通知数字 :
从 6.x (单位:千美元) 版本,插件已切换到 纯无害环境管理 并需要无服务器 页:1 或更新.
如果你需要的话 CJS 软件包 使用情况 5.x 电话 插件序列
如果您需要兼容性
serverless<3.0.0标记 页:1。 。 。 .
安装
npm install @haftahave/serverless-ses-template
配置
- 全体 @haftahave/ serverless-ses-template (英语) 配置参数为可选
# add to your serverless.yml
plugins:
- '@haftahave/serverless-ses-template'
custom:
sesTemplates:
addStage: true # Specifies whether to add stage to template name (default false)
configFile: './custom-config-file/path.js' # Config file path (default './ses-email-templates/index.js')
deployHook: 'after:deploy:deploy' # Specifies serverless lifecycle event plugin use to deploy templates (default 'before:deploy:deploy')
disableAutoDeploy: true # Specifies whether to sync templates while sls deploy and remove (default false)
region: 'us-west-2' # Specifies AWS region for SES templates (not required)
removeMissed: false # Set this flag in order to remove templates those are not present in your configuration file. (not required, default false)
模板配置文件
模板配置文件应该是返回对象数组(需要所有密钥)的async函数:
/**
* @param {Object} serverless - Serverless instance
* @param {Object} options - runtime options
* @returns {Promise<{name: string, subject: string, html: string, text: string}[]>}
*/
const templateConfiguration = async (serverless, options) => [{
name: 'example_name',
subject: 'Your subject',
html: '<h1>Hello world!</h1>',
text: 'Hello world!',
}];
export default templateConfiguration
真实世界的例子 这里。 。 。 .
插件按以下顺序解决区域 :
- 名为 CLI 的参数
sesTemplatesRegion- 最高优先级 serverless.yml已命名的插件配置参数region- 名为 CLI 的参数
region - 回落到默认区域解析( 在无服务器. yml 中定义的第一阶段的第一个区域)
插件按以下顺序解决模板配置文件路径 :
- 名为 CLI 的参数
sesTemplateConfig- 最高优先级 serverless.yml已命名的插件配置参数configFile- 倒向默认
./ses-email-templates/index.js
使用和命令行选项
部署
运行 sls ses-template deploy 以同步您的电子邮件模板.
可选 CLI 选项 :
--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]
--removeMissed Set this flag in order to remove templates those are not present in your configuration file. [OPTIONAL]
列表模板
运行 sls ses-template list 以列出您的电子邮件模板.
CLI 选项 :
--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]
删除模板
运行 sls ses-template delete --template template_name_goes_here 删除您的电子邮件模板.
CLI 选项 :
--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]
链接
许可证
麻省理工学院