Configuration as Code: Treat Your Settings Like Source Code

Configuration as Code (CasC) treats your settings like source code, storing them in version control. This ensures every environment is identical, with changes automatically tested and deployed via CI/CD.
Why it exists
Manually managing configuration files across different environments like development, staging, and production is notoriously error-prone. This leads to "environment drift," where subtle differences cause bugs that only appear in production. CasC was created to solve this by making configuration changes safe, repeatable, and auditable.
The mental model
Configuration as Code (CasC) is about treating configuration files—for your application, your infrastructure, and your CI/CD pipeline—as first-class citizens, just like your source code. You check them into Git, review changes in pull requests, and have a full history of who changed what, when, and why. It shifts configuration from a manual, operational task to a systematic, automated development practice.
How it works
With CasC, you define all settings in files (often YAML) within your source repository. Instead of SSHing into a server to edit a file, you make a change in your code editor, commit it, and push it. This push triggers your CI/CD pipeline, which automatically applies the new configuration to the relevant environments. The pipeline can also run tests to validate that the change didn't break anything, making the entire process traceable and easily revertible.
When to use it
CasC is essential for modern CI/CD. Use it to manage three main areas. First, application configuration, to centralize settings for distributed services and ensure consistency. Second, infrastructure configuration, to define the state of your servers, containers, or cloud resources after they've been provisioned. Third, pipeline configuration, where the CI/CD pipeline itself is defined in a version-controlled file like a Jenkinsfile or .circleci/config.yml.
When not to use it
Do not use CasC to store sensitive secrets like API keys, passwords, or certificates directly in your code repository, even if it's private. These should be managed by a dedicated secrets management tool (like HashiCorp Vault or AWS Secrets Manager) and injected into the environment at runtime. Your configuration file should reference the secret, but not contain its actual value.
One canonical example
A CI/CD pipeline configuration file, such as .circleci/config.yml, is a perfect example. This YAML file lives in your Git repository and defines the entire build, test, and deploy process. When a developer changes this file to add a new testing step, that change is reviewed in a pull request and, once merged, automatically applies to all future pipeline runs, ensuring the process is versioned and consistent for the whole team.
Interview question
Which scenario is NOT an appropriate application of Configuration as Code (CasC) principles?
- a.Storing sensitive API keys and database credentials directly in your code repository.Correct
- b.Centralizing environment-specific settings for multiple application services.
- c.Defining the build and deployment steps for a CI/CD pipeline in a version-controlled file.
- d.Describing the desired state of infrastructure components like servers and containers.
Why? this is the answer
CasC explicitly advises against storing sensitive secrets like API keys or passwords directly in a code repository, even if private, recommending dedicated secrets management tools instead. The other options are all core use cases for CasC, covering pipeline, application, and infrastructure configuration.
Just read this? Test yourself on what you have been reading.
Read the original → circleci.com
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on devops — each one lists the topics its interview covers.
See open roles