Skip to content

Commit

Permalink
NCC Producer VPC Spoke resource added (GoogleCloudPlatform#11934)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanMahendroo authored Oct 10, 2024
1 parent 54e6e59 commit aef29d4
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
50 changes: 50 additions & 0 deletions mmv1/products/networkconnectivity/Spoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -128,6 +136,7 @@ properties:
- linked_interconnect_attachments
- linked_router_appliance_instances
- linked_vpc_network
- linked_producer_vpc_network
properties:
- name: 'uris'
type: Array
Expand Down Expand Up @@ -156,6 +165,7 @@ properties:
- linked_vpn_tunnels
- linked_router_appliance_instances
- linked_vpc_network
- linked_producer_vpc_network
properties:
- name: 'uris'
type: Array
Expand Down Expand Up @@ -184,6 +194,7 @@ properties:
- linked_interconnect_attachments
- linked_vpn_tunnels
- linked_vpc_network
- linked_producer_vpc_network
properties:
- name: 'instances'
type: Array
Expand Down Expand Up @@ -223,6 +234,7 @@ properties:
- linked_interconnect_attachments
- linked_router_appliance_instances
- linked_vpn_tunnels
- linked_producer_vpc_network
properties:
- name: 'uri'
type: String
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
}

0 comments on commit aef29d4

Please sign in to comment.