From aef29d4aee109af32f440e86c90c241d0e4a91b3 Mon Sep 17 00:00:00 2001 From: Aman Mahendroo <30946991+amanMahendroo@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:40:58 +0530 Subject: [PATCH] NCC Producer VPC Spoke resource added (#11934) --- mmv1/products/networkconnectivity/Spoke.yaml | 50 +++++++++++++++++++ ..._linked_producer_vpc_network_basic.tf.tmpl | 50 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 mmv1/templates/terraform/examples/network_connectivity_spoke_linked_producer_vpc_network_basic.tf.tmpl diff --git a/mmv1/products/networkconnectivity/Spoke.yaml b/mmv1/products/networkconnectivity/Spoke.yaml index 05152cff4ec2..f0e3df14e3d8 100644 --- a/mmv1/products/networkconnectivity/Spoke.yaml +++ b/mmv1/products/networkconnectivity/Spoke.yaml @@ -85,6 +85,14 @@ examples: router_name: 'external-vpn-gateway' interconnect_attachment_name: 'partner-interconnect1' interconnect_attachment_spoke_name: 'interconnect-attachment-spoke' + - name: 'network_connectivity_spoke_linked_producer_vpc_network_basic' + primary_resource_id: 'primary' + vars: + network_name: "net-spoke" + global_name: 'test-address' + hub_name: "hub-basic" + spoke_name: "vpc-spoke" + producer_spoke_name: "producer-spoke" parameters: - name: 'location' type: String @@ -128,6 +136,7 @@ properties: - linked_interconnect_attachments - linked_router_appliance_instances - linked_vpc_network + - linked_producer_vpc_network properties: - name: 'uris' type: Array @@ -156,6 +165,7 @@ properties: - linked_vpn_tunnels - linked_router_appliance_instances - linked_vpc_network + - linked_producer_vpc_network properties: - name: 'uris' type: Array @@ -184,6 +194,7 @@ properties: - linked_interconnect_attachments - linked_vpn_tunnels - linked_vpc_network + - linked_producer_vpc_network properties: - name: 'instances' type: Array @@ -223,6 +234,7 @@ properties: - linked_interconnect_attachments - linked_router_appliance_instances - linked_vpn_tunnels + - linked_producer_vpc_network properties: - name: 'uri' type: String @@ -242,6 +254,44 @@ properties: immutable: true item_type: type: String + - name: linkedProducerVpcNetwork + type: NestedObject + description: Producer VPC network that is associated with the spoke. + immutable: true + conflicts: + - linked_interconnect_attachments + - linked_router_appliance_instances + - linked_vpn_tunnels + - linked_vpc_network + properties: + - name: network + type: String + description: The URI of the Service Consumer VPC that the Producer VPC is peered with. + required: true + immutable: true + diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' + - name: peering + type: String + description: The name of the VPC peering between the Service Consumer VPC and the Producer VPC (defined in the Tenant project) which is added to the NCC hub. This peering must be in ACTIVE state. + required: true + immutable: true + - name: producerNetwork + type: String + description: The URI of the Producer VPC. + output: true + immutable: true + - name: includeExportRanges + type: Array + description: IP ranges allowed to be included from peering. + immutable: true + item_type: + type: String + - name: excludeExportRanges + type: Array + description: IP ranges encompassing the subnets to be excluded from peering. + immutable: true + item_type: + type: String - name: 'uniqueId' type: String description: Output only. The Google-generated UUID for the spoke. This value is unique across all spoke resources. If a spoke is deleted and another with the same name is created, the new spoke is assigned a different unique_id. diff --git a/mmv1/templates/terraform/examples/network_connectivity_spoke_linked_producer_vpc_network_basic.tf.tmpl b/mmv1/templates/terraform/examples/network_connectivity_spoke_linked_producer_vpc_network_basic.tf.tmpl new file mode 100644 index 000000000000..76375d534212 --- /dev/null +++ b/mmv1/templates/terraform/examples/network_connectivity_spoke_linked_producer_vpc_network_basic.tf.tmpl @@ -0,0 +1,50 @@ +resource "google_compute_network" "network" { + name = "{{index $.Vars "network_name"}}" + auto_create_subnetworks = false +} + +resource "google_compute_global_address" "address" { + name = "{{index $.Vars "global_name"}}" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.network.id +} + +resource "google_service_networking_connection" "peering" { + network = google_compute_network.network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.address.name] +} + +resource "google_network_connectivity_hub" "basic_hub" { + name = "{{index $.Vars "hub_name"}}" +} + +resource "google_network_connectivity_spoke" "linked_vpc_spoke" { + name = "{{index $.Vars "spoke_name"}}" + location = "global" + hub = google_network_connectivity_hub.basic_hub.id + linked_vpc_network { + uri = google_compute_network.network.self_link + } +} + +resource "google_network_connectivity_spoke" "primary" { + name = "{{index $.Vars "producer_spoke_name"}}" + location = "global" + description = "A sample spoke with a linked router appliance instance" + labels = { + label-one = "value-one" + } + hub = google_network_connectivity_hub.basic_hub.id + linked_producer_vpc_network { + network = google_compute_network.network.name + peering = google_service_networking_connection.peering.peering + exclude_export_ranges = [ + "198.51.100.0/24", + "10.10.0.0/16" + ] + } + depends_on = [google_network_connectivity_spoke.linked_vpc_spoke] +} \ No newline at end of file