Login

Log in with one your accounts

Contribution

We are happy you want to contribute to DXKB. Please choose your preferred way

All Articles
Dec 18, 20204 min read

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.

Infrastructure as codeSource: 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.

Old Approach

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.

Ready to put this knowledge into action?

Visit our website and learn how DX Heroes can help your business succeed.

Why You Might Want Infrastructure As Code

The main measurable advantages of IaC are:

Cost

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.

Speed

Together with Continous Delivery/Deployment, you are delivering the final product faster. That is because you are cutting on the manual steps.

Risk

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:

  1. Collaboration Devs, Ops, or DevOps teams should collaborate on configuration and provisioning.
  2. Write Tests One of the most notable values of IaC. Start with Unit testing,Performance testing or Integration testing.
  3. Source control your configuration files. Use practices like Semantic versioning or commit name rules.
  4. Minimal documentation since your code should be self-explaining. However, on larger project, you can use updated documentation.

IaC Tools to consider:

AWS CloudFormation

Declarative, Provisioning, drag-n-drop UI, highly reliable, available, and scalable AWS infrastructure.

Azure Resource Manager

Declarative, Group deployments, group pricing options, JSON templates (instead of YAML).

Google Cloud Deployment Manager

Declarative, integration with other Google Cloud Services, console UI, supports both Python and JINJA,

Puppet

Declarative, own language for iac, needs master server.

Chef

Imperative (Procedural), needs master server, open source.

Terraform

Declarative, provisioning, masterless, open source.

Vagrant

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

Was the article helpful?

Want to write for DXKB?

Feel free to contribute. People from DXKB community will be more than happy.

Contribution

We are happy you want to contribute to DXKB. Please choose your preferred way