The idea behind infrastructure as code (IaC) is that you write and execute code to define, deploy, update, and destroy your infrastructure. This represents an important shift in mindset in which you treat all aspects of operations as software—even those aspects that represent hardware (e.g., setting up physical servers).

Bugs in the infrastructure code tend to be more severe, compared to a code for a typical application. Because of that more thought should be put into isolation, locking, state management.

Categories of IaC tools

Benefits

  • Self-service. The entire deployment process can be automated. Developers can make deployments whenever necessary.
  • Speed and safety. Automated deployments are faster than manual, and they are more consistent, repeatable, and not prone to manual error.
  • Documentation. IaC acts as documentation for your infrastructure.
  • Version control. IaC source files in the VCS can help with debugging, log the history of changes, and be used to revert back to a previous, known-good version of the infrastructure.
  • Validation. Code review, automated tests, static analysis tools can be used to validate new version of infrastructure.
  • Reuse. Parts of the infrastructure can be packaged into reusable modules.
  • Happiness. Deploying code and managing infrastructure manually is repetitive and tedious.

Tools comparison

TerraformChefPuppetAnsiblePulumiCloudFormationHeat
SourceOpenOpenOpenOpenOpenClosedOpen
CloudAllAllAllAllAllAWSAll
TypeProvisioningConfig mgmtConfig mgmtConfig mgmtProvisioningProvisioningProvisioning
InfraImmutableMutableMutableMutableImmutableImmutableImmutable
ParadigmDeclarativeProceduralDeclarativeProceduralDeclarativeDeclarativeDeclarative
LanguageDSLGPLDSLDSLGPLDSLDSL
MasterNoYesYesNoNoNoNo
AgentNoYesYesNoNoNoNo
Paid ServiceOptionalOptionalOptionalOptionalMust-haveN/AN/A
CommunityHugeLargeLargeHugeSmallSmallSmall
MaturityMediumHighHighMediumLowMediumLow