├── .dockerignore ├── .github ├── conventional-commit-lint.yaml ├── release-please.yml ├── renovate.json ├── trusted-contribution.yml └── workflows │ ├── lint.yaml │ └── stale.yml ├── .gitignore ├── .kitchen.yml ├── CHANGELOG.md ├── CODEOWNERS ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── autogen ├── README.md ├── main.tf.tmpl ├── outputs.tf.tmpl ├── variables.tf.tmpl └── versions.tf.tmpl ├── autogen_modules.json ├── build ├── int.cloudbuild.yaml └── lint.cloudbuild.yaml ├── docs ├── upgrading_to_mig_v13.0.md └── upgrading_to_mig_v2.0.md ├── examples ├── compute_instance │ ├── disk_snapshot │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── multiple_interfaces │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── next_hop │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── simple │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ └── tags │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf ├── confidential_computing │ ├── README.md │ ├── main.tf │ ├── org_policies.tf │ ├── outputs.tf │ └── variables.tf ├── confidential_computing_intel │ ├── README.md │ ├── main.tf │ ├── org_policies.tf │ ├── outputs.tf │ └── variables.tf ├── instance_template │ ├── additional_disks │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── alias_ip_range │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── confidential_computing │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── encrypted_disks │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ └── simple │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf ├── it_simple_with_sa_creation │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ └── variables.tf ├── mig │ ├── autoscaler │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── full │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ ├── healthcheck │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ └── simple │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf ├── mig_stateful │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ └── variables.tf ├── mig_with_percent │ └── simple │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf ├── preemptible_and_regular_instance_templates │ └── simple │ │ ├── README.md │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf └── umig │ ├── full │ ├── main.tf │ ├── outputs.tf │ └── variables.tf │ ├── named_ports │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ └── variables.tf │ ├── simple │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ └── variables.tf │ └── static_ips │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ └── variables.tf ├── metadata.display.yaml ├── metadata.yaml ├── modules ├── compute_disk_snapshot │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── compute_instance │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── instance_template │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── mig │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── mig_with_percent │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── preemptible_and_regular_instance_templates │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf └── umig │ ├── README.md │ ├── main.tf │ ├── metadata.display.yaml │ ├── metadata.yaml │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf └── test ├── .gitignore ├── fixtures ├── compute_instance │ ├── disk_snapshot │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf │ └── simple_zone │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf ├── confidential_compute_instance │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── confidential_instance_template │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── confidential_intel_compute_instance │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── instance_simple │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── instance_template │ ├── additional_disks │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf │ ├── alias_ip_range │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf │ └── simple │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf ├── mig │ ├── autoscaler │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf │ ├── healthcheck │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf │ └── simple │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf ├── mig_stateful │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── mig_with_percent │ └── simple │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf ├── preemptible_and_regular_instance_templates │ └── simple │ │ ├── main.tf │ │ ├── network.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf ├── shared │ ├── network.tf │ └── variables.tf └── umig │ ├── named_ports │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf │ ├── simple │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf │ └── static_ips │ ├── main.tf │ ├── network.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── integration ├── confidential_compute_instance │ └── confidential_compute_instance_test.go ├── confidential_instance_template │ └── confidential_instance_template_test.go ├── confidential_intel_compute_instance │ └── confidential_intel_compute_instance_test.go ├── discover_test.go ├── disk_snapshot │ ├── controls │ │ └── disk_snapshot.rb │ └── inspec.yml ├── go.mod ├── go.sum ├── instance_simple │ └── instance_simple_test.go ├── instance_simple_zone │ ├── controls │ │ └── instance_simple_zone.rb │ └── inspec.yml ├── it_additional_disks │ ├── controls │ │ └── it_additional_disks.rb │ └── inspec.yml ├── it_alias_ip_range │ ├── controls │ │ └── it_alias_ip_range.rb │ └── inspec.yml ├── it_simple │ ├── controls │ │ └── it_simple.rb │ └── inspec.yml ├── it_simple_with_sa_creation │ └── it_simple_with_sa_creation_test.go ├── mig_autoscaler │ ├── controls │ │ └── mig_autoscaler.rb │ └── inspec.yml ├── mig_healthcheck │ ├── controls │ │ └── mig_healthcheck.rb │ └── inspec.yml ├── mig_simple │ ├── controls │ │ └── mig_simple.rb │ └── inspec.yml ├── mig_stateful │ └── mig_stateful_test.go ├── mig_with_percent_simple │ ├── controls │ │ └── mig_with_percent_simple.rb │ └── inspec.yml ├── preemptible_and_regular_instance_templates_simple │ ├── controls │ │ └── simple.rb │ └── inspec.yml ├── umig_named_ports │ ├── controls │ │ └── umig_named_ports.rb │ └── inspec.yml ├── umig_simple │ ├── controls │ │ └── umig_simple.rb │ └── inspec.yml └── umig_static_ips │ ├── controls │ └── umig_static_ips.rb │ └── inspec.yml └── setup ├── .gitignore ├── iam.tf ├── main.tf ├── outputs.tf ├── variables.tf └── versions.tf /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .terraform 3 | .terraform.d 4 | .kitchen 5 | terraform.tfstate.d 6 | test/fixtures/*/.terraform 7 | test/fixtures/*/terraform.tfstate.d 8 | examples/.kitchen 9 | examples/*/.terraform 10 | examples/*/terraform.tfstate.d 11 | -------------------------------------------------------------------------------- /.github/conventional-commit-lint.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022-2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # NOTE: This file is automatically generated from: 16 | # https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/blob/main/infra/terraform/test-org/github 17 | 18 | enabled: true 19 | always_check_pr_title: true 20 | -------------------------------------------------------------------------------- /.github/release-please.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | releaseType: terraform-module 16 | handleGHRelease: true 17 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["github>GoogleCloudPlatform/cloud-foundation-toolkit//infra/terraform/test-org/github/resources/renovate"] 4 | } 5 | -------------------------------------------------------------------------------- /.github/trusted-contribution.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # NOTE: This file is automatically generated from: 16 | # https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/blob/main/infra/terraform/test-org/github 17 | 18 | annotations: 19 | - type: comment 20 | text: "/gcbrun" 21 | trustedContributors: 22 | - release-please[bot] 23 | - renovate[bot] 24 | - renovate-bot 25 | - forking-renovate[bot] 26 | - dependabot[bot] 27 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2022-2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # NOTE: This file is automatically generated from: 16 | # https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/blob/main/infra/terraform/test-org/github 17 | 18 | name: "Close stale issues" 19 | on: 20 | schedule: 21 | - cron: "0 23 * * *" 22 | 23 | jobs: 24 | stale: 25 | if: github.repository_owner == 'GoogleCloudPlatform' || github.repository_owner == 'terraform-google-modules' 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/stale@v9 29 | with: 30 | repo-token: ${{ secrets.GITHUB_TOKEN }} 31 | stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days' 32 | stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days' 33 | exempt-issue-labels: 'triaged' 34 | exempt-pr-labels: 'dependencies,autorelease: pending' 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.terraform/** 2 | **tfstate* 3 | **/*.pem 4 | terraform.tfvars 5 | **/account.json 6 | **/credentials 7 | .DS_Store 8 | .terraform 9 | .terraform.tfstate.d 10 | *.pyc 11 | credentials*.json 12 | 13 | # JetBrains - PyCharm, IntelliJ, etc. 14 | .idea/ 15 | __pycache__/ 16 | *.iml 17 | .project 18 | 19 | # Kitchen files 20 | **/inspec.lock 21 | **/.kitchen 22 | **/kitchen.local.yml 23 | **/Gemfile.lock 24 | 25 | # tf lock file 26 | .terraform.lock.hcl 27 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # NOTE: This file is automatically generated from values at: 2 | # https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/blob/main/infra/terraform/test-org/org/locals.tf 3 | 4 | * @terraform-google-modules/cft-admins @ayushmjain @erlanderlo @q2w 5 | 6 | # NOTE: GitHub CODEOWNERS locations: 7 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-and-branch-protection 8 | 9 | CODEOWNERS @terraform-google-modules/cft-admins 10 | .github/CODEOWNERS @terraform-google-modules/cft-admins 11 | docs/CODEOWNERS @terraform-google-modules/cft-admins 12 | 13 | -------------------------------------------------------------------------------- /autogen/README.md: -------------------------------------------------------------------------------- 1 | {% if mig %} 2 | # Managed Instance Group (MIG) 3 | 4 | This module is used to create a [google_compute_region_instance_group_manager](https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager), 5 | and optionally, an autoscaler and healthchecks. 6 | 7 | {% else %} 8 | # Managed Instance Group (MIG) with percent 9 | 10 | This module allows you to set the percentage ratio of second version of instance template on Managed Instance Group. 11 | 12 | {% endif %} 13 | ## Usage 14 | 15 | See the [simple example](../../examples/{{ module_name }}/simple) for a usage example. 16 | 17 | ## Upgrading 18 | 19 | The current version is 2.X. The following guides are available to assist with upgrades: 20 | 21 | - [1.X -> 2.0](../../docs/upgrading_to_mig_v2.0.md) 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /autogen/versions.tf.tmpl: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 4.48, < 7" 23 | } 24 | google-beta = { 25 | source = "hashicorp/google-beta" 26 | version = ">= 4.48, < 7" 27 | } 28 | } 29 | provider_meta "google" { 30 | module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v13.2.4" 31 | } 32 | provider_meta "google-beta" { 33 | module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v13.2.4" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /autogen_modules.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "template_folder": "./autogen", 4 | "path": "./modules/mig", 5 | "options": { 6 | "module_path": "//modules/mig", 7 | "module_name": "mig", 8 | "module_name_hr": "mig", 9 | "mig": true 10 | } 11 | }, 12 | 13 | { 14 | "template_folder": "./autogen", 15 | "path": "./modules/mig_with_percent", 16 | "options": { 17 | "module_path": "//modules/mig_with_percent", 18 | "module_name": "mig_with_percent", 19 | "module_name_hr": "mig-with-percent", 20 | "mig_with_percent": true 21 | } 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /build/lint.cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | steps: 16 | - name: 'gcr.io/cloud-foundation-cicd/cft/developer-tools:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' 17 | id: 'lint' 18 | args: ['/usr/local/bin/test_lint.sh'] 19 | tags: 20 | - 'ci' 21 | - 'lint' 22 | substitutions: 23 | _DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools' 24 | _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.22' 25 | -------------------------------------------------------------------------------- /examples/compute_instance/disk_snapshot/README.md: -------------------------------------------------------------------------------- 1 | # disk-snapshot 2 | 3 | This is a simple example of how to use the compute_disk_snapshot module 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 11 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 12 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string,
scopes = set(string)
})
| `null` | no | 13 | | subnetwork | The subnetwork selflink to host the compute instances in | `any` | n/a | yes | 14 | 15 | ## Outputs 16 | 17 | | Name | Description | 18 | |------|-------------| 19 | | disk\_snapshots | List of disks snapshots and the snapshot policy | 20 | | instances\_self\_links | List of self-links for compute instances | 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/compute_instance/disk_snapshot/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instances_self_links" { 18 | description = "List of self-links for compute instances" 19 | value = module.compute_instance.instances_self_links 20 | } 21 | 22 | output "disk_snapshots" { 23 | description = "List of disks snapshots and the snapshot policy" 24 | value = module.disk_snapshots 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/compute_instance/disk_snapshot/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | type = string 20 | } 21 | 22 | variable "region" { 23 | description = "The GCP region to create and test resources in" 24 | type = string 25 | default = "us-central1" 26 | } 27 | 28 | variable "subnetwork" { 29 | description = "The subnetwork selflink to host the compute instances in" 30 | } 31 | 32 | variable "service_account" { 33 | default = null 34 | type = object({ 35 | email = string, 36 | scopes = set(string) 37 | }) 38 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 39 | } 40 | -------------------------------------------------------------------------------- /examples/compute_instance/multiple_interfaces/README.md: -------------------------------------------------------------------------------- 1 | # Instance with multiple interfaces 2 | 3 | This example creates a VM instance with multiple network interfaces. 4 | The subnets must be in the same region as the VM. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | project\_id | The Google Cloud project ID | `string` | n/a | yes | 12 | | subnet\_1 | Self link to a subnetwork in the same region as the VM. | `string` | n/a | yes | 13 | | subnet\_2 | Self link to a subnetwork in the same region as the VM. | `string` | n/a | yes | 14 | 15 | ## Outputs 16 | 17 | | Name | Description | 18 | |------|-------------| 19 | | instance\_self\_link | The URI of the instance rule being created | 20 | | network\_name\_1 | The name of the VPC network where the VM's first network interface is created | 21 | | network\_name\_2 | The name of the VPC network where the VM's second network interface is created | 22 | | project\_id | Google Cloud project ID | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/compute_instance/multiple_interfaces/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | # [START compute_vm_with_multiple_interface] 18 | resource "google_compute_instance" "default" { 19 | project = var.project_id # Replace with your project ID in quotes 20 | zone = "us-central1-b" 21 | name = "backend-instance" 22 | machine_type = "e2-medium" 23 | boot_disk { 24 | initialize_params { 25 | image = "debian-cloud/debian-9" 26 | } 27 | } 28 | network_interface { 29 | subnetwork = var.subnet_1 # Replace with self link to a subnetwork in quotes 30 | network_ip = "10.0.0.14" 31 | } 32 | network_interface { 33 | subnetwork = var.subnet_2 # Replace with self link to a subnetwork in quotes 34 | network_ip = "10.10.20.14" 35 | } 36 | } 37 | # [END compute_vm_with_multiple_interface] 38 | -------------------------------------------------------------------------------- /examples/compute_instance/multiple_interfaces/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | output "project_id" { 19 | value = google_compute_instance.default.project 20 | description = "Google Cloud project ID" 21 | } 22 | 23 | output "instance_self_link" { 24 | value = google_compute_instance.default.self_link 25 | description = "The URI of the instance rule being created" 26 | } 27 | 28 | output "network_name_1" { 29 | value = google_compute_instance.default.network_interface[0].network 30 | description = "The name of the VPC network where the VM's first network interface is created" 31 | } 32 | 33 | output "network_name_2" { 34 | value = google_compute_instance.default.network_interface[1].network 35 | description = "The name of the VPC network where the VM's second network interface is created" 36 | } 37 | -------------------------------------------------------------------------------- /examples/compute_instance/multiple_interfaces/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The Google Cloud project ID" 19 | type = string 20 | } 21 | 22 | variable "subnet_1" { 23 | description = "Self link to a subnetwork in the same region as the VM." 24 | type = string 25 | } 26 | 27 | variable "subnet_2" { 28 | description = "Self link to a subnetwork in the same region as the VM." 29 | type = string 30 | } 31 | -------------------------------------------------------------------------------- /examples/compute_instance/next_hop/README.md: -------------------------------------------------------------------------------- 1 | # Instance as next hop for a route 2 | 3 | This example creates a VM instance with IP forwarding enabled so that the 4 | VM can forward a packet originated by another VM. 5 | 6 | To use a VM as a next hop for a route, the VM needs to receive packets that have 7 | destinations other than itself. Because it forwards those packets, the packet 8 | sources are different from its own internal IP address. To accomplish this, you 9 | must enable IP forwarding for the VM. When IP forwarding is enabled, Google 10 | Cloud does not enforce packet source and destination checking. 11 | 12 | 13 | ## Inputs 14 | 15 | | Name | Description | Type | Default | Required | 16 | |------|-------------|------|---------|:--------:| 17 | | project\_id | The Google Cloud project ID | `string` | n/a | yes | 18 | 19 | ## Outputs 20 | 21 | | Name | Description | 22 | |------|-------------| 23 | | instance\_self\_link | The URI of the instance rule being created | 24 | | network\_name | The name of the VPC network where the VM instance is created | 25 | | project\_id | Google Cloud project ID | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/compute_instance/next_hop/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | # [START compute_vm_as_next_hop_create] 18 | resource "google_compute_instance" "default" { 19 | project = var.project_id # Replace this with your project ID in quotes 20 | zone = "southamerica-east1-b" 21 | name = "instance-next-hop" 22 | machine_type = "e2-medium" 23 | boot_disk { 24 | initialize_params { 25 | image = "debian-cloud/debian-9" 26 | } 27 | } 28 | network_interface { 29 | network = "default" 30 | } 31 | can_ip_forward = true 32 | } 33 | # [END compute_vm_as_next_hop_create] 34 | -------------------------------------------------------------------------------- /examples/compute_instance/next_hop/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | output "network_name" { 19 | value = google_compute_instance.default.network_interface[0].network 20 | description = "The name of the VPC network where the VM instance is created" 21 | } 22 | 23 | output "instance_self_link" { 24 | value = google_compute_instance.default.self_link 25 | description = "The URI of the instance rule being created" 26 | } 27 | 28 | output "project_id" { 29 | value = google_compute_instance.default.project 30 | description = "Google Cloud project ID" 31 | } 32 | -------------------------------------------------------------------------------- /examples/compute_instance/next_hop/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The Google Cloud project ID" 21 | type = string 22 | } 23 | -------------------------------------------------------------------------------- /examples/compute_instance/simple/README.md: -------------------------------------------------------------------------------- 1 | # instance-simple 2 | 3 | This is a simple, minimal example of how to use the compute_instance module 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | nat\_ip | Public ip address | `any` | `null` | no | 11 | | network\_tier | Network network\_tier | `string` | `"PREMIUM"` | no | 12 | | num\_instances | Number of instances to create | `any` | n/a | yes | 13 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 14 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 15 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string,
scopes = set(string)
})
| `null` | no | 16 | | subnetwork | The subnetwork selflink to host the compute instances in | `any` | n/a | yes | 17 | | zone | The GCP zone to create resources in | `string` | `null` | no | 18 | 19 | ## Outputs 20 | 21 | | Name | Description | 22 | |------|-------------| 23 | | available\_zones | List of available zones in region | 24 | | instances\_self\_links | List of self-links for compute instances | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/compute_instance/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "instance_template" { 18 | source = "terraform-google-modules/vm/google//modules/instance_template" 19 | version = "~> 13.0" 20 | 21 | region = var.region 22 | project_id = var.project_id 23 | subnetwork = var.subnetwork 24 | subnetwork_project = var.project_id 25 | service_account = var.service_account 26 | } 27 | 28 | module "compute_instance" { 29 | source = "terraform-google-modules/vm/google//modules/compute_instance" 30 | version = "~> 13.0" 31 | 32 | region = var.region 33 | zone = var.zone 34 | subnetwork = var.subnetwork 35 | subnetwork_project = var.project_id 36 | num_instances = var.num_instances 37 | hostname = "instance-simple" 38 | instance_template = module.instance_template.self_link 39 | deletion_protection = false 40 | 41 | access_config = [{ 42 | nat_ip = var.nat_ip 43 | network_tier = var.network_tier 44 | }, ] 45 | } 46 | -------------------------------------------------------------------------------- /examples/compute_instance/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instances_self_links" { 18 | description = "List of self-links for compute instances" 19 | value = module.compute_instance.instances_self_links 20 | } 21 | 22 | output "available_zones" { 23 | description = "List of available zones in region" 24 | value = module.compute_instance.available_zones 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/compute_instance/tags/README.md: -------------------------------------------------------------------------------- 1 | # Instance with tags 2 | 3 | This example creates a VM instance with network tags. 4 | Tags enable you to make firewall rules and routes applicable to 5 | specific VM instances. 6 | 7 | 8 | ## Inputs 9 | 10 | | Name | Description | Type | Default | Required | 11 | |------|-------------|------|---------|:--------:| 12 | | project\_id | The Google Cloud project ID | `string` | n/a | yes | 13 | 14 | ## Outputs 15 | 16 | | Name | Description | 17 | |------|-------------| 18 | | instance\_self\_link | The URI of the instance rule being created | 19 | | network\_name | The name of the VPC network where the VM instance is created | 20 | | project\_id | Google Cloud project ID | 21 | | tags | Tags added to VM instance | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/compute_instance/tags/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | # [START compute_vm_with_tags_create] 18 | resource "google_compute_instance" "default" { 19 | project = var.project_id # Replace this with your project ID in quotes 20 | zone = "southamerica-east1-b" 21 | name = "backend-instance" 22 | machine_type = "e2-medium" 23 | boot_disk { 24 | initialize_params { 25 | image = "debian-cloud/debian-9" 26 | } 27 | } 28 | network_interface { 29 | network = "default" 30 | } 31 | tags = ["health-check", "ssh"] 32 | } 33 | # [END compute_vm_with_tags_create] 34 | -------------------------------------------------------------------------------- /examples/compute_instance/tags/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | output "network_name" { 19 | value = google_compute_instance.default.network_interface[0].network 20 | description = "The name of the VPC network where the VM instance is created" 21 | } 22 | 23 | output "instance_self_link" { 24 | value = google_compute_instance.default.self_link 25 | description = "The URI of the instance rule being created" 26 | } 27 | 28 | output "tags" { 29 | value = google_compute_instance.default.tags 30 | description = "Tags added to VM instance" 31 | } 32 | 33 | output "project_id" { 34 | value = google_compute_instance.default.project 35 | description = "Google Cloud project ID" 36 | } 37 | -------------------------------------------------------------------------------- /examples/compute_instance/tags/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The Google Cloud project ID" 21 | type = string 22 | } 23 | -------------------------------------------------------------------------------- /examples/confidential_computing/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | output "self_link" { 19 | description = "Self-link to the instance template." 20 | value = module.instance_template.self_link 21 | } 22 | 23 | output "name" { 24 | description = "Name of the instance templates." 25 | value = module.instance_template.name 26 | } 27 | 28 | output "instance_self_link" { 29 | description = "Self-link for compute instance." 30 | value = module.compute_instance.instances_self_links[0] 31 | } 32 | 33 | output "suffix" { 34 | description = "Suffix used as an identifier for resources." 35 | value = local.default_suffix 36 | } 37 | -------------------------------------------------------------------------------- /examples/confidential_computing_intel/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | output "self_link" { 19 | description = "Self-link to the instance template." 20 | value = module.instance_template.self_link 21 | } 22 | 23 | output "name" { 24 | description = "Name of the instance templates." 25 | value = module.instance_template.name 26 | } 27 | 28 | output "instance_self_link" { 29 | description = "Self-link for compute instance." 30 | value = module.compute_instance.instances_self_links[0] 31 | } 32 | 33 | output "suffix" { 34 | description = "Suffix used as an identifier for resources." 35 | value = local.default_suffix 36 | } 37 | -------------------------------------------------------------------------------- /examples/instance_template/additional_disks/README.md: -------------------------------------------------------------------------------- 1 | # instance-template-additional-disks 2 | 3 | This example demonstrates how to use the instance_template module to create 4 | instance templates with additional persistent disks. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 14 | | subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no | 15 | 16 | ## Outputs 17 | 18 | | Name | Description | 19 | |------|-------------| 20 | | name | Name of the instance templates | 21 | | self\_link | Self-link to the instance template | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/instance_template/additional_disks/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates" 24 | value = module.instance_template.name 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/instance_template/additional_disks/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | type = string 22 | } 23 | 24 | variable "region" { 25 | description = "The GCP region to create and test resources in" 26 | type = string 27 | default = "us-central1" 28 | } 29 | 30 | variable "subnetwork" { 31 | description = "The name of the subnetwork create this instance in." 32 | default = "" 33 | } 34 | 35 | variable "service_account" { 36 | default = null 37 | type = object({ 38 | email = string 39 | scopes = set(string) 40 | }) 41 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 42 | } 43 | 44 | -------------------------------------------------------------------------------- /examples/instance_template/alias_ip_range/README.md: -------------------------------------------------------------------------------- 1 | # instance-template-alias-ip-range 2 | 3 | This example demonstrates how to use an alias IP range. 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 11 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 12 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 13 | | subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no | 14 | 15 | ## Outputs 16 | 17 | | Name | Description | 18 | |------|-------------| 19 | | name | Name of the instance templates | 20 | | self\_link | Self-link to the instance template | 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/instance_template/alias_ip_range/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | project = var.project_id 20 | region = var.region 21 | } 22 | 23 | resource "google_compute_address" "ip_address" { 24 | name = "external-ip-alias-ip-range" 25 | } 26 | 27 | module "instance_template" { 28 | source = "terraform-google-modules/vm/google//modules/instance_template" 29 | version = "~> 13.0" 30 | 31 | project_id = var.project_id 32 | region = var.region 33 | subnetwork = var.subnetwork 34 | service_account = var.service_account 35 | name_prefix = "alias-ip-range" 36 | 37 | alias_ip_range = { 38 | ip_cidr_range = "/24" 39 | subnetwork_range_name = var.subnetwork 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/instance_template/alias_ip_range/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates" 24 | value = module.instance_template.name 25 | } 26 | -------------------------------------------------------------------------------- /examples/instance_template/alias_ip_range/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | type = string 20 | } 21 | 22 | variable "region" { 23 | description = "The GCP region to create and test resources in" 24 | type = string 25 | default = "us-central1" 26 | } 27 | 28 | variable "subnetwork" { 29 | description = "The name of the subnetwork create this instance in." 30 | default = "" 31 | } 32 | 33 | variable "service_account" { 34 | default = null 35 | type = object({ 36 | email = string 37 | scopes = set(string) 38 | }) 39 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 40 | } 41 | -------------------------------------------------------------------------------- /examples/instance_template/confidential_computing/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "instance_template" { 18 | source = "terraform-google-modules/vm/google//modules/instance_template" 19 | version = "~> 13.0" 20 | 21 | region = var.region 22 | project_id = var.project_id 23 | service_account = var.service_account 24 | subnetwork = var.subnetwork 25 | 26 | name_prefix = "confidential-template" 27 | source_image_project = "ubuntu-os-cloud" 28 | source_image = "ubuntu-2004-lts" 29 | machine_type = "n2d-standard-2" 30 | min_cpu_platform = "AMD Milan" 31 | enable_confidential_vm = true 32 | confidential_instance_type = "SEV" 33 | } 34 | -------------------------------------------------------------------------------- /examples/instance_template/confidential_computing/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | output "self_link" { 19 | description = "Self-link to the instance template." 20 | value = module.instance_template.self_link 21 | } 22 | 23 | output "name" { 24 | description = "Name of the instance templates." 25 | value = module.instance_template.name 26 | } 27 | -------------------------------------------------------------------------------- /examples/instance_template/confidential_computing/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The Google Cloud project ID." 19 | type = string 20 | } 21 | 22 | variable "region" { 23 | description = "The GCP region to create and test resources in." 24 | type = string 25 | default = "us-central1" 26 | } 27 | 28 | variable "subnetwork" { 29 | description = "The subnetwork selflink to host the compute instances in." 30 | type = string 31 | } 32 | 33 | variable "service_account" { 34 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 35 | type = object({ 36 | email = string, 37 | scopes = set(string) 38 | }) 39 | default = null 40 | } 41 | -------------------------------------------------------------------------------- /examples/instance_template/encrypted_disks/README.md: -------------------------------------------------------------------------------- 1 | # instance-template-additional-disks 2 | 3 | This example demonstrates how to use the instance_template module to create 4 | instance templates with encrypted persistent disks. 5 | 6 | 7 | 8 | ## Inputs 9 | 10 | | Name | Description | Type | Default | Required | 11 | |------|-------------|------|---------|:--------:| 12 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 13 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 14 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 15 | | subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no | 16 | 17 | ## Outputs 18 | 19 | | Name | Description | 20 | |------|-------------| 21 | | name | Name of the instance templates | 22 | | self\_link | Self-link to the instance template | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/instance_template/encrypted_disks/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates" 24 | value = module.instance_template.name 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/instance_template/encrypted_disks/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | variable "project_id" { 19 | description = "The GCP project to use for integration tests" 20 | type = string 21 | } 22 | 23 | variable "region" { 24 | description = "The GCP region to create and test resources in" 25 | type = string 26 | default = "us-central1" 27 | } 28 | 29 | variable "subnetwork" { 30 | description = "The name of the subnetwork create this instance in." 31 | default = "" 32 | } 33 | 34 | variable "service_account" { 35 | default = null 36 | type = object({ 37 | email = string 38 | scopes = set(string) 39 | }) 40 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 41 | } 42 | 43 | -------------------------------------------------------------------------------- /examples/instance_template/simple/README.md: -------------------------------------------------------------------------------- 1 | # instance-template-simple 2 | 3 | This is a simple, minimal example of how to use the instance_template module. 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | enable\_nested\_virtualization | Defines whether the instance should have nested virtualization enabled. | `bool` | `false` | no | 11 | | labels | Labels, provided as a map | `map(string)` | n/a | yes | 12 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 13 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 14 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 15 | | subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no | 16 | | tags | Network tags, provided as a list | `list(string)` | n/a | yes | 17 | | threads\_per\_core | The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. | `string` | `null` | no | 18 | 19 | ## Outputs 20 | 21 | | Name | Description | 22 | |------|-------------| 23 | | name | Name of the instance templates | 24 | | self\_link | Self-link to the instance template | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/instance_template/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates" 24 | value = module.instance_template.name 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/it_simple_with_sa_creation/README.md: -------------------------------------------------------------------------------- 1 | # instance-template-simple 2 | 3 | This is a simple, minimal example of how to use the instance_template module. 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 11 | 12 | ## Outputs 13 | 14 | | Name | Description | 15 | |------|-------------| 16 | | name | Name of the instance templates | 17 | | project\_id | The GCP project to use for integration tests | 18 | | self\_link | Self-link to the instance template | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/it_simple_with_sa_creation/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2025 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates" 24 | value = module.instance_template.name 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | -------------------------------------------------------------------------------- /examples/it_simple_with_sa_creation/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2025 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | type = string 22 | } 23 | -------------------------------------------------------------------------------- /examples/mig/autoscaler/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | project = var.project_id 20 | region = var.region 21 | } 22 | 23 | provider "google-beta" { 24 | 25 | project = var.project_id 26 | region = var.region 27 | } 28 | 29 | module "instance_template" { 30 | source = "terraform-google-modules/vm/google//modules/instance_template" 31 | version = "~> 13.0" 32 | 33 | project_id = var.project_id 34 | region = var.region 35 | subnetwork = var.subnetwork 36 | service_account = var.service_account 37 | } 38 | 39 | module "mig" { 40 | source = "terraform-google-modules/vm/google//modules/mig" 41 | version = "~> 13.0" 42 | 43 | project_id = var.project_id 44 | region = var.region 45 | hostname = "mig-autoscaler" 46 | autoscaling_enabled = var.autoscaling_enabled 47 | min_replicas = var.min_replicas 48 | autoscaling_cpu = var.autoscaling_cpu 49 | instance_template = module.instance_template.self_link 50 | } 51 | 52 | -------------------------------------------------------------------------------- /examples/mig/autoscaler/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instance_template_self_link" { 18 | description = "Self-link of instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "mig_self_link" { 23 | description = "Self-link for managed instance group" 24 | value = module.mig.self_link 25 | } 26 | 27 | output "region" { 28 | description = "The GCP region to create and test resources in" 29 | value = var.region 30 | } 31 | -------------------------------------------------------------------------------- /examples/mig/full/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instance_template_self_link" { 18 | description = "Self-link of instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "mig_self_link" { 23 | description = "Self-link for managed instance group" 24 | value = module.mig.self_link 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/mig/healthcheck/README.md: -------------------------------------------------------------------------------- 1 | # vm-autoscaler 2 | 3 | This is an example of how to use the MIG module to create a managed instance 4 | group with an autoscaler. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string,
scopes = set(string)
})
| `null` | no | 14 | 15 | ## Outputs 16 | 17 | | Name | Description | 18 | |------|-------------| 19 | | instance\_template\_self\_link | Self-link of instance template | 20 | | mig\_self\_link | Self-link for managed instance group | 21 | | region | The GCP region to create and test resources in | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/mig/healthcheck/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instance_template_self_link" { 18 | description = "Self-link of instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "mig_self_link" { 23 | description = "Self-link for managed instance group" 24 | value = module.mig.self_link 25 | } 26 | 27 | output "region" { 28 | description = "The GCP region to create and test resources in" 29 | value = var.region 30 | } 31 | -------------------------------------------------------------------------------- /examples/mig/healthcheck/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | type = string 20 | } 21 | 22 | variable "region" { 23 | description = "The GCP region to create and test resources in" 24 | type = string 25 | default = "us-central1" 26 | } 27 | 28 | variable "service_account" { 29 | default = null 30 | type = object({ 31 | email = string, 32 | scopes = set(string) 33 | }) 34 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 35 | } 36 | -------------------------------------------------------------------------------- /examples/mig/simple/README.md: -------------------------------------------------------------------------------- 1 | # mig-simple 2 | 3 | This is a simple, minimal example of how to use the MIG module to create a 4 | managed instance group. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 14 | | subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | 15 | | target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | `any` | n/a | yes | 16 | 17 | ## Outputs 18 | 19 | | Name | Description | 20 | |------|-------------| 21 | | region | The GCP region to create and test resources in | 22 | | self\_link | Self-link of the managed instance group | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/mig/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | region = var.region 20 | } 21 | 22 | provider "google-beta" { 23 | 24 | region = var.region 25 | } 26 | 27 | module "instance_template" { 28 | source = "terraform-google-modules/vm/google//modules/instance_template" 29 | version = "~> 13.0" 30 | 31 | project_id = var.project_id 32 | region = var.region 33 | subnetwork = var.subnetwork 34 | service_account = var.service_account 35 | subnetwork_project = var.project_id 36 | } 37 | 38 | module "mig" { 39 | source = "terraform-google-modules/vm/google//modules/mig" 40 | version = "~> 13.0" 41 | 42 | project_id = var.project_id 43 | region = var.region 44 | target_size = var.target_size 45 | hostname = "mig-simple" 46 | instance_template = module.instance_template.self_link 47 | } 48 | 49 | -------------------------------------------------------------------------------- /examples/mig/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link of the managed instance group" 19 | value = module.mig.self_link 20 | } 21 | 22 | output "region" { 23 | description = "The GCP region to create and test resources in" 24 | value = var.region 25 | } 26 | -------------------------------------------------------------------------------- /examples/mig/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | type = string 22 | } 23 | 24 | variable "region" { 25 | description = "The GCP region to create and test resources in" 26 | type = string 27 | default = "us-central1" 28 | } 29 | 30 | variable "subnetwork" { 31 | description = "The subnetwork to host the compute instances in" 32 | } 33 | 34 | variable "target_size" { 35 | description = "The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set." 36 | } 37 | 38 | variable "service_account" { 39 | default = null 40 | type = object({ 41 | email = string 42 | scopes = set(string) 43 | }) 44 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 45 | } 46 | 47 | -------------------------------------------------------------------------------- /examples/mig_stateful/README.md: -------------------------------------------------------------------------------- 1 | # mig-simple 2 | 3 | This is a simple, minimal example of how to use the MIG module to create a 4 | managed instance group. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 14 | | subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | 15 | | target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | `any` | n/a | yes | 16 | 17 | ## Outputs 18 | 19 | | Name | Description | 20 | |------|-------------| 21 | | region | The GCP region to create and test resources in | 22 | | self\_link | Self-link of the managed instance group | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/mig_stateful/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link of the managed instance group" 19 | value = module.mig.self_link 20 | } 21 | 22 | output "region" { 23 | description = "The GCP region to create and test resources in" 24 | value = var.region 25 | } 26 | -------------------------------------------------------------------------------- /examples/mig_with_percent/simple/README.md: -------------------------------------------------------------------------------- 1 | # mig_with_percent-simple 2 | 3 | This is a simple, minimal example of how to use the MIG with percent module to create a 4 | managed instance group. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account email address and scopes |
object({
email = string
scopes = set(string)
})
| `null` | no | 14 | | subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | 15 | 16 | ## Outputs 17 | 18 | | Name | Description | 19 | |------|-------------| 20 | | preemptible\_self\_link | Self-link of preemptible instance template | 21 | | region | The GCP region to create and test resources in | 22 | | regular\_self\_link | Self-link of regular instance template | 23 | | self\_link | Self-link of the managed instance group | 24 | 25 | 26 | -------------------------------------------------------------------------------- /examples/mig_with_percent/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link of the managed instance group" 19 | value = module.mig_with_percent.self_link 20 | } 21 | 22 | output "region" { 23 | description = "The GCP region to create and test resources in" 24 | value = var.region 25 | } 26 | 27 | output "preemptible_self_link" { 28 | description = "Self-link of preemptible instance template" 29 | value = module.preemptible_and_regular_instance_templates.preemptible_self_link 30 | } 31 | 32 | output "regular_self_link" { 33 | description = "Self-link of regular instance template" 34 | value = module.preemptible_and_regular_instance_templates.regular_self_link 35 | } 36 | -------------------------------------------------------------------------------- /examples/mig_with_percent/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | type = string 22 | } 23 | 24 | variable "region" { 25 | description = "The GCP region to create and test resources in" 26 | type = string 27 | default = "us-central1" 28 | } 29 | 30 | variable "subnetwork" { 31 | description = "The subnetwork to host the compute instances in" 32 | } 33 | 34 | variable "service_account" { 35 | default = null 36 | type = object({ 37 | email = string 38 | scopes = set(string) 39 | }) 40 | description = "Service account email address and scopes" 41 | } 42 | -------------------------------------------------------------------------------- /examples/preemptible_and_regular_instance_templates/simple/README.md: -------------------------------------------------------------------------------- 1 | # preemptible_and_regular_instance_templates-simple 2 | 3 | This creates instance templates for both preemptible VM and regular VM 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | labels | Labels, provided as a map | `map(string)` | n/a | yes | 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 14 | | subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no | 15 | | tags | Network tags, provided as a list | `list(string)` | n/a | yes | 16 | 17 | ## Outputs 18 | 19 | | Name | Description | 20 | |------|-------------| 21 | | preemptible\_name | Name of the preemptible instance templates | 22 | | preemptible\_self\_link | Self-link to the preemptible instance template | 23 | | regular\_name | Name of the regular instance templates | 24 | | regular\_self\_link | Self-link to the regular instance template | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/preemptible_and_regular_instance_templates/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | project = var.project_id 20 | region = var.region 21 | } 22 | 23 | module "preemptible_and_regular_instance_templates" { 24 | source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates" 25 | version = "~> 13.0" 26 | 27 | subnetwork = var.subnetwork 28 | project_id = var.project_id 29 | region = var.region 30 | service_account = var.service_account 31 | name_prefix = "pvm-and-regular-simple" 32 | tags = var.tags 33 | labels = var.labels 34 | } 35 | -------------------------------------------------------------------------------- /examples/preemptible_and_regular_instance_templates/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "regular_self_link" { 18 | description = "Self-link to the regular instance template" 19 | value = module.preemptible_and_regular_instance_templates.regular_self_link 20 | } 21 | 22 | output "regular_name" { 23 | description = "Name of the regular instance templates" 24 | value = module.preemptible_and_regular_instance_templates.regular_name 25 | } 26 | 27 | output "preemptible_self_link" { 28 | description = "Self-link to the preemptible instance template" 29 | value = module.preemptible_and_regular_instance_templates.preemptible_self_link 30 | } 31 | 32 | output "preemptible_name" { 33 | description = "Name of the preemptible instance templates" 34 | value = module.preemptible_and_regular_instance_templates.preemptible_name 35 | } 36 | -------------------------------------------------------------------------------- /examples/umig/full/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instance_template_self_link" { 18 | description = "Self-link of instance template" 19 | value = module.instance_template.self_link 20 | } 21 | 22 | output "umig_self_links" { 23 | description = "List of self-links for unmanaged instance groups" 24 | value = module.umig.self_links 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/umig/named_ports/README.md: -------------------------------------------------------------------------------- 1 | # umig-named-ports 2 | 3 | This is an example of how to use the UMIG module to create unmanaged instance 4 | groups with named ports 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | named\_ports | Named name and named port |
list(object({
name = string
port = number
}))
| `[]` | no | 12 | | num\_instances | Number of instances to create | `any` | n/a | yes | 13 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 14 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 15 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account |
object({
email = string
scopes = set(string)
})
| `null` | no | 16 | | subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | 17 | 18 | ## Outputs 19 | 20 | | Name | Description | 21 | |------|-------------| 22 | | available\_zones | List of available zones in region | 23 | | instances\_self\_links | List of self-links for compute instances | 24 | | self\_links | List of self-links of unmanaged instance groups | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/umig/named_ports/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | project = var.project_id 20 | region = var.region 21 | } 22 | 23 | module "instance_template" { 24 | source = "terraform-google-modules/vm/google//modules/instance_template" 25 | version = "~> 13.0" 26 | 27 | project_id = var.project_id 28 | region = var.region 29 | subnetwork = var.subnetwork 30 | service_account = var.service_account 31 | } 32 | 33 | module "umig" { 34 | source = "terraform-google-modules/vm/google//modules/umig" 35 | version = "~> 13.0" 36 | 37 | project_id = var.project_id 38 | subnetwork = var.subnetwork 39 | subnetwork_project = var.project_id 40 | num_instances = var.num_instances 41 | hostname = "umig-named-ports" 42 | instance_template = module.instance_template.self_link 43 | named_ports = var.named_ports 44 | region = var.region 45 | } 46 | -------------------------------------------------------------------------------- /examples/umig/named_ports/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links of unmanaged instance groups" 19 | value = module.umig.self_links 20 | } 21 | 22 | output "instances_self_links" { 23 | description = "List of self-links for compute instances" 24 | value = module.umig.instances_self_links 25 | } 26 | 27 | output "available_zones" { 28 | description = "List of available zones in region" 29 | value = module.umig.available_zones 30 | } 31 | 32 | -------------------------------------------------------------------------------- /examples/umig/simple/README.md: -------------------------------------------------------------------------------- 1 | # umig-simple 2 | 3 | This is a simple, minimal example of how to use the UMIG module 4 | 5 | 6 | ## Inputs 7 | 8 | | Name | Description | Type | Default | Required | 9 | |------|-------------|------|---------|:--------:| 10 | | num\_instances | Number of instances to create | `any` | n/a | yes | 11 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 12 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 13 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 14 | | subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | 15 | 16 | ## Outputs 17 | 18 | | Name | Description | 19 | |------|-------------| 20 | | available\_zones | List of available zones in region | 21 | | instances\_self\_links | List of self-links for compute instances | 22 | | self\_links | List of self-links of unmanaged instance groups | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/umig/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | project = var.project_id 20 | region = var.region 21 | } 22 | 23 | module "instance_template" { 24 | source = "terraform-google-modules/vm/google//modules/instance_template" 25 | version = "~> 13.0" 26 | 27 | project_id = var.project_id 28 | region = var.region 29 | subnetwork = var.subnetwork 30 | subnetwork_project = var.project_id 31 | service_account = var.service_account 32 | } 33 | 34 | module "umig" { 35 | source = "terraform-google-modules/vm/google//modules/umig" 36 | version = "~> 13.0" 37 | 38 | project_id = var.project_id 39 | subnetwork = var.subnetwork 40 | subnetwork_project = var.project_id 41 | num_instances = var.num_instances 42 | hostname = "umig-simple" 43 | instance_template = module.instance_template.self_link 44 | region = var.region 45 | } 46 | -------------------------------------------------------------------------------- /examples/umig/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links of unmanaged instance groups" 19 | value = module.umig.self_links 20 | } 21 | 22 | output "instances_self_links" { 23 | description = "List of self-links for compute instances" 24 | value = module.umig.instances_self_links 25 | } 26 | 27 | output "available_zones" { 28 | description = "List of available zones in region" 29 | value = module.umig.available_zones 30 | } 31 | 32 | -------------------------------------------------------------------------------- /examples/umig/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | type = string 22 | } 23 | 24 | variable "region" { 25 | description = "The GCP region to create and test resources in" 26 | type = string 27 | default = "us-central1" 28 | } 29 | 30 | variable "subnetwork" { 31 | description = "The subnetwork to host the compute instances in" 32 | } 33 | 34 | variable "num_instances" { 35 | description = "Number of instances to create" 36 | } 37 | 38 | variable "service_account" { 39 | default = null 40 | type = object({ 41 | email = string 42 | scopes = set(string) 43 | }) 44 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 45 | } 46 | 47 | -------------------------------------------------------------------------------- /examples/umig/static_ips/README.md: -------------------------------------------------------------------------------- 1 | # umig-static-ips 2 | 3 | This is an example to demonstrate how to use the UMIG module to create unmanaged 4 | instance groups with user-specified static IPs. 5 | 6 | 7 | ## Inputs 8 | 9 | | Name | Description | Type | Default | Required | 10 | |------|-------------|------|---------|:--------:| 11 | | num\_instances | Number of instances to create | `string` | `"1"` | no | 12 | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | 13 | | region | The GCP region to create and test resources in | `string` | `"us-central1"` | no | 14 | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| `null` | no | 15 | | static\_ips | List of static IPs for VM instances | `list(string)` | n/a | yes | 16 | | subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes | 17 | 18 | ## Outputs 19 | 20 | | Name | Description | 21 | |------|-------------| 22 | | available\_zones | List of available zones in region | 23 | | instances\_self\_links | List of self-links for compute instances | 24 | | self\_links | List of self-links of unmanaged instance groups | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/umig/static_ips/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | provider "google" { 18 | 19 | project = var.project_id 20 | region = var.region 21 | } 22 | 23 | module "instance_template" { 24 | source = "terraform-google-modules/vm/google//modules/instance_template" 25 | version = "~> 13.0" 26 | 27 | project_id = var.project_id 28 | region = var.region 29 | subnetwork = var.subnetwork 30 | subnetwork_project = var.project_id 31 | service_account = var.service_account 32 | } 33 | 34 | module "umig" { 35 | source = "terraform-google-modules/vm/google//modules/umig" 36 | version = "~> 13.0" 37 | 38 | project_id = var.project_id 39 | subnetwork = var.subnetwork 40 | subnetwork_project = var.project_id 41 | num_instances = var.num_instances 42 | hostname = "umig-static-ips" 43 | instance_template = module.instance_template.self_link 44 | static_ips = var.static_ips 45 | region = var.region 46 | } 47 | -------------------------------------------------------------------------------- /examples/umig/static_ips/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links of unmanaged instance groups" 19 | value = module.umig.self_links 20 | } 21 | 22 | output "instances_self_links" { 23 | description = "List of self-links for compute instances" 24 | value = module.umig.instances_self_links 25 | } 26 | 27 | output "available_zones" { 28 | description = "List of available zones in region" 29 | value = module.umig.available_zones 30 | } 31 | 32 | -------------------------------------------------------------------------------- /examples/umig/static_ips/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | type = string 22 | } 23 | 24 | variable "region" { 25 | description = "The GCP region to create and test resources in" 26 | type = string 27 | default = "us-central1" 28 | } 29 | 30 | variable "subnetwork" { 31 | description = "The subnetwork to host the compute instances in" 32 | } 33 | 34 | variable "num_instances" { 35 | description = "Number of instances to create" 36 | default = "1" 37 | } 38 | 39 | variable "static_ips" { 40 | type = list(string) 41 | description = "List of static IPs for VM instances" 42 | } 43 | 44 | variable "service_account" { 45 | default = null 46 | type = object({ 47 | email = string 48 | scopes = set(string) 49 | }) 50 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 51 | } 52 | -------------------------------------------------------------------------------- /metadata.display.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: blueprints.cloud.google.com/v1alpha1 16 | kind: BlueprintMetadata 17 | metadata: 18 | name: terraform-google-vm-display 19 | annotations: 20 | config.kubernetes.io/local-config: "true" 21 | spec: 22 | info: 23 | title: terraform-google-vm 24 | source: 25 | repo: https://github.com/terraform-google-modules/terraform-google-vm 26 | sourceType: git 27 | ui: 28 | input: {} 29 | -------------------------------------------------------------------------------- /modules/compute_disk_snapshot/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "policy" { 18 | description = "Resource snapshot policy details." 19 | value = google_compute_resource_policy.policy 20 | } 21 | 22 | output "attachments" { 23 | description = "Disk attachments to the resource policy." 24 | value = google_compute_disk_resource_policy_attachment.attachment[*] 25 | } 26 | -------------------------------------------------------------------------------- /modules/compute_disk_snapshot/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 3.71, < 7" 23 | } 24 | null = { 25 | source = "hashicorp/null" 26 | version = ">= 2.1" 27 | } 28 | } 29 | provider_meta "google" { 30 | module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v13.2.4" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /modules/compute_instance/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instances_self_links" { 18 | description = "List of self-links for compute instances" 19 | value = google_compute_instance_from_template.compute_instance[*].self_link 20 | } 21 | 22 | output "instances_details" { 23 | description = "List of all details for compute instances" 24 | sensitive = true 25 | value = google_compute_instance_from_template.compute_instance[*] 26 | } 27 | 28 | output "available_zones" { 29 | description = "List of available zones in region" 30 | value = data.google_compute_zones.available.names 31 | } 32 | -------------------------------------------------------------------------------- /modules/compute_instance/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 3.88, < 7" 23 | } 24 | } 25 | provider_meta "google" { 26 | module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v13.2.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /modules/instance_template/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link_unique" { 18 | description = "Unique self-link of instance template (recommended output to use instead of self_link)" 19 | value = google_compute_instance_template.tpl.self_link_unique 20 | } 21 | 22 | output "self_link" { 23 | description = "Self-link of instance template" 24 | value = google_compute_instance_template.tpl.self_link 25 | } 26 | 27 | output "name" { 28 | description = "Name of instance template" 29 | value = google_compute_instance_template.tpl.name 30 | } 31 | 32 | output "tags" { 33 | description = "Tags that will be associated with instance(s)" 34 | value = google_compute_instance_template.tpl.tags 35 | } 36 | 37 | output "service_account_info" { 38 | description = "Service account id and email" 39 | value = local.service_account_output 40 | } 41 | -------------------------------------------------------------------------------- /modules/instance_template/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google-beta = { 21 | source = "hashicorp/google-beta" 22 | version = ">= 5.36, < 7" 23 | } 24 | } 25 | provider_meta "google" { 26 | module_name = "blueprints/terraform/terraform-google-vm:instance_template/v13.2.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /modules/mig/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 4.48, < 7" 23 | } 24 | google-beta = { 25 | source = "hashicorp/google-beta" 26 | version = ">= 4.48, < 7" 27 | } 28 | } 29 | provider_meta "google" { 30 | module_name = "blueprints/terraform/terraform-google-vm:mig/v13.2.4" 31 | } 32 | provider_meta "google-beta" { 33 | module_name = "blueprints/terraform/terraform-google-vm:mig/v13.2.4" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/mig_with_percent/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // This file was automatically generated from a template in ./autogen 18 | 19 | output "self_link" { 20 | description = "Self-link of managed instance group" 21 | value = google_compute_region_instance_group_manager.mig_with_percent.self_link 22 | } 23 | 24 | output "instance_group" { 25 | description = "Instance-group url of managed instance group" 26 | value = google_compute_region_instance_group_manager.mig_with_percent.instance_group 27 | } 28 | 29 | output "instance_group_manager" { 30 | description = "An instance of google_compute_region_instance_group_manager of the instance group." 31 | value = google_compute_region_instance_group_manager.mig_with_percent 32 | } 33 | 34 | output "health_check_self_links" { 35 | description = "All self_links of healthchecks created for the instance group." 36 | value = local.healthchecks 37 | } 38 | -------------------------------------------------------------------------------- /modules/mig_with_percent/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 4.48, < 7" 23 | } 24 | google-beta = { 25 | source = "hashicorp/google-beta" 26 | version = ">= 4.48, < 7" 27 | } 28 | } 29 | provider_meta "google" { 30 | module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v13.2.4" 31 | } 32 | provider_meta "google-beta" { 33 | module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v13.2.4" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/preemptible_and_regular_instance_templates/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "preemptible_self_link" { 18 | description = "Self-link of preemptible instance template" 19 | value = module.preemptible.self_link 20 | } 21 | 22 | output "preemptible_name" { 23 | description = "Name of preemptible instance template" 24 | value = module.preemptible.name 25 | } 26 | 27 | output "regular_self_link" { 28 | description = "Self-link of regular instance template" 29 | value = module.regular.self_link 30 | } 31 | 32 | output "regular_name" { 33 | description = "Name of regular instance template" 34 | value = module.regular.name 35 | } 36 | -------------------------------------------------------------------------------- /modules/preemptible_and_regular_instance_templates/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = ">= 3.88, < 7" 21 | google-beta = ">= 3.88, < 7" 22 | } 23 | provider_meta "google" { 24 | module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v13.2.4" 25 | } 26 | provider_meta "google-beta" { 27 | module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v13.2.4" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /modules/umig/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links for unmanaged instance groups" 19 | value = google_compute_instance_group.instance_group[*].self_link 20 | } 21 | 22 | output "umig_details" { 23 | description = "List of all details for unmanaged instance groups" 24 | value = google_compute_instance_group.instance_group[*] 25 | } 26 | 27 | output "instances_self_links" { 28 | description = "List of self-links for compute instances" 29 | value = google_compute_instance_from_template.compute_instance[*].self_link 30 | } 31 | 32 | output "instances_details" { 33 | description = "List of all details for compute instances" 34 | sensitive = true 35 | value = google_compute_instance_from_template.compute_instance[*] 36 | } 37 | 38 | output "available_zones" { 39 | description = "List of available zones in region" 40 | value = data.google_compute_zones.available.names 41 | } 42 | -------------------------------------------------------------------------------- /modules/umig/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=1.3.0" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 3.88, < 7" 23 | } 24 | } 25 | provider_meta "google" { 26 | module_name = "blueprints/terraform/terraform-google-vm:umig/v13.2.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | source.sh 2 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/disk_snapshot/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module "disk_snapshot" { 19 | source = "../../../../examples/compute_instance/disk_snapshot" 20 | project_id = var.project_id 21 | region = "us-central1" 22 | subnetwork = google_compute_subnetwork.main.self_link 23 | service_account = var.service_account 24 | } 25 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/disk_snapshot/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/compute_instance/disk_snapshot/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instances_self_links" { 18 | description = "List of instance self-links" 19 | value = module.disk_snapshot.instances_self_links 20 | } 21 | 22 | output "project_id" { 23 | description = "The GCP project to use for integration tests" 24 | value = var.project_id 25 | } 26 | 27 | output "disk_snapshots" { 28 | description = "List of disks snapshots and the snapshot policy" 29 | value = module.disk_snapshot.disk_snapshots 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/disk_snapshot/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/disk_snapshot/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/simple_zone/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "instance_simple" { 18 | source = "../../../../examples/compute_instance/simple" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | zone = "us-central1-b" 22 | subnetwork = google_compute_subnetwork.main.self_link 23 | num_instances = 2 24 | service_account = var.service_account 25 | } 26 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/simple_zone/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/compute_instance/simple_zone/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instances_self_links" { 18 | description = "List of instance self-links" 19 | value = module.instance_simple.instances_self_links 20 | } 21 | 22 | output "project_id" { 23 | description = "The GCP project to use for integration tests" 24 | value = var.project_id 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/simple_zone/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/fixtures/compute_instance/simple_zone/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | required_providers { 20 | random = { 21 | source = "hashicorp/random" 22 | version = ">= 3.0" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/fixtures/confidential_compute_instance/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "confidential_computing" { 18 | source = "../../../examples/confidential_computing" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | keyring = "key-ring-test" 23 | key = "key-test" 24 | service_account_roles = ["roles/compute.imageUser", "roles/compute.networkUser"] 25 | } 26 | -------------------------------------------------------------------------------- /test/fixtures/confidential_compute_instance/network.tf: -------------------------------------------------------------------------------- 1 | ../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/confidential_compute_instance/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template." 19 | value = module.confidential_computing.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates." 24 | value = module.confidential_computing.name 25 | } 26 | 27 | output "instance_self_link" { 28 | description = "Self-link for compute instance" 29 | value = module.confidential_computing.instance_self_link 30 | } 31 | 32 | output "project_id" { 33 | description = "The GCP project to use for integration tests." 34 | value = var.project_id 35 | } 36 | 37 | output "suffix" { 38 | description = "Suffix used as an identifier for resources." 39 | value = module.confidential_computing.suffix 40 | } 41 | -------------------------------------------------------------------------------- /test/fixtures/confidential_compute_instance/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests." 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /test/fixtures/confidential_compute_instance/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.13" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/confidential_instance_template/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "confidential_simple" { 18 | source = "../../../examples/instance_template/confidential_computing" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | service_account = var.service_account 23 | } 24 | -------------------------------------------------------------------------------- /test/fixtures/confidential_instance_template/network.tf: -------------------------------------------------------------------------------- 1 | ../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/confidential_instance_template/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template." 19 | value = module.confidential_simple.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates." 24 | value = module.confidential_simple.name 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests." 29 | value = var.project_id 30 | } 31 | 32 | output "service_account" { 33 | description = "Service account to attach to the instance" 34 | value = var.service_account 35 | } 36 | -------------------------------------------------------------------------------- /test/fixtures/confidential_instance_template/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests." 19 | type = string 20 | } 21 | 22 | variable "service_account" { 23 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 24 | type = object({ 25 | email = string 26 | scopes = list(string) 27 | }) 28 | default = null 29 | } 30 | -------------------------------------------------------------------------------- /test/fixtures/confidential_instance_template/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.13" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/confidential_intel_compute_instance/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "confidential_computing_intel" { 18 | source = "../../../examples/confidential_computing_intel" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | keyring = "key-ring-test" 23 | key = "key-test" 24 | service_account_roles = ["roles/compute.imageUser", "roles/compute.networkUser"] 25 | } 26 | -------------------------------------------------------------------------------- /test/fixtures/confidential_intel_compute_instance/network.tf: -------------------------------------------------------------------------------- 1 | ../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/confidential_intel_compute_instance/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to the instance template." 19 | value = module.confidential_computing_intel.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of the instance templates." 24 | value = module.confidential_computing_intel.name 25 | } 26 | 27 | output "instance_self_link" { 28 | description = "Self-link for compute instance." 29 | value = module.confidential_computing_intel.instance_self_link 30 | } 31 | 32 | output "project_id" { 33 | description = "The GCP project to use for integration tests." 34 | value = var.project_id 35 | } 36 | 37 | output "suffix" { 38 | description = "Suffix used as an identifier for resources." 39 | value = module.confidential_computing_intel.suffix 40 | } 41 | -------------------------------------------------------------------------------- /test/fixtures/confidential_intel_compute_instance/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests." 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /test/fixtures/confidential_intel_compute_instance/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.13" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/instance_simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module "instance_simple" { 19 | source = "../../../examples/compute_instance/simple" 20 | project_id = var.project_id 21 | region = "us-central1" 22 | subnetwork = google_compute_subnetwork.main.self_link 23 | num_instances = 4 24 | service_account = var.service_account 25 | } 26 | -------------------------------------------------------------------------------- /test/fixtures/instance_simple/network.tf: -------------------------------------------------------------------------------- 1 | ../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/instance_simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "instances_self_links" { 18 | description = "List of instance self-links" 19 | value = module.instance_simple.instances_self_links 20 | } 21 | 22 | output "project_id" { 23 | description = "The GCP project to use for integration tests" 24 | value = var.project_id 25 | } 26 | 27 | output "service_account" { 28 | description = "Service account to attach to the instance" 29 | value = var.service_account 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/instance_simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/fixtures/instance_simple/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/additional_disks/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "instance_template_additional_disks" { 18 | source = "../../../../examples/instance_template/additional_disks" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | service_account = var.service_account 22 | } 23 | 24 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/additional_disks/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/instance_template/additional_disks/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to instance template" 19 | value = module.instance_template_additional_disks.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of instance template" 24 | value = module.instance_template_additional_disks.name 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/additional_disks/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | 22 | 23 | variable "service_account" { 24 | default = null 25 | type = object({ 26 | email = string 27 | scopes = list(string) 28 | }) 29 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/additional_disks/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/alias_ip_range/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "instance_template_alias_ip_range" { 18 | source = "../../../../examples/instance_template/alias_ip_range" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | service_account = var.service_account 22 | } 23 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/alias_ip_range/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/instance_template/alias_ip_range/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to instance template" 19 | value = module.instance_template_alias_ip_range.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of instance template" 24 | value = module.instance_template_alias_ip_range.name 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | output "subnetwork_name" { 33 | description = "The GCP subnetwork name to use for integration tests" 34 | value = google_compute_subnetwork.main.name 35 | } 36 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/alias_ip_range/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/alias_ip_range/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "instance_template_simple" { 18 | source = "../../../../examples/instance_template/simple" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | service_account = var.service_account 22 | tags = ["foo", "bar"] 23 | 24 | labels = { 25 | environment = "dev" 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/simple/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/instance_template/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link to instance template" 19 | value = module.instance_template_simple.self_link 20 | } 21 | 22 | output "name" { 23 | description = "Name of instance template" 24 | value = module.instance_template_simple.name 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | 22 | 23 | variable "service_account" { 24 | default = null 25 | type = object({ 26 | email = string 27 | scopes = list(string) 28 | }) 29 | } 30 | 31 | -------------------------------------------------------------------------------- /test/fixtures/instance_template/simple/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/mig/autoscaler/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "mig_autoscaler" { 18 | source = "../../../../examples/mig/autoscaler" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | service_account = var.service_account 22 | autoscaling_enabled = "true" 23 | min_replicas = 4 24 | 25 | autoscaling_cpu = [ 26 | { 27 | target = 0.6, 28 | predictive_method = null, 29 | }, 30 | ] 31 | } 32 | 33 | -------------------------------------------------------------------------------- /test/fixtures/mig/autoscaler/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/mig/autoscaler/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | value = var.project_id 20 | } 21 | 22 | output "region" { 23 | description = "The GCP region to create and test resources in" 24 | value = module.mig_autoscaler.region 25 | } 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/fixtures/mig/autoscaler/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/fixtures/mig/autoscaler/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/mig/healthcheck/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "mig_healthcheck" { 18 | source = "../../../../examples/mig/healthcheck" 19 | project_id = var.project_id 20 | service_account = var.service_account 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/mig/healthcheck/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | value = var.project_id 20 | } 21 | 22 | output "region" { 23 | description = "The GCP region to create and test resources in" 24 | value = module.mig_healthcheck.region 25 | } 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/fixtures/mig/healthcheck/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/mig/healthcheck/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/mig/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "mig_simple" { 18 | source = "../../../../examples/mig/simple" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | target_size = 4 22 | service_account = var.service_account 23 | } 24 | 25 | -------------------------------------------------------------------------------- /test/fixtures/mig/simple/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/mig/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "mig_self_link" { 18 | description = "Self-link to managed instance group" 19 | value = module.mig_simple.self_link 20 | } 21 | 22 | output "project_id" { 23 | description = "The GCP project to use for integration tests" 24 | value = var.project_id 25 | } 26 | 27 | output "region" { 28 | description = "The GCP region to create and test resources in" 29 | value = module.mig_simple.region 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/mig/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | 22 | 23 | variable "service_account" { 24 | default = null 25 | type = object({ 26 | email = string 27 | scopes = list(string) 28 | }) 29 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/mig/simple/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/mig_stateful/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "mig_stateful" { 18 | source = "../../../examples/mig_stateful" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | target_size = 3 23 | service_account = var.service_account 24 | } 25 | -------------------------------------------------------------------------------- /test/fixtures/mig_stateful/network.tf: -------------------------------------------------------------------------------- 1 | ../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/mig_stateful/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "mig_self_link" { 18 | description = "Self-link to managed instance group" 19 | value = module.mig_stateful.self_link 20 | } 21 | 22 | output "project_id" { 23 | description = "The GCP project to use for integration tests" 24 | value = var.project_id 25 | } 26 | 27 | output "region" { 28 | description = "The GCP region to create and test resources in" 29 | value = module.mig_stateful.region 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/mig_stateful/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | variable "project_id" { 20 | description = "The GCP project to use for integration tests" 21 | } 22 | 23 | variable "service_account" { 24 | default = null 25 | type = object({ 26 | email = string 27 | scopes = list(string) 28 | }) 29 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/mig_stateful/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/mig_with_percent/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "mig_with_percent_simple" { 18 | source = "../../../../examples/mig_with_percent/simple" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | service_account = var.service_account 22 | } 23 | -------------------------------------------------------------------------------- /test/fixtures/mig_with_percent/simple/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/mig_with_percent/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_link" { 18 | description = "Self-link of the managed instance group" 19 | value = module.mig_with_percent_simple.self_link 20 | } 21 | 22 | output "project_id" { 23 | description = "The GCP project to use for integration tests" 24 | value = var.project_id 25 | } 26 | 27 | output "region" { 28 | description = "The GCP region to create and test resources in" 29 | value = module.mig_with_percent_simple.region 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/fixtures/mig_with_percent/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | 22 | 23 | variable "service_account" { 24 | default = null 25 | type = object({ 26 | email = string 27 | scopes = list(string) 28 | }) 29 | description = "Service account email address and scopes" 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/mig_with_percent/simple/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "preemptible_and_regular_instance_templates" { 18 | source = "../../../../examples/preemptible_and_regular_instance_templates/simple" 19 | project_id = var.project_id 20 | subnetwork = google_compute_subnetwork.main.self_link 21 | service_account = var.service_account 22 | tags = ["foo", "bar"] 23 | 24 | labels = { 25 | environment = "dev" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/fixtures/preemptible_and_regular_instance_templates/simple/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/preemptible_and_regular_instance_templates/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "preemptible_self_link" { 18 | description = "Self-link to the preemptible instance template" 19 | value = module.preemptible_and_regular_instance_templates.preemptible_self_link 20 | } 21 | 22 | output "regular_self_link" { 23 | description = "Self-link to the regular instance template" 24 | value = module.preemptible_and_regular_instance_templates.regular_self_link 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/fixtures/preemptible_and_regular_instance_templates/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | 22 | 23 | variable "service_account" { 24 | default = null 25 | type = object({ 26 | email = string 27 | scopes = list(string) 28 | }) 29 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/preemptible_and_regular_instance_templates/simple/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/shared/network.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | resource "random_string" "suffix" { 18 | length = 4 19 | special = "false" 20 | upper = "false" 21 | } 22 | 23 | resource "google_compute_network" "main" { 24 | project = var.project_id 25 | name = "cft-vm-test-${random_string.suffix.result}" 26 | auto_create_subnetworks = "false" 27 | } 28 | 29 | resource "google_compute_subnetwork" "main" { 30 | project = var.project_id 31 | region = "us-central1" 32 | name = "cft-vm-test-${random_string.suffix.result}" 33 | ip_cidr_range = "10.128.0.0/20" 34 | network = google_compute_network.main.self_link 35 | } 36 | -------------------------------------------------------------------------------- /test/fixtures/shared/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/umig/named_ports/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "umig_named_ports" { 18 | source = "../../../../examples/umig/named_ports" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | num_instances = 4 23 | service_account = var.service_account 24 | 25 | named_ports = [ 26 | { 27 | name = "https" 28 | port = "443" 29 | }, 30 | { 31 | name = "http" 32 | port = "80" 33 | }, 34 | ] 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/umig/named_ports/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/umig/named_ports/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links to unmanaged instance groups" 19 | value = module.umig_named_ports.self_links 20 | } 21 | 22 | output "instances_self_links" { 23 | description = "List of instance self-links" 24 | value = module.umig_named_ports.instances_self_links 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/umig/named_ports/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/fixtures/umig/named_ports/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/umig/simple/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "umig_simple" { 18 | source = "../../../../examples/umig/simple" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | num_instances = 4 23 | service_account = var.service_account 24 | } 25 | 26 | -------------------------------------------------------------------------------- /test/fixtures/umig/simple/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/umig/simple/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links to unmanaged instance groups" 19 | value = module.umig_simple.self_links 20 | } 21 | 22 | output "instances_self_links" { 23 | description = "List of instance self-links" 24 | value = module.umig_simple.instances_self_links 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/umig/simple/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/umig/simple/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/umig/static_ips/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "umig_static_ips" { 18 | source = "../../../../examples/umig/static_ips" 19 | project_id = var.project_id 20 | region = "us-central1" 21 | subnetwork = google_compute_subnetwork.main.self_link 22 | 23 | static_ips = [ 24 | "10.128.0.10", 25 | "10.128.0.11", 26 | "10.128.0.12", 27 | "10.128.0.13", 28 | ] 29 | 30 | service_account = var.service_account 31 | } 32 | 33 | -------------------------------------------------------------------------------- /test/fixtures/umig/static_ips/network.tf: -------------------------------------------------------------------------------- 1 | ../../shared/network.tf -------------------------------------------------------------------------------- /test/fixtures/umig/static_ips/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "self_links" { 18 | description = "List of self-links to unmanaged instance groups" 19 | value = module.umig_static_ips.self_links 20 | } 21 | 22 | output "instances_self_links" { 23 | description = "List of instance self-links" 24 | value = module.umig_static_ips.instances_self_links 25 | } 26 | 27 | output "project_id" { 28 | description = "The GCP project to use for integration tests" 29 | value = var.project_id 30 | } 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/umig/static_ips/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | variable "project_id" { 18 | description = "The GCP project to use for integration tests" 19 | } 20 | 21 | variable "service_account" { 22 | default = null 23 | type = object({ 24 | email = string 25 | scopes = list(string) 26 | }) 27 | description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/fixtures/umig/static_ips/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">=0.12.6" 19 | } 20 | -------------------------------------------------------------------------------- /test/integration/discover_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package test 16 | 17 | import ( 18 | // should be imported to enable testing for GO modules 19 | "testing" 20 | 21 | // should be imported to use terraform helpers in blueprints test framework 22 | "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" 23 | ) 24 | 25 | // entry function for the test; can be named as Test* 26 | func TestAll(t *testing.T) { 27 | // the helper to autodiscover and test blueprint examples 28 | tft.AutoDiscoverAndTest(t) 29 | } 30 | -------------------------------------------------------------------------------- /test/integration/disk_snapshot/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: disk_snapshot 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/instance_simple_zone/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: instance_simple_zone 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/it_additional_disks/controls/it_additional_disks.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | project_id = attribute('project_id') 16 | 17 | expected_templates = 1 18 | expected_disks = 4 19 | 20 | control "Instance Template" do 21 | title "With additional disks" 22 | 23 | describe command("gcloud --project=#{project_id} compute instance-templates list --format=json --filter='name~^additional-disks*'") do 24 | its(:exit_status) { should eq 0 } 25 | its(:stderr) { should eq '' } 26 | 27 | let!(:data) do 28 | if subject.exit_status == 0 29 | JSON.parse(subject.stdout) 30 | else 31 | [] 32 | end 33 | end 34 | 35 | describe "number of templates" do 36 | it "should be #{expected_templates}" do 37 | expect(data.length).to eq(expected_templates) 38 | end 39 | end 40 | 41 | describe "number of disks" do 42 | it "should be #{expected_disks}" do 43 | expect(data[0]['properties']['disks'].length).to eq(expected_disks) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /test/integration/it_additional_disks/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: it_additional_disks 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/it_alias_ip_range/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: it_alias_ip_range 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | - name: subnetwork_name 22 | required: true 23 | type: string 24 | -------------------------------------------------------------------------------- /test/integration/it_simple/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: it_simple 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/mig_autoscaler/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: mig_autoscaler 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | - name: region 22 | required: true 23 | type: string 24 | -------------------------------------------------------------------------------- /test/integration/mig_healthcheck/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: mig_healthcheck 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | - name: region 22 | required: true 23 | type: string 24 | -------------------------------------------------------------------------------- /test/integration/mig_simple/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: mig_simple 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | - name: region 22 | required: true 23 | type: string 24 | -------------------------------------------------------------------------------- /test/integration/mig_with_percent_simple/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: mig_with_percent_simple 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | - name: region 22 | required: true 23 | type: string 24 | -------------------------------------------------------------------------------- /test/integration/preemptible_and_regular_instance_templates_simple/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: preemptible_and_regular_instance_templates_simple 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/umig_named_ports/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: umig_named_ports 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/umig_simple/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: umig_simple 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/integration/umig_static_ips/inspec.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | name: umig_static_ips 17 | attributes: 18 | - name: project_id 19 | required: true 20 | type: string 21 | -------------------------------------------------------------------------------- /test/setup/.gitignore: -------------------------------------------------------------------------------- 1 | terraform.tfvars 2 | source.sh 3 | -------------------------------------------------------------------------------- /test/setup/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module "project_ci_vm" { 18 | source = "terraform-google-modules/project-factory/google" 19 | version = "~> 17.0" 20 | 21 | name = "ci-vm-module" 22 | random_project_id = true 23 | org_id = var.org_id 24 | folder_id = var.folder_id 25 | billing_account = var.billing_account 26 | 27 | activate_apis = [ 28 | "cloudresourcemanager.googleapis.com", 29 | "storage-api.googleapis.com", 30 | "serviceusage.googleapis.com", 31 | "compute.googleapis.com", 32 | "iam.googleapis.com", 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /test/setup/outputs.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | output "project_id" { 18 | value = module.project_ci_vm.project_id 19 | } 20 | 21 | output "sa_key" { 22 | value = google_service_account_key.ci_vm_account.private_key 23 | sensitive = true 24 | } 25 | 26 | output "service_account" { 27 | value = { 28 | email = google_service_account.ci_vm_account.email 29 | scopes = ["cloud-platform"] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/setup/variables.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | variable "org_id" { 17 | description = "The numeric organization id" 18 | } 19 | 20 | variable "folder_id" { 21 | description = "The folder to deploy in" 22 | } 23 | 24 | variable "billing_account" { 25 | description = "The billing account id associated with the project, e.g. XXXXXX-YYYYYY-ZZZZZZ" 26 | } 27 | -------------------------------------------------------------------------------- /test/setup/versions.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | terraform { 18 | required_version = ">= 0.13" 19 | required_providers { 20 | google = { 21 | source = "hashicorp/google" 22 | version = ">= 3.71, < 7" 23 | } 24 | google-beta = { 25 | source = "hashicorp/google-beta" 26 | version = ">= 3.71, < 7" 27 | } 28 | null = { 29 | source = "hashicorp/null" 30 | version = "~> 3.0" 31 | } 32 | random = { 33 | source = "hashicorp/random" 34 | version = "~> 3.4" 35 | } 36 | } 37 | } 38 | --------------------------------------------------------------------------------