File tree Expand file tree Collapse file tree 5 files changed +137
-0
lines changed
examples/compute_instance/next_hop Expand file tree Collapse file tree 5 files changed +137
-0
lines changed Original file line number Diff line number Diff line change 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+ <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
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+ <!-- 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+ provider "google" {
18+
19+ version = " ~> 3.0"
20+ }
21+
22+ # [START compute_vm_as_next_hop_create]
23+ resource "google_compute_instance" "default" {
24+ project = var. project_id # Replace this with your project ID in quotes
25+ zone = " southamerica-east1-b"
26+ name = " instance-next-hop"
27+ machine_type = " e2-medium"
28+ boot_disk {
29+ initialize_params {
30+ image = " debian-cloud/debian-9"
31+ }
32+ }
33+ network_interface {
34+ network = " default"
35+ }
36+ can_ip_forward = true
37+ }
38+ # [END compute_vm_as_next_hop_create]
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 "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+ }
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+
18+
19+ variable "project_id" {
20+ description = " The Google Cloud project ID"
21+ type = string
22+ }
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