github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/terraform-gcp-ig-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 # --------------------------------------------------------------------------------------------------------------------- 15 # DEPLOY A REGIONAL MANAGED INSTANCE GROUP 16 # See test/terraform_gcp_ig_example_test.go for how to write automated tests for this code. 17 # --------------------------------------------------------------------------------------------------------------------- 18 19 # Create a Regional Managed Instance Group 20 resource "google_compute_region_instance_group_manager" "example" { 21 project = var.gcp_project_id 22 region = var.gcp_region 23 24 name = "${var.cluster_name}-ig" 25 base_instance_name = var.cluster_name 26 version { 27 name = "terratest" 28 instance_template = google_compute_instance_template.example.self_link 29 } 30 31 target_size = var.cluster_size 32 } 33 34 # Create the Instance Template that will be used to populate the Managed Instance Group. 35 resource "google_compute_instance_template" "example" { 36 project = var.gcp_project_id 37 38 name_prefix = var.cluster_name 39 machine_type = var.machine_type 40 41 scheduling { 42 automatic_restart = true 43 on_host_maintenance = "MIGRATE" 44 preemptible = false 45 } 46 47 disk { 48 boot = true 49 auto_delete = true 50 source_image = "ubuntu-os-cloud/ubuntu-1604-lts" 51 } 52 53 network_interface { 54 network = "default" 55 56 # The presence of this property assigns a public IP address to each Compute Instance. We intentionally leave it 57 # blank so that an external IP address is selected automatically. 58 access_config { 59 } 60 } 61 } 62