Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multiple alias IP ranges for compute instance. #2029

Merged
merged 2 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion google/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func resourceComputeInstance() *schema.Resource {

"alias_ip_range": &schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down
198 changes: 106 additions & 92 deletions google/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ resource "google_compute_instance" "foobar" {
labels {
my_key = "my_value"
my_other_key = "my_other_value"
}
}
}
`, instance)
}
Expand Down Expand Up @@ -2788,83 +2788,83 @@ data "google_compute_image" "my_image" {
}

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
network = "default"
}

scheduling {
# Instances with guest accelerators do not support live migration.
on_host_maintenance = "TERMINATE"
}

guest_accelerator {
count = %d
type = "nvidia-tesla-k80"
}
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
network = "default"
}

scheduling {
# Instances with guest accelerators do not support live migration.
on_host_maintenance = "TERMINATE"
}

guest_accelerator {
count = %d
type = "nvidia-tesla-k80"
}
}`, instance, count)
}

func testAccComputeInstance_minCpuPlatform(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}
boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
network = "default"
}
network_interface {
network = "default"
}

min_cpu_platform = "Intel Haswell"
min_cpu_platform = "Intel Haswell"
}`, instance)
}

func testAccComputeInstance_primaryAliasIpRange(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
network = "default"

alias_ip_range {
ip_cidr_range = "/24"
}
}
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
network = "default"

alias_ip_range {
ip_cidr_range = "/24"
}
}
}`, instance)
}

Expand All @@ -2887,26 +2887,37 @@ resource "google_compute_subnetwork" "inst-test-subnetwork" {
range_name = "inst-test-secondary"
ip_cidr_range = "172.16.0.0/20"
}
secondary_ip_range {
range_name = "inst-test-tertiary"
ip_cidr_range = "10.1.0.0/16"
}
}
resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
subnetwork = "${google_compute_subnetwork.inst-test-subnetwork.self_link}"

alias_ip_range {
subnetwork_range_name = "${google_compute_subnetwork.inst-test-subnetwork.secondary_ip_range.0.range_name}"
ip_cidr_range = "172.16.0.0/24"
}
}
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
subnetwork = "${google_compute_subnetwork.inst-test-subnetwork.self_link}"

alias_ip_range = [
{
subnetwork_range_name = "${google_compute_subnetwork.inst-test-subnetwork.secondary_ip_range.0.range_name}"
ip_cidr_range = "172.16.0.0/24"
},
{
subnetwork_range_name = "${google_compute_subnetwork.inst-test-subnetwork.secondary_ip_range.1.range_name}"
ip_cidr_range = "10.1.0.0/20"
}
]

}
}`, network, subnet, instance)
}

Expand All @@ -2929,25 +2940,28 @@ resource "google_compute_subnetwork" "inst-test-subnetwork" {
range_name = "inst-test-secondary"
ip_cidr_range = "172.16.0.0/20"
}
secondary_ip_range {
range_name = "inst-test-tertiary"
ip_cidr_range = "10.1.0.0/16"
}
}
resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
subnetwork = "${google_compute_subnetwork.inst-test-subnetwork.self_link}"

alias_ip_range {
ip_cidr_range = "10.0.1.0/24"
}
}
name = "%s"
machine_type = "n1-standard-1"
zone = "us-east1-d"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
subnetwork = "${google_compute_subnetwork.inst-test-subnetwork.self_link}"
alias_ip_range {
ip_cidr_range = "10.0.1.0/24"
}
}
}`, network, subnet, instance)
}

Expand Down