Skip to content

Add custom MAIL FROM support to the ses module - #297

Merged
ale210 merged 2 commits into
mainfrom
ses-custom-mail-from
Nov 20, 2026
Merged

ale210 merged 2 commits into
mainfrom
ses-custom-mail-from

Conversation

@ale210

@ale210 ale210 commented Nov 20, 2026

Copy link
Copy Markdown
Member

Adds optional custom MAIL FROM support to modules/ses and turns it on for Food Oasis as bounce.foodoasis.net.

Without it, SES sends with its own amazonses.com envelope sender, so SPF doesn't align with the From domain and the SES console warns "MAIL FROM record is not aligned". DMARC already passes through DKIM; this adds SPF as a second aligned path.

  • New optional mail_from_subdomain variable (default null, so existing callers are unchanged). When set, the module configures the identity's MAIL FROM domain with USE_DEFAULT_VALUE on MX failure, and writes the MX (feedback-smtp.<region>.amazonses.com) and SPF records into zone_id. A new mail_from_records output lists them for zone-less use.
  • projects/food-oasis/ses.tf sets mail_from_subdomain = "bounce".

Expected plan: 3 to add (the MAIL FROM attributes, MX, TXT), 0 to change, 0 to destroy.

The foodoasis.net nameservers still point at the Food Oasis account's zone, so the MX and TXT records get copied there by hand after the apply (mirroring rule, #284). The Food Oasis account's own identity stays on SES's default MAIL FROM.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Terraform plan in terraform
With backend config files: terraform/prod.backend.tfvars

Plan: 3 to add, 0 to change, 0 to destroy.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+   create

Terraform will perform the following actions:

  # module.food-oasis.module.ses_foodoasis_net.aws_route53_record.mail_from["mx"] will be created
+   resource "aws_route53_record" "mail_from" {
+       allow_overwrite = (known after apply)
+       fqdn            = (known after apply)
+       id              = (known after apply)
+       name            = "bounce.foodoasis.net"
+       records         = [
+           "10 feedback-smtp.us-west-2.amazonses.com",
        ]
+       ttl             = 1800
+       type            = "MX"
+       zone_id         = "********************"
    }

  # module.food-oasis.module.ses_foodoasis_net.aws_route53_record.mail_from["spf"] will be created
+   resource "aws_route53_record" "mail_from" {
+       allow_overwrite = (known after apply)
+       fqdn            = (known after apply)
+       id              = (known after apply)
+       name            = "bounce.foodoasis.net"
+       records         = [
+           "\"v=spf1 include:amazonses.com ~all\"",
        ]
+       ttl             = 1800
+       type            = "TXT"
+       zone_id         = "********************"
    }

  # module.food-oasis.module.ses_foodoasis_net.aws_sesv2_email_identity_mail_from_attributes.this[0] will be created
+   resource "aws_sesv2_email_identity_mail_from_attributes" "this" {
+       behavior_on_mx_failure = "USE_DEFAULT_VALUE"
+       email_identity         = "*************"
+       id                     = (known after apply)
+       mail_from_domain       = "bounce.foodoasis.net"
+       region                 = "us-west-2"
    }

Plan: 3 to add, 0 to change, 0 to destroy.

❌ Error applying plan in Terraform apply (OIDC) #122

@ale210
ale210 merged commit 0d8cb68 into main Nov 20, 2026
1 check passed
ale210 added a commit that referenced this pull request Nov 20, 2026
Fixes the failed apply from #297.

`modules/ses` quoted the SPF TXT value itself, but the AWS provider
already adds the quotes Route 53 needs, so Route 53 received `""v=spf1
include:amazonses.com ~all""` and rejected it with
`InvalidCharacterString`. The MAIL FROM attributes and the MX record
were created; the TXT record was not. This writes the value unquoted,
the same way the other TXT records in the repo are written.

Expected plan: 1 to add (the `bounce.foodoasis.net` TXT record), 0 to
change, 0 to destroy.

Mail is unaffected meanwhile: the MAIL FROM status is `PENDING` and
`USE_DEFAULT_VALUE` keeps SES on its own envelope sender.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant