Infrastructure as Code
What is Infrastructure As Code
IaC is a principle (or process) of provisioning and managing your infrastructure through machine-readable definitions instead of using physical hardware configuration. To put it in better terms, instead of manually setting everything by yourself, you create a configuration file. Some people call IaC golden rule for DevOps.
Source: Infrastructure as code
With IaC, you can spin your resources to match your needs (utility computing). New peak of visitors? You just adjust your infrastructure to the new load.
Before IaC, Ops and Devs had a hard time managing your resources. You were always setting up your servers, configuring networks, creating routing tables, or installing software — all that on your hardware. If you had more visitors, it could take weeks to adjust for this load. Not only that, but any update takes a lot of time (updating databases, checking dependencies, and much more) and resources.
That is why IaC is gaining popularity as it is a modern response to the old situation.
Approaches of IaC - Declarative (functional)
Focuses on What. What is the desired end look? With this approach, you declare the end state, and the system makes it happen
Approaches of IaC - Imperative (procedural)
Focuses on How. How should my existing infrastructure change? With this approach, you define the steps the system takes to arrive at the desired end state.
Why You Might Want Infrastructure As Code
The main measurable advantages of IaC are:
IaC practices and tools can reduce the cost of the service (save you money). Through automatization, you are lowering the manual labor that allows Ops/Dev Ops team to focus on something else. Moreover, through spinning, you are using your resources optimally.
Together with Continous Delivery/Deployment, you are delivering the final product faster. That is because you are cutting on the manual steps.
With automation, you are lowering the risk of human error, and with configuration files instead of manual labor, you are increasing reliability (the system will always behave the same way). Using source control, you can audit changes. DevOps or Ops teams are able to write tests for your IaC.
Problems Infrastructure As Code Helps to Solve
How to Implement Infrastructure As Code
Before exploring possible tools, there are general rules to follow for maximal effect:
- Collaboration Devs, Ops, or DevOps teams should collaborate on configuration and provisioning.
- Write Tests One of the most notable values of IaC. Start with Unit testing,Performance testing or Integration testing.
- Source control your configuration files. Use practices like Semantic versioning or commit name rules.
- Minimal documentation since your code should be self-explaining. However, on larger project, you can use updated documentation.
IaC Tools to consider:
Declarative, Provisioning, drag-n-drop UI, highly reliable, available, and scalable AWS infrastructure.
Declarative, Group deployments, group pricing options, JSON templates (instead of YAML).
Declarative, integration with other Google Cloud Services, console UI, supports both Python and JINJA,
Declarative, own language for iac, needs master server.
Imperative (Procedural), needs master server, open source.
Declarative, provisioning, masterless, open source.
Runs over AWS, Puppet, Chef and others, a way to virtualize machines.
If you don't have a dev-ops team or your team is on junior level, consider asking experts. We have good experience with LUKAPO
Common Pitfalls of Infrastructure As Code
- The management can be against moving towards IaC since they don’t see the results immediately
- IaC opens code-like issues such as the question of code maintenance, working with someone’s code, or just question of collaboration
- For some tools, there is a general lack of code samples
- The integration with CI/CD pipeline can be tricky
- Devs can have problems learning with IaC tools
Resources for Documentation Testing
- Infrastructure as Code by Kief Morris: Chapter 1
- Infrastructure as Code by Kief Morris: blog
- Infrastructure as code
- Implementing infrastructure as code
- What Is Infrastructure as Code? How It Works, Best Practices, Tutorials
- Kief Morris
- Implementing Infrastructure as Code
- Infrastructure as code: The engine at the heart of DevOps
- Chef Tutorial – Transform Infrastructure Into Code
- Top 12 Infrastructure as Code (Iac) Tools
Want to write for DXKB?
Feel free to contribute. People from DXKB community will be more than happy.
Practicing Continuous Delivery means that you adopt practices to be ready to release product changes any time you want. Your product is always ready to deploy to production.Read more
Apache Kafka is used as a high-available messaging queue. It receives messages from other services in the environment and provides it to the others.Read more
DevOps is a set of practices that brings development and operations teams together. The collaboration helps to release software much faster.Read more
Operations Logbook allows you to collect, store, and share data in real time and dig your historical data easily. Record every incident and every important event related to your project.Read more
Continuous Integration is a software development practice that makes developers integrate code changes into a shared repository routinely and frequently. Usually, each person integrates at least daily and that ensures them that their code changes do not break anything.Read more