Skip to content

feat(ses): support the AWS default credential chain - #284

Merged
mrz1836 merged 1 commit into
masterfrom
feat/ses-default-credential-chain
Sep 23, 2026
Merged

mrz1836 merged 1 commit into
masterfrom
feat/ses-default-credential-chain

Conversation

@mrz1836

@mrz1836 mrz1836 commented Sep 23, 2026

Copy link
Copy Markdown
Owner

What Changed

Add an AwsSesUseIAMRole option to the AWS SES provider. When enabled, StartUp loads the SES client using the AWS default credential chain (IAM role, environment variables, shared config, or web identity) instead of requiring static access keys. Static credentials, when supplied, continue to take precedence, so existing configurations are unchanged.

  • New MailService.AwsSesUseIAMRole config field (json / mapstructure tag aws_ses_use_iam_role).
  • StartUp now loads SES when either static keys or the IAM-role option is set.
  • Extracted the SES client construction into loadAwsSesService to keep StartUp flat.
  • README feature note + a runnable awsSesIAMRoleExample.

Why It Was Necessary

When running on AWS compute (Lambda, ECS, EC2), credentials are provided by an attached IAM role and no static keys exist. Previously the SES provider only loaded when both an access id and secret key were set, so role-based deployments could not use it. This lets SES authenticate the same way the rest of the AWS SDK does by default.

Testing Performed

  • go build ./..., go vet ./..., go test ./... — all pass.
  • Added TestMailService_StartUpAwsSesIAMRole: SES loads via the default chain with the option set and no static keys, and is skipped when neither keys nor the option are present. Existing static-key coverage in TestMailService_StartUp is unchanged.
  • golangci-lint passes with 0 issues; loadAwsSesService is ~93% covered.

Impact / Risk

  • Backward compatible: no behavior change for existing static-key configurations; the new path is opt-in via AwsSesUseIAMRole.
  • No new dependencies — uses the already-imported aws-sdk-go-v2/config default credential chain.

Notifications

Allow the AWS SES provider to authenticate via the AWS default
credential chain (IAM role, environment, shared config, web identity)
instead of requiring static access keys.

Add the AwsSesUseIAMRole option: when set, StartUp loads the SES client
without static credentials, letting the SDK resolve them from its
default provider chain. Static keys, when supplied, continue to take
precedence, so existing configurations are unchanged.

Extract the SES client construction into loadAwsSesService to keep
StartUp flat, cover the IAM-role path in the StartUp tests, document
the option in the README, and add a usage example.
@github-actions github-actions Bot added the feature Any new significant addition label Sep 23, 2026
@github-actions github-actions Bot added the size/M Medium change (51-200 lines) label Sep 23, 2026
@mrz1836
mrz1836 merged commit c5ca1af into master Sep 23, 2026
23 checks passed
@github-actions
github-actions Bot deleted the feat/ses-default-credential-chain branch September 23, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Any new significant addition size/M Medium change (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址