File tree Expand file tree Collapse file tree 5 files changed +157
-0
lines changed
examples/compute_instance/multiple_interfaces Expand file tree Collapse file tree 5 files changed +157
-0
lines changed Original file line number Diff line number Diff line change 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+ <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
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+ <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Original file line number Diff line number Diff line change 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_providers {
19+ google = {
20+ version = " >= 3.45.0"
21+ }
22+ null = {
23+ version = " >= 2.1.0"
24+ }
25+ }
26+ }
27+
28+ # [START compute_vm_with_multiple_interface]
29+ resource "google_compute_instance" "default" {
30+ project = var. project_id # Replace with your project ID in quotes
31+ zone = " us-central1-b"
32+ name = " backend-instance"
33+ machine_type = " e2-medium"
34+ boot_disk {
35+ initialize_params {
36+ image = " debian-cloud/debian-9"
37+ }
38+ }
39+ network_interface {
40+ subnetwork = var. subnet_1 # Replace with self link to a subnetwork in quotes
41+ network_ip = " 10.0.0.14"
42+ }
43+ network_interface {
44+ subnetwork = var. subnet_2 # Replace with self link to a subnetwork in quotes
45+ network_ip = " 10.10.20.14"
46+ }
47+ }
48+ # [END compute_vm_with_multiple_interface]
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments