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.

Curated Stage 4 Extractor Profile (vendor:aws)

Extracts 6-digit AWS sign-in verification codes and `signin.aws.amazon.com` verification links while disqualifying AWS Budgets alerts, monthly bills, Invoice emails, and Amazon retail order confirmations.

Matched Sender Domains
amazon.comamazonaws.comaws.amazon.comsignin.aws
Login URL example: https://signin.aws.amazon.com/
Filtered Non-Auth Noise
  • AWS Budgets threshold notifications
  • Monthly AWS billing & Invoice # alerts
  • Amazon retail shipment & order # emails

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.com

2. 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

Frequently Asked Questions

How are AWS TOTP seeds stored in Sentry Relay?
TOTP seeds are envelope-encrypted via Google Cloud KMS (AES-256-GCM bound to workspaceId:identityId:secretId AAD). Raw Base32 seeds are never returned via API or exposed to LLMs.
What happens if AWS sends an email OTP before Playwright reaches the wait step?
Sentry Relay maintains a 15-second Upstash Redis timeline lookback window by default, so emails arriving before relay.wait() connects are still matched atomically.
Can we connect our existing finance@company.com AWS email without changing AWS settings?
Yes. Configure a 60-second Gmail or Microsoft 365 forwarding filter to route AWS verification emails to your Identity and Sentry Relay unwraps the original sender automatically.
Provision an Isolated Identity for AWS (Amazon Web Services)

Start free in 3 minutes with @in.sentryrelay.com email + Simulated SMS, or attach a dedicated US carrier Telnyx SMS DID starting on Builder ($29/mo) and Growth/Pro ($79/mo).