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

Update Network Connectivity Spoke Router and VPN Tunnels #12519

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 9 additions & 1 deletion mmv1/products/networkconnectivity/Spoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ properties:
- linked_router_appliance_instances
- linked_vpc_network
- linked_producer_vpc_network
update_mask_fields:
- 'linkedVpnTunnels.includeImportRanges'
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
properties:
- name: 'uris'
type: Array
Expand Down Expand Up @@ -160,6 +162,8 @@ properties:
- linked_router_appliance_instances
- linked_vpc_network
- linked_producer_vpc_network
update_mask_fields:
- 'linkedInterconnectAttachments.includeImportRanges'
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
properties:
- name: 'uris'
type: Array
Expand All @@ -183,12 +187,14 @@ properties:
- name: 'linkedRouterApplianceInstances'
type: NestedObject
description: The URIs of linked Router appliance resources
immutable: true
conflicts:
- linked_interconnect_attachments
- linked_vpn_tunnels
- linked_vpc_network
- linked_producer_vpc_network
update_mask_fields:
- 'linkedRouterApplianceInstances.instances'
- 'linkedRouterApplianceInstances.includeImportRanges'
properties:
- name: 'instances'
type: Array
Expand All @@ -203,11 +209,13 @@ properties:
type: String
description: The URI of the virtual machine resource
immutable: true
required: true
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
- name: 'ipAddress'
type: String
description: The IP address on the VM to use for peering.
immutable: true
required: true
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
- name: 'siteToSiteDataTransfer'
type: Boolean
description: A value that controls whether site-to-site data transfer is enabled for these resources. Note that data transfer is available only in supported locations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ func TestAccNetworkConnectivitySpoke_RouterApplianceHandWritten(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
{
Config: testAccNetworkConnectivitySpoke_RouterApplianceHandWrittenUpdate1(context),
},
{
ResourceName: "google_network_connectivity_spoke.primary",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
},
})
}
Expand Down Expand Up @@ -148,6 +157,15 @@ func TestAccNetworkConnectivitySpoke_RouterApplianceHandWrittenLongForm(t *testi
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
{
Config: testAccNetworkConnectivitySpoke_RouterApplianceHandWrittenUpdate1LongForm(context),
},
{
ResourceName: "google_network_connectivity_spoke.primary",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
},
})
}
Expand Down Expand Up @@ -244,8 +262,8 @@ resource "google_compute_subnetwork" "subnetwork" {
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "instance" {
name = "tf-test-instance%{random_suffix}"
resource "google_compute_instance" "router-instance1" {
name = "tf-test-router-instance1%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"
Expand Down Expand Up @@ -276,14 +294,14 @@ resource "google_network_connectivity_hub" "basic_hub" {
resource "google_network_connectivity_spoke" "primary" {
name = "tf-test-name%{random_suffix}"
location = "%{region}"
description = "A sample spoke with a linked routher appliance instance"
description = "A sample spoke with a single linked routher appliance instance"
labels = {
label-one = "value-one"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.instance.self_link
virtual_machine = google_compute_instance.router-instance1.self_link
ip_address = "10.0.0.2"
}
site_to_site_data_transfer = true
Expand All @@ -307,8 +325,8 @@ resource "google_compute_subnetwork" "subnetwork" {
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "instance" {
name = "tf-test-instance%{random_suffix}"
resource "google_compute_instance" "router-instance1" {
name = "tf-test-router-instance1%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"
Expand Down Expand Up @@ -339,21 +357,111 @@ resource "google_network_connectivity_hub" "basic_hub" {
resource "google_network_connectivity_spoke" "primary" {
name = "tf-test-name%{random_suffix}"
location = "%{region}"
description = "An UPDATED sample spoke with a linked routher appliance instance"
description = "An UPDATED sample spoke with a single linked routher appliance instance"
labels = {
label-two = "value-two"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.instance.self_link
virtual_machine = google_compute_instance.router-instance1.self_link
ip_address = "10.0.0.2"
}
site_to_site_data_transfer = true
}
}
`, context)
}

func testAccNetworkConnectivitySpoke_RouterApplianceHandWrittenUpdate1(context map[string]interface{}) string {
return acctest.Nprintf(`

resource "google_compute_network" "network" {
name = "tf-test-network%{random_suffix}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "subnetwork" {
name = "tf-test-subnet%{random_suffix}"
ip_cidr_range = "10.0.0.0/28"
region = "%{region}"
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "router-instance1" {
name = "tf-test-router-instance1%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"

boot_disk {
initialize_params {
image = "projects/debian-cloud/global/images/debian-10-buster-v20210817"
}
}

network_interface {
subnetwork = google_compute_subnetwork.subnetwork.name
network_ip = "10.0.0.2"
access_config {
network_tier = "PREMIUM"
}
}
}

resource "google_compute_instance" "router-instance2" {
name = "tf-test-router-instance2%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"

boot_disk {
initialize_params {
image = "projects/debian-cloud/global/images/debian-10-buster-v20210817"
}
}

network_interface {
subnetwork = google_compute_subnetwork.subnetwork.name
network_ip = "10.0.0.3"
access_config {
network_tier = "PREMIUM"
}
}
}

resource "google_network_connectivity_hub" "basic_hub" {
name = "tf-test-hub%{random_suffix}"
description = "A sample hub"
labels = {
label-two = "value-one"
}
}

resource "google_network_connectivity_spoke" "primary" {
name = "tf-test-name%{random_suffix}"
location = "%{region}"
description = "An UPDATED sample spoke with two linked routher appliance instances"
labels = {
label-two = "value-two"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.router-instance1.self_link
ip_address = "10.0.0.2"
}
instances {
virtual_machine = google_compute_instance.router-instance2.self_link
ip_address = "10.0.0.3"
}
include_import_ranges = ["ALL_IPV4_RANGES"]
site_to_site_data_transfer = true
}
}
`, context)
}

func testAccNetworkConnectivitySpoke_LinkedVPCNetworkHandWrittenLongForm(context map[string]interface{}) string {
return acctest.Nprintf(`

Expand Down Expand Up @@ -447,8 +555,8 @@ resource "google_compute_subnetwork" "subnetwork" {
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "instance" {
name = "tf-test-instance%{random_suffix}"
resource "google_compute_instance" "router-instance1" {
name = "tf-test-router-instance1%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"
Expand Down Expand Up @@ -479,14 +587,14 @@ resource "google_network_connectivity_hub" "basic_hub" {
resource "google_network_connectivity_spoke" "primary" {
name = "tf-test-name%{random_suffix}"
location = "%{region}"
description = "A sample spoke with a linked routher appliance instance"
description = "A sample spoke with a single linked routher appliance instance"
labels = {
label-one = "value-one"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.instance.self_link
virtual_machine = google_compute_instance.router-instance1.self_link
ip_address = "10.0.0.2"
}
site_to_site_data_transfer = true
Expand All @@ -510,8 +618,8 @@ resource "google_compute_subnetwork" "subnetwork" {
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "instance" {
name = "tf-test-instance%{random_suffix}"
resource "google_compute_instance" "router-instance1" {
name = "tf-test-router-instance1%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"
Expand Down Expand Up @@ -542,18 +650,107 @@ resource "google_network_connectivity_hub" "basic_hub" {
resource "google_network_connectivity_spoke" "primary" {
name = "tf-test-name%{random_suffix}"
location = "%{region}"
description = "An UPDATED sample spoke with a linked routher appliance instance"
description = "An UPDATED sample spoke with a single linked routher appliance instance"
labels = {
label-two = "value-two"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.instance.self_link
virtual_machine = google_compute_instance.router-instance1.self_link
ip_address = "10.0.0.2"
}
site_to_site_data_transfer = true
}
}
`, context)
}

func testAccNetworkConnectivitySpoke_RouterApplianceHandWrittenUpdate1LongForm(context map[string]interface{}) string {
return acctest.Nprintf(`

resource "google_compute_network" "network" {
name = "tf-test-network%{random_suffix}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "subnetwork" {
name = "tf-test-subnet%{random_suffix}"
ip_cidr_range = "10.0.0.0/28"
region = "%{region}"
network = google_compute_network.network.self_link
}

resource "google_compute_instance" "router-instance1" {
name = "tf-test-router-instance1%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"

boot_disk {
initialize_params {
image = "projects/debian-cloud/global/images/debian-10-buster-v20210817"
}
}

network_interface {
subnetwork = google_compute_subnetwork.subnetwork.name
network_ip = "10.0.0.2"
access_config {
network_tier = "PREMIUM"
}
}
}

resource "google_compute_instance" "router-instance2" {
name = "tf-test-router-instance2%{random_suffix}"
machine_type = "e2-medium"
can_ip_forward = true
zone = "%{zone}"

boot_disk {
initialize_params {
image = "projects/debian-cloud/global/images/debian-10-buster-v20210817"
}
}

network_interface {
subnetwork = google_compute_subnetwork.subnetwork.name
network_ip = "10.0.0.3"
access_config {
network_tier = "PREMIUM"
}
}
}

resource "google_network_connectivity_hub" "basic_hub" {
name = "tf-test-hub%{random_suffix}"
description = "A sample hub"
labels = {
label-two = "value-one"
}
}

resource "google_network_connectivity_spoke" "primary" {
name = "tf-test-name%{random_suffix}"
location = "%{region}"
description = "An UPDATED sample spoke with two linked routher appliance instances"
labels = {
label-two = "value-two"
}
hub = google_network_connectivity_hub.basic_hub.id
linked_router_appliance_instances {
instances {
virtual_machine = google_compute_instance.router-instance1.self_link
ip_address = "10.0.0.2"
}
instances {
virtual_machine = google_compute_instance.router-instance2.self_link
ip_address = "10.0.0.3"
}
include_import_ranges = ["ALL_IPV4_RANGES"]
site_to_site_data_transfer = true
}
}
`, context)
}
Loading