Infrastructure as code ( IaC )
Dear Friend,
Six months ago, I asked a DevOps lead what's the challenge he face at his team.
He said, the team is good in creating the infra with cloud console. Yet, when it comes to automate them using IaC like terraform they needs his time.
Creating infra through console for the first time is way faster than writing IaC code.
But, the infra is creation isn't one time and it's ever growing, repeating need.
Frequent need to repeat an activity or change in a system makes manual work, a difficult task.
Why Terraform ?
Terraform have provisions to connect three major cloud providers and beyond.
So you are not required to connect the cloud providers API's to automate the system.
Specify your desired state, then terraform will do the rest.
领英推荐
Terraform workflow
Sample terraform snippet
On the below snippet tells terraform that,
// Tells terraform that we would like to use google provider
provider "google" {
project = "my-project"
region = "us-central1"
}
// The below code would create a compute instance
resource "google_compute_instance" "tf-instance-1" {
project = 12345677
name = "tf-instance-1"
machine_type = "n1-standard-1"
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
network_interface {
network = "default"
access_config {
// Ephemeral IP
}
}
}
Now, a cloud compute instance can be provisioned with below commands
Next Step ?
Get started with Terraform here