github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/terraform-gcp-example/main.tf (about)

     1  # ---------------------------------------------------------------------------------------------------------------------
     2  # PIN TERRAFORM VERSION TO >= 0.12
     3  # The examples have been upgraded to 0.12 syntax
     4  # ---------------------------------------------------------------------------------------------------------------------
     5  
     6  terraform {
     7    # This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
     8    # 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
     9    # forwards compatible with 0.13.x code.
    10    required_version = ">= 0.12.26"
    11  }
    12  
    13  # ---------------------------------------------------------------------------------------------------------------------
    14  # DEPLOY A CLOUD INSTANCE RUNNING UBUNTU
    15  # See test/terraform_gcp_example_test.go for how to write automated tests for this code.
    16  # ---------------------------------------------------------------------------------------------------------------------
    17  
    18  resource "google_compute_instance" "example" {
    19    project      = var.gcp_project_id
    20    name         = var.instance_name
    21    machine_type = var.machine_type
    22    zone         = var.zone
    23  
    24    boot_disk {
    25      initialize_params {
    26        image = "ubuntu-os-cloud/ubuntu-1604-lts"
    27      }
    28    }
    29  
    30    network_interface {
    31      network = "default"
    32      access_config {
    33      }
    34    }
    35  }
    36  
    37  # ---------------------------------------------------------------------------------------------------------------------
    38  # CREATE A GOOGLE STORAGE BUCKET
    39  # ---------------------------------------------------------------------------------------------------------------------
    40  
    41  resource "google_storage_bucket" "example_bucket" {
    42    project  = var.gcp_project_id
    43    name     = var.bucket_name
    44    location = var.bucket_location
    45  }
    46