An application needs a secret at boot. A teammate puts it in `user_data`. Why is that wrong, and what's the alternative?
IntermediateScenarioSecrets Provisioners and Policy as Code
Answer
Situation read → User data is readable from the instance metadata and visible in console and state.
What I'd do →
- Remove the secret from user data.
- Give the instance an IAM role.
- Have the app or boot script fetch it from Secrets Manager or SSM Parameter Store at runtime.
- Enforce IMDSv2 with
metadata_options { http_tokens = "required" }.
Why → Secrets stay out of code, state and metadata, and access is auditable and revocable.
Interview tip → Mention rotation: runtime fetch makes it painless.
More on Secrets Provisioners and Policy as Code
A developer hardcodes a DB password in `terraform.tfvars` and commits it. What do you do right now, and what's the long-term fix?BeginnerHow do you avoid Terraform persisting a secret in state when creating a secret in AWS Secrets Manager?AdvancedSomeone wants a `remote-exec` provisioner to configure servers after creation. What's your advice?BeginnerYou must run a one-off command after a resource is created, such as registering with an external system.IntermediateHow do you generate and manage the master password for a new RDS instance?IntermediateCompare Sentinel, OPA/Conftest and Checkov for policy as code.Intermediate