Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/set-up-ses-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Sets up the account's Amazon SES sending for company Email's outbound relay
# (devantler-tech/platform#5481): the pay-per-use pricing plan, then a request
# for production access, then a readback of the account's state.
#
# Neither setting has a Crossplane resource, so a reviewed workflow makes the
# two account calls instead of anyone using the AWS console. It runs only from
# main, after a typed confirmation, with the platform-owned ses-account-setup
# role. That role trusts only this repository's main branch and holds only
# ses:GetAccount, ses:PutAccountDetails and ses:PutAccountPricingAttributes in
# eu-central-1. It checks out no code and prints only fixed account fields.
#
# Re-running is safe. The plan is written only when pay-per-use is neither
# active nor scheduled, and production access is requested only while it is
# neither granted nor already under review.
name: Set Up SES Account

on:
workflow_dispatch:
inputs:
confirm:
description: Type set-up-ses-account to set the SES plan and request production access
required: true
type: string

permissions: {}

concurrency:
group: set-up-ses-account
cancel-in-progress: false

jobs:
set-up:
name: 📮 Set up the SES account
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
id-token: write
env:
AWS_REGION: eu-central-1
ROLE_ARN: arn:aws:iam::939001610192:role/ses-account-setup
steps:
- name: 🔒 Refuse anything but a confirmed run on main
env:
CONFIRM: ${{ inputs.confirm }}
run: |
if [ "$GITHUB_REF" != refs/heads/main ]; then
echo "::error::Run this workflow only from main."
exit 1
fi
if [ "$CONFIRM" != set-up-ses-account ]; then
echo "::error::The confirmation text does not match."
exit 1
fi

- name: 🔐 Assume the SES account set-up role
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: ${{ env.ROLE_ARN }}
role-session-name: ses-account-setup-${{ github.run_id }}
aws-region: ${{ env.AWS_REGION }}
role-duration-seconds: 900

- name: 💶 Use the pay-per-use pricing plan
# NONE is SES's pay-per-use (a-la-carte) plan. Set it before production
# access is requested: the plan cannot change while a review is open, so
# a rerun during a pending review writes nothing.
run: |
account="$(aws sesv2 get-account --output json)"
current="$(jq -r '.PricingAttributes.CurrentPlan // "UNKNOWN"' <<<"$account")"
next="$(jq -r '.PricingAttributes.NextPlan // "UNKNOWN"' <<<"$account")"
review="$(jq -r '.Details.ReviewDetails.Status // "NONE"' <<<"$account")"
if [ "$current" = NONE ] || [ "$next" = NONE ]; then
echo "The pay-per-use plan is already active or scheduled."
elif [ "$review" = PENDING ]; then
echo "::error::A production access review is pending, so the plan cannot change now."
exit 1
else
aws sesv2 put-account-pricing-attributes --plan NONE
echo "Pay-per-use plan set."
fi

- name: 📨 Request production access
env:
USE_CASE: >-
Devantler Tech is a one-person software consultancy. We send
low-volume mail from our own domain only: the owner's ordinary
business correspondence with clients and suppliers, and
notifications from our own website, such as account invitations
and password resets. We send no marketing or bulk mail and use no
purchased lists. We expect fewer than 1,000 messages a month. Every
recipient is a client, supplier or someone who contacted us. Bounce
and complaint notifications are forwarded to the sending mailbox,
and the owner handles them.
run: |
account="$(aws sesv2 get-account --output json)"
enabled="$(jq -r '.ProductionAccessEnabled // false' <<<"$account")"
review="$(jq -r '.Details.ReviewDetails.Status // "NONE"' <<<"$account")"
if [ "$enabled" = true ]; then
echo "Production access is already granted."
elif [ "$review" = PENDING ]; then
echo "A production access review is already pending."
else
aws sesv2 put-account-details \
--production-access-enabled \
--mail-type TRANSACTIONAL \
--website-url https://devantler.tech \
--contact-language EN \
--use-case-description "$USE_CASE"
echo "Production access requested."
fi

- name: 🔎 Read the account back
run: |
aws sesv2 get-account --output json | jq '{
productionAccessEnabled: (.ProductionAccessEnabled // false),
sendingEnabled: (.SendingEnabled // false),
enforcementStatus: (.EnforcementStatus // "UNKNOWN"),
reviewStatus: (.Details.ReviewDetails.Status // "NONE"),
currentPlan: (.PricingAttributes.CurrentPlan // "UNKNOWN"),
nextPlan: (.PricingAttributes.NextPlan // "NONE_SCHEDULED")
}'
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ It mirrors the `devantler-tech/.github` repo's `github-config` tenant pattern.
active and which of them this tenant may write. The EKS CI `Role` and its permissions
boundary stay platform-owned on purpose, because the cap on what that identity may create
lives inside the `Role`.
- **SES account settings** (pricing plan, production access) have no Crossplane resource.
The main-only `Set Up SES Account` workflow sets them through the platform-owned
`ses-account-setup` OIDC role, then reads the account back.
- **Adding a new resource kind takes two PRs, platform first:** the platform activates the
kind and grants this tenant permission to manage it; only after that merges does the
manifest land here. A manifest for a kind the tenant may not write passes this
Expand Down
Loading