Introduction to Terraform

Terraform allows us to describe our complete infrastructure in the form of code. Even if our servers come from different providers such as AWS or Azure, Terraform helps us build and manage these resources in parallel across providers. We can think of the Terraform as a connective tool and common language that we can utilize to manage our entire IT stack.

▪ An open-source infrastructure as code (IaC) tool by HashiCorp

▪ Let us automate and manage:

● our infrastructure

● our platform

● services that run on that platform

▪ By defining the resources in human-readable configuration files that you can:

● version

● reuse

● share

▪ Definition of configuration files is declarative!

Declarative = define WHAT end result or desired state you want

Imperative = define exact steps - HOW

Benefits of Infrastructure as Code

IaC solves many common problems with provisioning Infrastructure.

  • New environments or infrastructure can be provisioned easily from your IaC configuration code. Infrastructure deployments with IaC are repeatable.

  • Manually configured environments are difficult to scale. With environments provisioned using IaC, they can be deployed and scaled rapidly.

  • If you want to make changes to the existing infrastructure that has been deployed with IaC, this can be done in code, and the changes will be tracked.

  • When IaC is used with a declarative tool (it describes the state you want your environment to look like), you can detect and correct environment drift. If a part of the infrastructure is modified manually outside the code, it can be brought back in line with the desired state on the next run.

  • Changes can be applied multiple times without changing the result beyond the initial application. This is known as idempotence.

  • Avoid manual configuration of environments which can typically introduce mistakes due to human error. With IaC, these can be avoided.

  • IaC is a means to achieve consistency across environments and infrastructure. The code can be reused.

  • Infrastructure costs are lowered as the time to deploy and effort to manage, administer and maintain environments decrease.

  • IaC can be used in Continuous Integration / Continuous Deployment (or CI/CD) pipelines. The main benefit of doing this is to automate your Infrastructure deployments.

  • DevOps teams can test applications in production-like environments early in the development cycle.

  • With your Infrastructure configuration code held in your version control system alongside your application source code, commonly in the same repository. Now everything can be held together.

  • Productivity will increase due to a combination of all the benefits of using IaC.

  • As the code is held in your version control system, it gains all the benefits of the VCS. More on that in the next section.

Difference of Ansible and Terraform

Infrastructure Provisioning

Last updated