AWS SMTP service Terraform Infra

Vijay Nallagatla
2 min readMar 4, 2022

--

Created logo online with https://looka.com/

How often are we discussing about sending the email notifications through services to subscribed users?

Most of the digital industries most of the time require sending the Email notifications to their customers or subscribers. I wanted to integrate the email notification service to one of my projects and Gmail or Outlook is not an out of the box solution to integrate to the core of the software products or services. Here in this article I would like to provide the glimpse of integrating the AWS solution — Amazon Simple Email Service

AWS SES
Amazon Simple Email Service (SES) is a cost-effective, flexible, and scalable email service that enables developers to send mail from within any application. It has many advantages to name a few Transactional emails, Marketing emails, Bulk email communication.

In Amazon SES, a verified identity is a domain or email address that you use to send or receive email. Before you can send an email using Amazon SES, you must create and verify each identity that you’re going to use as a “From”, “Source”, “Sender”, or “Return-Path” address. Verifying an identity with Amazon SES confirms that you own it and helps prevent unauthorised use.

AWS provides two ways to verify the identity
-
Email identity
- Domain identity

Here’s a Terraform script to create an email identity and IAM resources to allow authentication to SMTP services through SES

Email verification
Sender email identity that we used to deploy the SES service resources in AWS would trigger a verification email to validate the authenticity of the email. Open the email and click the link to complete the verification process for the email address. After it’s complete, the Identity status updates to Verified

Sending an Email notification through service

Here’s a short program written in Golang to connect to the AWS’s SES service through IAM user creds which we created earlier to send an email

I used an email identity here to create SES identity resource since it’s useful for me to use just a common email to send the notifications to all of the subscribers. cons of using the email identity is restriction to use the single email and unlike domain identity to have any emails ends with domain name Ex: info@example.com, news@example.com …

To be continued next on — Creating and verifying a domain identity

--

--