Engineers launched a few p4d GPU instances "for testing" and forgot them for a month. How do you stop this happening again?

IntermediateScenarioCost
Answer

Situation read → You need guardrails that prevent it, and alerts that catch it fast when prevention fails.

What I'd do →

  1. Prevent: an SCP that denies expensive instance types in non-prod accounts unless the request comes through an approved role.
{
  "Effect": "Deny",
  "Action": "ec2:RunInstances",
  "Resource": "arn:aws:ec2:*:*:instance/*",
  "Condition": {
    "StringLike": { "ec2:InstanceType": ["p4*", "p5*", "x2*", "u-*"] },
    "ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/gpu-approved" }
  }
}
  1. Require tags (owner, expiry) using tag policies or an SCP condition on aws:RequestTag.
  2. Detect: AWS Budgets per account and Cost Anomaly Detection alerts to Slack.
  3. Clean up: a nightly job that stops instances past their expiry tag, after warning the owner.

Why → Prevention handles most cases; anomaly alerts limit the damage to a day instead of a month.

Interview tip → Combine an SCP (preventive) with budgets and anomaly detection (detective); naming both layers is the strong answer.

All Real-World Interview questions Roadmap: Interview readiness

More on Cost