Interview Prep/DevSecOps/Cloud IAM and Compliance

How do you make sure EC2 instances and Lambdas reach S3 and DynamoDB without going over the internet?

BeginnerScenarioCloud IAM and Compliance
Answer

Situation read → Traffic to AWS APIs via NAT goes over public endpoints. VPC endpoints keep it on the AWS network and let you add policies.

What I'd do →

  1. Create gateway endpoints for S3 and DynamoDB (free) and interface endpoints for others (ECR, STS, Secrets Manager).
  2. Add endpoint policies limiting access to your own buckets.
  3. Use bucket policies with aws:SourceVpce to deny access not through the endpoint for sensitive buckets.
  4. Bonus: lower NAT gateway data costs.

Why → Private paths reduce exposure and enable data perimeter controls.

Interview tip → Mention "data perimeter" (aws:ResourceOrgID, aws:PrincipalOrgID) as the bigger pattern.

All DevSecOps questions Roadmap: Policy as code

More on Cloud IAM and Compliance