Infrastructure as code ( IaC )
source:terraform.io

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.

No alt text provided for this image

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

  1. Write - Author infrastructure as code
  2. Plan?- Preview changes before applying
  3. Apply?- Provision reproducible infrastructure

Sample terraform snippet

On the below snippet tells terraform that,

  • The service provider will be Google and the region would be "us-central1"
  • A compute instance to be created with a name "tf-instance-1"
  • The machine type should be "n1-standard-1"
  • Boot disk image will be "debian-cloud/debian-9"
  • And finally this compute instance will be provisioned under default network.

// 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

  1. terraform init - Pulls the provider resources so the above code can provision new compute instance
  2. terraform plan - Shows you a Preview of changes
  3. terraform apply - Provision infrastructure as mentioned in the file.
  4. terraform destroy will remove the infrastructure.

Next Step ?

Get started with Terraform here

要查看或添加评论,请登录

Rajesh Muthusamy的更多文章

  • Terraform in 6 Weeks - Week 2: Build a Scalable Static Website

    Terraform in 6 Weeks - Week 2: Build a Scalable Static Website

    Dear friend, The week 2 objective is to create a scalable and highly available static website hosted on S3, served…

    2 条评论
  • Terraform in 6 Weeks - Week 1: Architectural view

    Terraform in 6 Weeks - Week 1: Architectural view

    Dear Friend, In Week 0, we covered the basics of Terraform to get you started. Now, let’s dive deeper into Terraform’s…

    2 条评论
  • Terraform in 6 Weeks - Week 0: Laying the Foundation

    Terraform in 6 Weeks - Week 0: Laying the Foundation

    Dear Friend, Terraform is the gold standard in Infrastructure as Code (IaC), and mastering it is a skill that will stay…

    8 条评论
  • Understanding the OSI Model

    Understanding the OSI Model

    Dear Friend, The Open Systems Interconnection (OSI) model is a fundamental conceptual framework that illustrates how…

    2 条评论
  • Understanding Linux File Permissions

    Understanding Linux File Permissions

    Dear Friend, Linux file permissions are a fundamental aspect of the operating system's security model, determining who…

  • Kubernetes Networking

    Kubernetes Networking

    Dear Friend, In the world of kubernetes, we have different levels of networking requirements. Container-to-container…

    1 条评论
  • How To Design A Container-Based Application?

    How To Design A Container-Based Application?

    Dear Friend, Container is an important moving part of microservices architecture. You will need to place your…

  • The Journey Of A Code To Pod

    The Journey Of A Code To Pod

    Dear Friend, The journey of code towards Pod has multiple stages, and would feel overwhelming to dig the path. But…

    2 条评论
  • How Pods Connect Over Network?

    How Pods Connect Over Network?

    Dear Friend, Kubernetes allows unrestricted communication between pods by default. All pods can communicate with each…

    5 条评论
  • What The Helm?

    What The Helm?

    Dear Friend, In the Kubernetes world, there's no shortage of buzzwords. One among them is Helm.

    1 条评论

社区洞察

其他会员也浏览了