From 77e1b7ceff9819de3ba07166df6a7e2b257a5aaf Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 23 Oct 2024 18:28:40 +0200 Subject: [PATCH] feat(Email): Adds configuration for Strapi's email service --- cms/config/plugins.ts | 18 +++++++++++++++++- cms/package.json | 1 + infrastructure/base/modules/email/main.tf | 13 +++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cms/config/plugins.ts b/cms/config/plugins.ts index 56bf55f..29e3705 100644 --- a/cms/config/plugins.ts +++ b/cms/config/plugins.ts @@ -1 +1,17 @@ -export default () => ({}); +export default ({env}) => ({ + email: { + config: { + provider: 'amazon-ses', + providerOptions: { + key: env('AWS_SES_ACCESS_KEY_ID'), + secret: env('AWS_SES_ACCESS_KEY_SECRET'), + amazon: `https://email.${env('AWS_REGION')}.amazonaws.com` + }, + settings: { + defaultFrom: `strapi@${env('AWS_SES_DOMAIN')}`, + defaultReplyTo: `strapi@${env('AWS_SES_DOMAIN')}`, + }, + }, + } + +}); diff --git a/cms/package.json b/cms/package.json index a5adcf6..3241368 100644 --- a/cms/package.json +++ b/cms/package.json @@ -15,6 +15,7 @@ "@strapi/plugin-documentation": "4.25.13", "@strapi/plugin-i18n": "4.25.13", "@strapi/plugin-users-permissions": "4.25.13", + "@strapi/provider-email-amazon-ses": "5.1.1", "@strapi/strapi": "4.25.13", "pg": "8.8.0", "react": "^18.0.0", diff --git a/infrastructure/base/modules/email/main.tf b/infrastructure/base/modules/email/main.tf index 8485e7b..077d85d 100644 --- a/infrastructure/base/modules/email/main.tf +++ b/infrastructure/base/modules/email/main.tf @@ -7,10 +7,23 @@ resource "aws_ses_domain_identity" "domain_identity" { domain = var.domain } +// This represents a completed email identity verification, so it must be uncommented once +// it's been completed +resource "aws_ses_domain_identity_verification" "domain_identity_verification" { + domain = aws_ses_domain_identity.domain_identity.id +} + resource "aws_ses_domain_dkim" "domain_dkim" { domain = aws_ses_domain_identity.domain_identity.domain } +resource "aws_ses_configuration_set" "email_configuration_set" { + name = "${var.project}-email-config-set" +} +// MISSING: currently the resource to assign a configuration set to an identity seems to be available +//only in aws_ses_v2, so it needs to be done manually on the console, or be forced to recreate all ses resources + +//Permissions resource "aws_iam_user" "email_sender_user" { name = "${replace(title(replace(var.domain, "/\\W/", " ")), " ","")}EmailSender" }