Lot of tools available if you search for infrastructure as code:
But Cloudformation and Terraform are provisioning tools. Here we will discuss about Terraform.
Terraform is the infrastructure as code offering from HashiCorp. It is a tool for
- building,
- changing,
- managing infrastructure
in a safe, repeatable way.
Infrastructure as Code
It is the process of managing infrastructure in a file(s) rather than manually configuring resources in a user interface. A resource in this instance is any piece of infrastructure in a given environment, such as a virtual machine, security group, network interface, etc.
Terraform
- Terraform allows operators to use HCL to author files containing definitions of their desired resources.
- Almost any provider (AWS, GCP, GitHub, Docker, etc)
Workflows
A simple workflow for deployment will follow closely to the steps below.
- Scope - Confirm what resources need to be created for a given project.
- Author - Create the configuration file in HCL based on the scoped parameters
- Initialize - Run
terraform init
in the project directory with the configuration files. This will download the correct provider plug-ins for the project. - Plan & Apply - Run
terraform plan
to verify creation process and thenterraform apply
to create real resources as well as state file that compares future changes in your configuration files to what actually exists in your deployment environment.
Advantages
- Platform Agnostic
- State Management
- Operator Confidence
Install Terraform
Follow Install terraform to install.