DevOps Engineer interview question · Most asked
How do you handle secrets in CI/CD pipelines securely?
Summary
Avoid long-lived credentials: use OIDC federation from the CI system to the cloud (GitHub Actions, GitLab and others can assume cloud roles with short-lived tokens), fetch application secrets at runtime from a secret manager rather than passing them through the pipeline, scope CI permissions per job and environment, and protect production credentials behind approvals and protected branches.
Longer Answer
Additional controls: mask secrets in logs (but do not rely on masking), never echo or write them to artifacts, restrict which branches and workflows can access production secrets, rotate any remaining static secrets automatically, scan repositories and history for leaked secrets (gitleaks, GitHub secret scanning), and audit secret access. Pull requests from forks must never get secrets.
Key Points
- OIDC to cloud; no long-lived keys.
- Runtime secrets from a secret manager.
- Scope per job/environment; approvals for prod.
- Scan for leaks; rotate; audit.
More most-asked DevOps Engineer questions
- A rollback after a release made the outage worse because the database had already been migrated. How do you design releases so rollbacks are always safe?
- Every deployment produces a burst of 502s. What do you check?
- What happens when you type a URL into a browser and press Enter?
- Design a CI/CD pipeline for a containerised microservice from commit to production.
- Pods keep restarting with OOMKilled under load. How do you investigate and fix it?
- What are DORA metrics, and how would you use them without gaming them?
- How do you handle database schema migrations in an automated deployment pipeline?
- Your CI pipeline takes 45 minutes. How would you speed it up?