What I thought I had
One monthly cost budget in each of four AWS accounts, created by my
infrastructure tool. Each budget is sized at last month's spend times
1.3 and carries three notifications, at 80, 100 and 120 percent of the
limit, each with one email subscriber. The tool logged
created budget, alerts to email for every account and
exited zero. The list command agreed: four budgets, all under
limit, all green. I wrote it down as done.
Nothing was wrong with the budgets. The part that was wrong does not appear on the budgets page at all.
Where the email actually goes
AWS Budgets no longer mails an email subscriber directly. It hands the
address to AWS User Notifications, a separate service with its own
console and its own API. When a budget is created with an email
subscriber, two calls appear in CloudTrail under the identity that
created the budget: CreateEmailContact and
SendActivationCode. The first makes an email contact in
that account. The second sends the recipient a message with a
"Verify email" link.
Until that link is clicked, the contact has status:
inactive, and an inactive contact receives nothing. Not a
bounce, not a warning, nothing. Two more rules make it worse. The
link expires in twelve hours. And it only works while the recipient
is signed in to the specific account that owns the contact. Click it
while signed in to a different account and it fails without a
useful message.
Four accounts meant four verification emails, each from a service I had not asked for, each looking like the kind of mail you leave for later. By the time I understood what they were, all four links had expired. The budgets stayed green the whole time.
How to check
In the console. Open AWS User Notifications, not
Budgets, and look at the email contacts. Each one shows an address
and a status. Anything other than active is a contact
that will never deliver a budget alert.
From the command line. The API is
notificationscontacts. Contacts are a global resource
served from one region, us-east-1 in the standard
partition, so the region flag matters even though the budget itself
is not regional.
aws notificationscontacts list-email-contacts --region us-east-1
The response lists each contact with an arn, a
name, an address and a
status. There are two statuses that matter:
active: the recipient clicked the link while signed in to this account. Alerts will deliver.inactive: the link was never clicked, or it expired, or it was clicked under the wrong account. Alerts will not deliver.
To send a fresh link, pass the contact's ARN:
aws notificationscontacts send-activation-code --region us-east-1 --arn CONTACT_ARN
Then sign in to the account that owns the contact, open the new
email, and click Verify within twelve hours. Repeat per account. The
list command shows active as soon as the click lands.
What I changed in the tool
The budget command had reported success the moment
CreateBudget returned, which is the exact point where
the silence begins. Two changes.
A warning after every create. Once the budget exists, the tool lists the account's email contacts and looks for the subscriber address. If that contact is anything but active, it logs a warning that says the alerts will not be delivered, what to click, and that the link is good for twelve hours. Trimmed to the part that matters:
def warn_unverified_contact(session, email):
nc = session.client("notificationscontacts", region_name="us-east-1")
for c in nc.list_email_contacts().get("emailContacts", []):
if c.get("address") == email and c.get("status") != "active":
logger.warning(
"%s is UNVERIFIED in AWS User Notifications; budget alerts "
"will NOT be delivered until Verify email is clicked while "
"signed in to this account (12 h link)", email)
Two commands of their own. A list command that
prints every contact with its status and flags the inactive ones
with "receives nothing", and a resend command that calls
SendActivationCode for every inactive contact, or for
one address when named. Both follow the pagination token, both have
a dry run, and the resend prints the same reminder about being
signed in. Eight unit tests cover the region choice, pagination,
the active check, and that resend never touches an active contact.
One trade-off I made on purpose. The warning after create is advisory. If the contacts API call fails, for a missing permission say, the tool logs that at debug level and moves on, because a budget that exists is still better than a budget that was rolled back over a warning. The cost of that choice is that a permission gap can hide the warning. The list command is the backstop, and it does not swallow errors.
Resending four links
With the resend command the recovery was short: resend, sign in to that account through the identity
portal, open the email, click Verify, run the list command, read
active. All four contacts went active the same
session. My honest mistake was earlier than any of that: I trusted
a log line that described an API call succeeding, and read it as an
email arriving. Those are different events, and the gap between
them was four expired links.
The only proof that counts
A contact reading active proves the delivery path is
open. It does not prove an alert fires. For that, set one budget
deliberately below the month's current spend and wait for the email.
Budgets do not evaluate instantly, so give it a day before concluding
anything. If no mail comes, check the contact state first, before
touching the budget, because the budget was never the problem.
If you created budgets with email subscribers recently
- Run
list-email-contactsin every account that has a budget. Anyinactivecontact is a silent budget. - Resend the activation code. Sign in to that account before you click. Click within twelve hours.
- Re-run the list and read
activebefore you call it done. - Set one budget under current spend and wait for the real email.
- If a tool creates your budgets, make it check the contact after every create. A green budget with an inactive contact is the default outcome, not the exception.