Skip to content

Terraform - infrastructure as code

Source: Terraform explained in 15 mins | Terraform Tutorial for Beginners - YouTube

See Infrastructure as Code with Terraform - DevOps Bootcamp - Infrastructure as Code with Terraform

Provision infrastructure, platforms, and services.

Use Case, you want:

  1. Provisioning infrastructure - To use AWS to build 3 containers and deploy your apps, services, private network space, EC2 server instances, install Docker and tools
  2. Deploy applications

Terraform is used for infrastructure provisioning such as creating infrastructure, user permissions, create servers, install services.

Continuing with the use case, you created the infrastructure, now you want:

  • Add more servers
  • Increase security
  • Reconfigure infrastructure

Terraform can automate continuous changes. Such as promote infrastructure changes in DEV to PROD and/or create same infrastructure in PROD.

Terraform and Ansible Differences and When to Use Them

Section titled “Terraform and Ansible Differences and When to Use Them”

They appear to do the same thing?

AnsibleTerraform
Infrastructure as CodeSame
Mainly Configuration toolMainly Infrastructure Provisioning tool
Configure existing infrastructure
Install/update softwareCan deploy apps
MatureNewer
Advanced in orchestration
  • Ansible is better for configuring existing infrastructure
  • Terraform is better for infrastructure

Both tools should be used together for their strengths.

  • Terraform uses Declarative language - you define the end state
  • Imperative approach defines exact steps to get to end state