Skip to content

Commit 494b98d

Browse files
chore: Added snippet that creates a VM with the reserved IP address (#286)
* Added snippet that creates a VM with the reserved IP address * Updated info in README
1 parent bffd77d commit 494b98d

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

examples/basic_shared_vpc/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ This example:
55
* Enables shared VPC on a host project
66
* Attaches a service project
77
* Reserves an internal IP address in a subnet of a Shared VPC network
8+
* Creates a VM instance
89

9-
Note that the IP address configuration object is created in the service
10-
project, while its value comes from the range of available addresses in
11-
the chosen shared subnet.
10+
The IP address configuration object is created in the service
11+
project. Its value can come from the range of available addresses in
12+
the chosen shared subnet, or you can specify an address.
1213

1314

1415
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/basic_shared_vpc/main.tf

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ resource "google_compute_address" "internal" {
5555
}
5656
# [END compute_shared_internal_ip_create]
5757

58-
# [START compute_shared_instance_create]
59-
resource "google_compute_instance" "default" {
58+
# [START compute_shared_instance_with_reserved_ip_create]
59+
resource "google_compute_instance" "reserved_ip" {
6060
project = var.service_project
6161
zone = "us-central1-a"
6262
name = "my-vm"
@@ -68,6 +68,24 @@ resource "google_compute_instance" "default" {
6868
}
6969
network_interface {
7070
subnetwork = data.google_compute_subnetwork.subnet.self_link
71+
network_ip = "int-ip"
7172
}
7273
}
73-
# [END compute_shared_instance_create]
74+
# [END compute_shared_instance_with_reserved_ip_create]
75+
76+
# [START compute_shared_instance_with_ephemeral_ip_create]
77+
resource "google_compute_instance" "ephemeral_ip" {
78+
project = var.service_project
79+
zone = "us-central1-a"
80+
name = "my-vm"
81+
machine_type = "e2-medium"
82+
boot_disk {
83+
initialize_params {
84+
image = "debian-cloud/debian-9"
85+
}
86+
}
87+
network_interface {
88+
subnetwork = data.google_compute_subnetwork.subnet.self_link
89+
}
90+
}
91+
# [END compute_shared_instance_with_ephemeral_ip_create]

0 commit comments

Comments
 (0)