I had heard about Terraform as a good solution to infrastructure as code approach. I have been using idempotent powershell scripts as a way to achieve that objective which is imperative (procedural) rather than declarative (as Terraform is). And that too, once the infrastructure (virtual machunes) were already provisioned. However, as I moved further and further into infrastructure as code process, I started realizing that there should be an efficient way of also provisioning the underlying infrastructure (virtual machines in this case). This repository is to capture my learning using terraform. My objective is to be able to run a few use cases, e.g. how to provision a VM in Azure and AWS and also be able to remote (for windows OS) into it. As I learn more I will add more use cases to this repository.
To begin with, most of my hands on learnings are going to be following tutorials/getting started docs available at:
Get Started - Azure
Get Started - AWS
Installation is available as part of getting stated documentations at https://www.terraform.io/
-start with terraform init
in the folder where the .tf file exists
-followed by terraform plan -out ${PlanFileName}.tfplan
-next terraform apply ${PlanFileName}.tfplan
-and lastly, once the resource is provisioned and verified, the command to destroy is terraform destroy
-in-order to not be prompted for each terraform apply
and terraform destroy
command, add --auto-approve
at the end. But do not use this the first time to provision an instance, since that might result in incorrect provisioning and without the review, it might take longer to identify and correct the error.
-when creating a new repository for terraform please be careful what kind of files are being commited (we do not want sensetive files like state and tfvars to be commited at all). Use .gitignore effectively in this case.