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 →
- 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" }
}
}
- Require tags (
owner,expiry) using tag policies or an SCP condition onaws:RequestTag. - Detect: AWS Budgets per account and Cost Anomaly Detection alerts to Slack.
- Clean up: a nightly job that stops instances past their
expirytag, 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.
More on Cost
The AWS bill jumped 40% this month and finance wants an explanation by tomorrow. How do you find out why?BeginnerThe "NAT Gateway – data processed" line is $9,000 a month. How do you bring it down?IntermediateCut EKS compute cost by 40% without hurting reliability. What's your plan?AdvancedDev and test environments run 24/7 but are used only during office hours. How do you cut that cost?BeginnerCloudWatch Logs costs more than the EC2 fleet. What do you do?IntermediateFinance asks you to buy commitments. Savings Plans or Reserved Instances, and how much?Intermediate