google-site-verification=EmVnnySXehAfTr_j8ZJN48hwvxJtfNf80pkPX1ObQlA Fast Track News: March || Level 2 || Lab 8 Infrastructure as Code with Terraform

March || Level 2 || Lab 8 Infrastructure as Code with Terraform

 export PROJECT_ID=$(gcloud config get-value project)

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}' > main.tf

terraform init

terraform apply -auto-approve

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}

resource "google_compute_instance" "vm_instance" {

  name         = "terraform-instance"

  machine_type = "e2-micro"

  boot_disk {

    initialize_params {

      image = "debian-cloud/debian-11"

    }

  }

  network_interface {

    network = google_compute_network.vpc_network.name

    access_config {

    }

  }

}' > main.tf

terraform apply -auto-approve

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}

resource "google_compute_instance" "vm_instance" {

  name         = "terraform-instance"

  machine_type = "e2-micro"

  tags        = ["web", "dev"]

  boot_disk {

    initialize_params {

      image = "debian-cloud/debian-11"

    }

  }

  network_interface {

    network = google_compute_network.vpc_network.name

    access_config {

    }

  }

}' > main.tf

terraform apply -auto-approve

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}

resource "google_compute_instance" "vm_instance" {

  name         = "terraform-instance"

  machine_type = "e2-micro"

  tags        = ["web", "dev"]

      boot_disk {

    initialize_params {

      image = "cos-cloud/cos-stable"

    }

  }

  network_interface {

    network = google_compute_network.vpc_network.name

    access_config {

    }

  }

}' > main.tf

terraform apply -auto-approve

terraform destroy -auto-approve

terraform apply -auto-approve

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}

resource "google_compute_instance" "vm_instance" {

  name         = "terraform-instance"

  machine_type = "e2-micro"

  tags        = ["web", "dev"]

      boot_disk {

    initialize_params {

      image = "cos-cloud/cos-stable"

    }

  }

  network_interface {

    network = google_compute_network.vpc_network.name

    access_config {

    }

  }

}

resource "google_compute_address" "vm_static_ip" {

  name = "terraform-static-ip"

}' > main.tf

terraform plan

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}

resource "google_compute_instance" "vm_instance" {

  name         = "terraform-instance"

  machine_type = "e2-micro"

  tags        = ["web", "dev"]

      boot_disk {

    initialize_params {

      image = "cos-cloud/cos-stable"

    }

  }

    network_interface {

    network = google_compute_network.vpc_network.self_link

    access_config {

      nat_ip = google_compute_address.vm_static_ip.address

    }

  }

}

resource "google_compute_address" "vm_static_ip" {

  name = "terraform-static-ip"

}' > main.tf

terraform plan -out static_ip

terraform apply "static_ip"

echo 'terraform {

  required_providers {

    google = {

      source = "hashicorp/google"

    }

  }

}

provider "google" {

  version = "3.5.0"

  project = "'"$PROJECT_ID"'"

  region  = "us-central1"

  zone    = "us-central1-c"

}

resource "google_compute_network" "vpc_network" {

  name = "terraform-network"

}

resource "google_compute_instance" "vm_instance" {

  name         = "terraform-instance"

  machine_type = "e2-micro"

  tags        = ["web", "dev"]

      boot_disk {

    initialize_params {

      image = "cos-cloud/cos-stable"

    }

  }

    network_interface {

    network = google_compute_network.vpc_network.self_link

    access_config {

      nat_ip = google_compute_address.vm_static_ip.address

    }

  }

}

resource "google_compute_address" "vm_static_ip" {

  name = "terraform-static-ip"

}

# New resource for the storage bucket our application will use.

resource "google_storage_bucket" "example_bucket" {

  name     = "'"$PROJECT_ID"'"

  location = "US"

  website {

    main_page_suffix = "index.html"

    not_found_page   = "404.html"

  }

}

# Create a new instance that uses the bucket

resource "google_compute_instance" "another_instance" {

  depends_on = [google_storage_bucket.example_bucket]

  name         = "terraform-instance-2"

  machine_type = "e2-micro"

  boot_disk {

    initialize_params {

      image = "cos-cloud/cos-stable"

    }

  }

  network_interface {

    network = google_compute_network.vpc_network.self_link

    access_config {

    }

  }

}' > main.tf

terraform plan

terraform apply -auto-approve

No comments:

Post a Comment

April Week 2 || Lab 2 || Troubleshooting Data Models in Looker

  CREATE NEW FILE NAME: user_order_lifetime view: user_order_lifetime { derived_table: { sql: SELECT order_items.user_id as us...