Scenario: Create a virtual Machine / EC2 instance
-
Details:
- Size:
- CPU: 1 vcpu
- RAM: 1 GB
- Operating System: Redhat Linux
- Disk: 10 GB
- Size:
-
Options:
- Manual
- Command Line
- Templated
Infrastructure as Code (IaC)
- Infrastructure required for the application is expressed in a templated format with variables which can be passed dynamically
- IaC tries to maintain desired state expressed by user
Terraform
- Terraform is an on open source Infra Provisioining tool to create, manage and update infrastructure in various providers such as
- AWS
- Azure
- GCP
- AliCloud
- Openstack
- VM ware
- As part of CI/CD Pipeline we need to manage multipel environments for an application
- Dev
- QA
- Staging
- Terraform can use the some template across various environments

- Terraform also allows parallel executions by multiple users across organizations.
- Alternatives to Terraform
- ARM Templates, Azure Bicep
- Can be used in Azure Only
- AWS Cloud formation:
- Can be used with AWS Only
- Pulumi: As of now terraform is much popular than this.
- ARM Templates, Azure Bicep
Scenarios with Terraform in CI/CD
- If we categorize the infra managed by terraform we have 3 broader categories
- Virtual Machines
- Cloud Platforms
- Kubernetes
Steps to Learn Terraform
- The template in terraform is expressed in Hashicorp Configuration Lanaguage (HCL).
-
Terms:
- Provider: Where we want to create resources.
- resource: The individual infra element to be created
- module: reusable template.
-
WOW (Ways of Working)
- Figure out manual steps
- identify what can change and parametrize
- Now each step try to use HCL
