Interview Prep/DevSecOps/Container and IaC Security

Someone opened a security group manually in the console, bypassing Terraform. How do you detect and prevent it?

IntermediateScenarioContainer and IaC Security
Answer

Situation read → Drift means your reviewed code is no longer the truth.

What I'd do →

  1. Detect: scheduled terraform plan -detailed-exitcode (exit 2 means changes) and AWS Config rules.
  2. Alert via CloudTrail and EventBridge on AuthorizeSecurityGroupIngress from non-pipeline principals.
  3. Remediate: re-apply Terraform, or auto-remediate with Config and SSM Automation.
  4. Prevent: remove write permissions from humans, use read-only console roles plus a break-glass role, add SCPs.

Why → If humans cannot change prod directly, drift becomes rare.

Interview tip → "Detect, remediate, then remove the permission that allowed it."

All DevSecOps questions Roadmap: Policy as code

More on Container and IaC Security