Skip to content

Commit 4ebae27

Browse files
sean-navapbcSean Thomas
andauthored
⚠️ [942] Replace Amazon Pinpoint with direct SES usage (#968)
## Ticket Resolves #942 ## Changes - Updated template-only-app/notifications.py to use SES - Removed Pinpoint resources (main.tf, email.tf, access_control.tf) - Updated IAM policies to SES-only - Updated environment variables to use AWS_SES_FROM_EMAIL - Updated all Pinpoint references in comments and docs - Removed Pinpoint VPC endpoint - Removed mobiletargeting from AWS services - ## Context for reviewers - https://p-231-app-dev-1629703657.us-east-1.elb.amazonaws.com/email-notifications - Emails successfully sent using new SES direct integration ### FOR RELEASE If you want to test SES alongside your existing Pinpoint setup before fully migrating, you can adopt a gradual approach: #### Phase 1: Add SES alongside Pinpoint (Optional) Keep your Pinpoint resources - Don't delete aws_pinpoint_app.app or related resources yet Add the SES environment variable to your service configuration `infra/<app_name>/service/notifications.tf`: ``` notifications_environment_variables = local.notifications_config != null ? { # Existing Pinpoint variables AWS_PINPOINT_APP_ID = module.notifications[0].app_id # New SES variable (can construct inline to avoid output changes) AWS_SES_FROM_EMAIL = local.notifications_config.sender_display_name != null ? "${local.notifications_config.sender_display_name} <${local.notifications_config.sender_email}>" : local.notifications_config.sender_email } : {} ``` Update your application code to use the sesv2 client instead of pinpoint, referencing AWS_SES_FROM_EMAIL Test that SES email sending works in your environment #### Phase 2: Remove Pinpoint Once you've confirmed SES works: Apply the full migration by merging/pulling the changes from this PR Run terraform apply to destroy the Pinpoint resources This approach minimizes risk by allowing you to validate SES functionality before removing Pinpoint infrastructure. > Provide evidence that the code works as expected. Explain what was done for testing and the results of the test plan. Include screenshots, [GIF demos](https://www.cockos.com/licecap/), shell commands or output to help show the changes working as expected. ProTip: you can drag and drop or paste images into this textbox. Co-authored-by: Sean Thomas <sean.thomas@navapbc.com>
1 parent c477511 commit 4ebae27

File tree

14 files changed

+40
-97
lines changed

14 files changed

+40
-97
lines changed

infra/modules/network/resources/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variable "enable_command_execution" {
66

77
variable "enable_notifications" {
88
type = bool
9-
description = "Whether the application(s) in this network need AWS Pinpoint access."
9+
description = "Whether the application(s) in this network need email notification access via SES."
1010
default = false
1111
}
1212

infra/modules/network/resources/vpc_endpoints.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717
var.enable_command_execution ? ["ssmmessages"] : [],
1818

1919
# AWS services used by notifications
20-
var.enable_notifications ? ["pinpoint", "email-smtp"] : [],
20+
var.enable_notifications ? ["email-smtp"] : [],
2121
)
2222

2323
# S3 and DynamoDB use Gateway VPC endpoints. All other services use Interface VPC endpoints

infra/modules/notifications-email-domain/resources/access_control.tf

Lines changed: 0 additions & 31 deletions
This file was deleted.

infra/modules/notifications-email-domain/resources/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ locals {
99
}
1010

1111
# Verify email sender identity.
12-
# Docs: https://docs.aws.amazon.com/pinpoint/latest/userguide/channels-email-manage-verify.html
12+
# Docs: https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html
1313
resource "aws_sesv2_email_identity" "sender_domain" {
1414
email_identity = var.domain_name
1515
configuration_set_name = aws_sesv2_configuration_set.email.configuration_set_name

infra/modules/notifications/resources/access_control.tf

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
resource "aws_iam_policy" "access" {
22
name = "${var.name}-notifications-access"
3-
description = "Policy for calling SendMessages and SendUsersMessages on Pinpoint app ${var.name}"
3+
description = "Policy for sending emails via SES for ${var.name}"
44

55
policy = jsonencode({
66
Version = "2012-10-17"
77
Statement = [
8-
# From https://docs.aws.amazon.com/pinpoint/latest/developerguide/permissions-actions.html#permissions-actions-apiactions-messages
9-
{
10-
Effect = "Allow"
11-
Action = [
12-
"mobiletargeting:SendMessages",
13-
"mobiletargeting:SendUsersMessages"
14-
]
15-
Resource = "${aws_pinpoint_app.app.arn}/messages"
16-
},
17-
18-
# From https://docs.aws.amazon.com/pinpoint/latest/developerguide/permissions-ses.html
8+
# Permissions for sending emails via SES
9+
# From https://docs.aws.amazon.com/ses/latest/dg/control-user-access.html
1910
{
2011
Effect = "Allow"
2112
Action = [

infra/modules/notifications/resources/email.tf

Lines changed: 0 additions & 5 deletions
This file was deleted.

infra/modules/notifications/resources/main.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
output "app_id" {
2-
value = aws_pinpoint_app.app.application_id
3-
}
4-
51
output "access_policy_arn" {
62
value = aws_iam_policy.access.arn
73
}
4+
5+
output "from_email" {
6+
value = var.sender_display_name != null ? "${var.sender_display_name} <${var.sender_email}>" : var.sender_email
7+
}

infra/project-config/aws_services.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ locals {
5454
// Amazon CloudWatch Logs – Collects, monitors, and analyzes log data from AWS services.
5555
"logs",
5656

57-
// Amazon Pinpoint – Provides customer engagement and messaging capabilities. Used for notifications.
58-
"mobiletargeting",
59-
6057
// Amazon EventBridge Pipes – Connects event producers to consumers with filtering and enrichment.
6158
"pipes",
6259

@@ -84,7 +81,7 @@ locals {
8481
// AWS Cloud Map – Provides service discovery for microservices and applications.
8582
"servicediscovery",
8683

87-
// Amazon Simple Email Service (SES) – An email sending and receiving service. Used in conjunction with Amazon Pinpoint for notifications.
84+
// Amazon Simple Email Service (SES) – An email sending and receiving service. Used for email notifications.
8885
"ses",
8986

9087
// Amazon Simple Notification Service (SNS) – A pub/sub messaging service.

infra/{{app_name}}/app-config/env-config/notifications.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Notifications configuration
22
locals {
33
notifications_config = var.enable_notifications && var.domain_name != null && local.network_config.domain_config.hosted_zone != null ? {
4-
# Pinpoint app name.
4+
# Notification configuration name.
55
name = "${var.app_name}-${var.environment}"
66

77
# Configure the name that users see in the "From" section of their inbox,

0 commit comments

Comments
 (0)