Skip to content

Commit

Permalink
feat(Email): Adds configuration for Strapi's email service
Browse files Browse the repository at this point in the history
  • Loading branch information
KevSanchez committed Oct 25, 2024
1 parent 3c9b9ab commit 3e6af4e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
18 changes: 17 additions & 1 deletion cms/config/plugins.ts
Original file line number Diff line number Diff line change
@@ -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')}`,
},
},
}

});
1 change: 1 addition & 0 deletions cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@strapi/plugin-cloud": "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",
Expand Down
13 changes: 13 additions & 0 deletions infrastructure/base/modules/email/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/base/modules/email/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ variable "region" {
type = string
description = "A valid AWS region to house resources."
}

variable "project" {
type = string
}
6 changes: 4 additions & 2 deletions infrastructure/base/modules/env/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ resource "aws_security_group_rule" "port_forward_postgres" {
module "email" {
source = "../email"

domain = var.domain
region = var.aws_region
domain = var.domain
region = var.aws_region
project = var.project

}

resource "aws_iam_access_key" "email_user_access_key" {
Expand Down

0 comments on commit 3e6af4e

Please sign in to comment.