Cloud & Infravendor:awsEmail OTPUnwrapped Magic LinkCarrier SMS DIDCloud KMS TOTP
Automate AWS MFA TOTP & Email Verification in Playwright & Stagehand
Automate AWS Root/IAM Console MFA, Cloud KMS-protected virtual authenticator codes, Email OTPs, and SMS challenges for cloud ops and billing agents.
1. 60-Second Gmail & Outlook Auto-Forwarding Filter
Don't want to change your existing account email on AWS (Amazon Web Services)? Keep your corporate inbox on AWS (Amazon Web Services) and forward only verification emails to <identity-slug>@in.sentryrelay.com. Sentry Relay's Stage 2 unwrapper preserves the original AWS (Amazon Web Services) sender header automatically (full setup guide).
# Paste into Gmail -> Settings -> Filters -> Create a new filter ("Has the words")
from:(amazon.com OR amazonaws.com OR signin.aws) ("verification code" OR "one-time passcode" OR "security code" OR "AWS verification")
# Action: Forward it to -> <your-identity-slug>@in.sentryrelay.com2. Copy-Paste AWS (Amazon Web Services) 2FA Automation Snippets
Choose your browser automation stack below. All snippets resolve codes in <200ms with Upstash Redis 15-second lookback protection so arrived-before-wait race conditions never fail a run.
import { test, expect } from '@playwright/test';
import { SentryRelay } from '@sentryrelay/sdk';
const relay = new SentryRelay({ apiKey: process.env.SENTRY_RELAY_API_KEY! });
test('Sign into AWS Console with KMS TOTP and Email OTP', async ({ page }) => {
await page.goto('https://signin.aws.amazon.com/');
await page.fill('input#resolving_input', process.env.AWS_ROOT_EMAIL!);
await page.click('button#next_button');
await page.fill('input#password', process.env.AWS_ROOT_PASSWORD!);
await page.click('button#signin_button');
// Path A: AWS Virtual MFA (TOTP) with automatic <=4s rollover wait
const mfaInput = page.locator('input#mfaCode');
if (await mfaInput.isVisible({ timeout: 5000 }).catch(() => false)) {
const token = await relay.totp.get('aws-billing-bot', 'aws_root');
await mfaInput.fill(token.code);
await page.click('button[type="submit"]');
}
// Path B: Risk-based AWS Email Verification Code
const otpInput = page.locator('input[name="otpCode"]');
if (await otpInput.isVisible({ timeout: 4000 }).catch(() => false)) {
const auth = await relay.wait('aws-billing-bot', { sender: 'amazon', timeout: 30 });
await otpInput.fill(auth.event!.otpCode!);
await page.click('button[type="submit"]');
}
await expect(page).toHaveURL(/console\.aws\.amazon\.com/);
});3. AWS (Amazon Web Services) Production Gotchas
AWS TOTP Rejects Codes That Roll Over During Slow LLM Actions
When an LLM browser agent takes 3 seconds to click Submit, fetching a TOTP with 2 seconds remaining causes Invalid MFA errors. Sentry Relay automatically waits out the <=4s rollover to return a fresh 26–30s token.
AWS Root vs. IAM User Billing Portals
Finance and invoice-download bots often log into the AWS Billing console with root or finance-scoped credentials where AWS enforces extra email verification on unrecognized IPs.
Invoice & AWS Budgets Emails Stay Filtered Out
Because invoice emails contain numbers like `Invoice #123456`, Stage 4 explicitly disqualifies AWS Budgets and monthly bill emails so your agent never grabs an invoice ID as an OTP.