From f97a4071ced71a577718673bc4968011c36f967c Mon Sep 17 00:00:00 2001 From: Vivian Cox Date: Mon, 16 Dec 2024 12:26:51 -0800 Subject: [PATCH 1/3] Add edgenetwork InterconnectAttachment resource. --- .../edgenetwork/InterconnectAttachment.yaml | 135 ++++++++++++++++++ ...dgenetwork_interconnect_attachment.tf.tmpl | 23 +++ 2 files changed, 158 insertions(+) create mode 100644 mmv1/products/edgenetwork/InterconnectAttachment.yaml create mode 100644 mmv1/templates/terraform/examples/edgenetwork_interconnect_attachment.tf.tmpl diff --git a/mmv1/products/edgenetwork/InterconnectAttachment.yaml b/mmv1/products/edgenetwork/InterconnectAttachment.yaml new file mode 100644 index 000000000000..14f58d8b61d5 --- /dev/null +++ b/mmv1/products/edgenetwork/InterconnectAttachment.yaml @@ -0,0 +1,135 @@ +# Copyright 2024 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +name: 'InterconnectAttachment' +description: | + A Distributed Cloud Edge interconnect attachment, which connects routers to the northbound network. +references: + guides: + 'Create and manage interconnect attachments': 'https://cloud.google.com/distributed-cloud/edge/latest/docs/attachments#api' + api: 'https://cloud.google.com/distributed-cloud/edge/latest/docs/reference/network/rest/v1/projects.locations.zones.interconnectAttachments' +docs: +base_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/interconnectAttachments' +self_link: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/interconnectAttachments/{{interconnect_attachment_id}}' +create_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/interconnectAttachments?interconnectAttachmentId={{interconnect_attachment_id}}' +immutable: true +import_format: + - 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/interconnectAttachment/{{interconnect_attachment_id}}' + - '{{name}}' +timeouts: + insert_minutes: 20 + update_minutes: 20 + delete_minutes: 30 +autogen_async: true +async: + actions: ['create', 'delete', 'update'] + type: 'OpAsync' + operation: + base_url: '{{op_id}}' + path: 'name' + wait_ms: 1000 + result: + path: 'response' + resource_inside_response: false + error: + path: 'error' + message: 'message' +examples: + - name: 'edgenetwork_interconnect_attachment' + primary_resource_id: 'example_interconnect_attachment' + vars: + edgenetwork_interconnect_attachment_id: 'example-interconnect-attachment' + edgenetwork_network_id: 'example-network' + test_env_vars: + location: 'REGION' + zone: 'ZONE' + exclude_test: true +parameters: + - name: 'location' + type: String + description: | + The Google Cloud region to which the target Distributed Cloud Edge zone belongs. + url_param_only: true + required: true + immutable: true + - name: 'zone' + type: String + description: | + The name of the target Distributed Cloud Edge zone. + url_param_only: true + required: true + immutable: true + - name: 'interconnect_attachment_id' + type: String + description: | + A unique ID that identifies this interconnect attachment. + url_param_only: true + required: true + immutable: true +properties: + - name: 'name' + type: String + description: | + The canonical name of this resource, with format + `projects/{{project}}/locations/{{location}}/zones/{{zone}}/interconnectAttachments/{{interconnect_attachment_id}}` + output: true + - name: 'labels' + type: KeyValueLabels + description: | + Labels associated with this resource. + required: false + - name: 'description' + type: String + description: | + A free-text description of the resource. Max length 1024 characters. + required: false + - name: 'createTime' + type: String + description: | + The time when the resource was created. + A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine + fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`. + output: true + - name: 'updateTime' + type: String + description: | + The time when the resource was last updated. + A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine + fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`. + output: true + - name: 'interconnect' + type: String + description: | + The ID of the underlying interconnect that this attachment's traffic will traverse through. + required: true + - name: 'network' + type: ResourceRef + description: | + The ID of the network to which this interconnect attachment belongs. + Must be of the form: `projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}` + required: true + custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl' + resource: 'Network' + imports: 'name' + - name: 'vlanId' + type: Integer + description: | + VLAN ID provided by user. Must be site-wise unique. + required: true + - name: 'mtu' + type: Integer + description: | + IP (L3) MTU value of the virtual edge cloud. Default value is `1500`. Possible values are: `1500`, `9000`. + default_value: 1500 + diff --git a/mmv1/templates/terraform/examples/edgenetwork_interconnect_attachment.tf.tmpl b/mmv1/templates/terraform/examples/edgenetwork_interconnect_attachment.tf.tmpl new file mode 100644 index 000000000000..fc3147dc74eb --- /dev/null +++ b/mmv1/templates/terraform/examples/edgenetwork_interconnect_attachment.tf.tmpl @@ -0,0 +1,23 @@ + +resource "google_edgenetwork_interconnect_attachment" "{{$.PrimaryResourceId}}" { + interconnect_attachment_id = "{{index $.Vars "edgenetwork_interconnect_attachment_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example interconnect attachment." + network = google_edgenetwork_network.example_network.id + interconnect = "11111111-2222-3333-4444-555555555555" + vlan_id = 55 + mtu = 9000 + labels = { + "environment" : "dev" + } +} + +resource "google_edgenetwork_network" "example_network" { + network_id = "{{index $.Vars "edgenetwork_network_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example network." + mtu = 9000 +} + From c504786849c9fb9afdcd031761a46927e89694b0 Mon Sep 17 00:00:00 2001 From: Vivian Cox Date: Mon, 16 Dec 2024 12:36:41 -0800 Subject: [PATCH 2/3] Fix yaml lint for InterconnectAttachment.yaml --- mmv1/products/edgenetwork/InterconnectAttachment.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/edgenetwork/InterconnectAttachment.yaml b/mmv1/products/edgenetwork/InterconnectAttachment.yaml index 14f58d8b61d5..20662e23e578 100644 --- a/mmv1/products/edgenetwork/InterconnectAttachment.yaml +++ b/mmv1/products/edgenetwork/InterconnectAttachment.yaml @@ -132,4 +132,3 @@ properties: description: | IP (L3) MTU value of the virtual edge cloud. Default value is `1500`. Possible values are: `1500`, `9000`. default_value: 1500 - From db4066461d03d9db791d4d0dcded255bbd278b42 Mon Sep 17 00:00:00 2001 From: Vivian Cox Date: Tue, 17 Dec 2024 08:26:41 -0800 Subject: [PATCH 3/3] Add edgenetwork Router resource --- mmv1/products/edgenetwork/Router.yaml | 227 ++++++++++++++++++ .../edgenetwork_router_minimal.tf.tmpl | 23 ++ .../edgenetwork_router_with_bgp.tf.tmpl | 82 +++++++ 3 files changed, 332 insertions(+) create mode 100644 mmv1/products/edgenetwork/Router.yaml create mode 100644 mmv1/templates/terraform/examples/edgenetwork_router_minimal.tf.tmpl create mode 100644 mmv1/templates/terraform/examples/edgenetwork_router_with_bgp.tf.tmpl diff --git a/mmv1/products/edgenetwork/Router.yaml b/mmv1/products/edgenetwork/Router.yaml new file mode 100644 index 000000000000..14ba30f0ebc4 --- /dev/null +++ b/mmv1/products/edgenetwork/Router.yaml @@ -0,0 +1,227 @@ +# Copyright 2024 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +name: 'Router' +description: | + A Distributed Cloud Edge router, which encapsulates northbound layer-3 parameters for a zone. +references: + guides: + 'Create and manage routers': 'https://cloud.google.com/distributed-cloud/edge/latest/docs/routers#api' + api: 'https://cloud.google.com/distributed-cloud/edge/latest/docs/reference/network/rest/v1/projects.locations.zones.routers' +docs: +base_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/routers' +self_link: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/routers/{{router_id}}' +create_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/routers?routerId={{router_id}}' +update_verb: 'PATCH' +update_mask: true +import_format: + - 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/routers/{{router_id}}' + - '{{name}}' +timeouts: + insert_minutes: 20 + update_minutes: 20 + delete_minutes: 30 +autogen_async: true +async: + actions: ['create', 'delete', 'update'] + type: 'OpAsync' + operation: + base_url: '{{op_id}}' + path: 'name' + wait_ms: 1000 + result: + path: 'response' + resource_inside_response: false + error: + path: 'error' + message: 'message' +examples: + - name: 'edgenetwork_router_minimal' + primary_resource_id: 'example_router' + vars: + edgenetwork_router_id: 'example-router' + edgenetwork_network_id: 'example-network' + test_env_vars: + location: 'REGION' + zone: 'ZONE' + exclude_test: true + - name: 'edgenetwork_router_with_bgp' + primary_resource_id: 'example_router' + vars: + edgenetwork_router_id: 'example-router' + edgenetwork_interconnect_attachment_id: 'example-interconnect-attachment' + edgenetwork_network_id: 'example-network' + edgenetwork_subnet_id: 'example-subnet' + test_env_vars: + location: 'REGION' + zone: 'ZONE' + exclude_test: true +parameters: + - name: 'location' + type: String + description: | + The Google Cloud region to which the target Distributed Cloud Edge zone belongs. + url_param_only: true + required: true + immutable: true + - name: 'zone' + type: String + description: | + The name of the target Distributed Cloud Edge zone. + url_param_only: true + required: true + immutable: true + - name: 'router_id' + type: String + description: | + A unique ID that identifies this router. + url_param_only: true + required: true + immutable: true +properties: + - name: 'name' + type: String + description: | + The canonical name of this resource, with format + `projects/{{project}}/locations/{{location}}/zones/{{zone}}/routers/{{router_id}}` + output: true + - name: 'labels' + type: KeyValueLabels + description: | + Labels associated with this resource. + required: false + - name: 'description' + type: String + description: | + A free-text description of the resource. Max length 1024 characters. + required: false + - name: 'createTime' + type: String + description: | + The time when the resource was created. + A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine + fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`. + output: true + - name: 'updateTime' + type: String + description: | + The time when the resource was last updated. + A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine + fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`. + output: true + - name: 'network' + type: ResourceRef + description: | + The ID of the network to which this router belongs. + Must be of the form: `projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}` + required: true + custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl' + resource: 'Network' + imports: 'name' + - name: 'interface' + type: Array + description: | + Router interfaces, defining the zone-side layer-3 information for building the BGP session. + item_type: + type: NestedObject + properties: + - name: 'name' + type: String + description: | + Name of this interface entry. Unique within the zone. + - name: 'ipv4Cidr' + type: String + description: | + IPv4 address and range of the interface. + - name: 'ipv6Cidr' + type: String + description: | + IPv6 address and range of the interface. + - name: 'linkedInterconnectAttachment' + type: ResourceRef + description: | + The ID of the linked interconnect attachment. + Must be of the form: `projects/{{project}}/locations/{{location}}/zones/{{zone}}/interconnectAttachments/{{interconnect_attachment_id}}` + custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl' + resource: 'InterconnectAttachment' + imports: 'name' + - name: 'subnetwork' + type: ResourceRef + description: | + The ID of the subnetwork that this interface belongs to. + Must be of the form: `projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}` + custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl' + resource: 'Subnet' + imports: 'name' + - name: 'loopbackIpAddresses' + type: Array + description: | + Creates loopback interfaces in the router when specified. The number of IP addresses must match the number of TOR devices. + item_type: + type: String + - name: 'bgpPeer' + type: Array + description: | + BGP Peers, defining the peer-side layer-3 information for building the BGP session. + item_type: + type: NestedObject + properties: + - name: 'name' + type: String + description: | + Name of this BGP peer. Unique within the zone. + - name: 'interface' + type: String + description: | + Name of the interface entry that this peer is associated with. + - name: 'interfaceIpv4Cidr' + type: String + description: | + IPv4 range of the interface within Google. + - name: 'interfaceIpv6Cidr' + type: String + description: | + IPv6 range of the interface within Google. + - name: 'peerIpv4Cidr' + type: String + description: | + IPv4 range of the BGP interface outside Google. + - name: 'peerIpv6Cidr' + type: String + description: | + IPv6 range of the BGP interface outside Google. + - name: 'peerAsn' + type: Integer + description: | + Peer BGP autonomous system number (ASN). Each BGP interface may use a different value. + - name: 'bgp' + type: NestedObject + description: | + BGP information specific to this router. + properties: + - name: 'asn' + type: Integer + description: | + Locally assigned BGP ASN. + - name: 'keepaliveIntervalInSeconds' + type: Integer + description: | + The interval in seconds between BGP keepalive messages that are sent to the peer. Default value is `20`. Must be between `20` and `60`. + default_value: 20 + - name: 'routeAdvertisements' + type: Array + description: | + A list of CIDRs in IP/Length format to advertise northbound as static routes from this router. + item_type: + type: String diff --git a/mmv1/templates/terraform/examples/edgenetwork_router_minimal.tf.tmpl b/mmv1/templates/terraform/examples/edgenetwork_router_minimal.tf.tmpl new file mode 100644 index 000000000000..c9d27dd8d2fb --- /dev/null +++ b/mmv1/templates/terraform/examples/edgenetwork_router_minimal.tf.tmpl @@ -0,0 +1,23 @@ + +resource "google_edgenetwork_router" "{{$.PrimaryResourceId}}" { + router_id = "{{index $.Vars "edgenetwork_router_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example router." + network = google_edgenetwork_network.example_network.id + labels = { + "environment" : "dev" + } + bgp { + asn = 456 + } +} + +resource "google_edgenetwork_network" "example_network" { + network_id = "{{index $.Vars "edgenetwork_network_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example network." + mtu = 9000 +} + diff --git a/mmv1/templates/terraform/examples/edgenetwork_router_with_bgp.tf.tmpl b/mmv1/templates/terraform/examples/edgenetwork_router_with_bgp.tf.tmpl new file mode 100644 index 000000000000..e6c49606b6f4 --- /dev/null +++ b/mmv1/templates/terraform/examples/edgenetwork_router_with_bgp.tf.tmpl @@ -0,0 +1,82 @@ + +resource "google_edgenetwork_router" "{{$.PrimaryResourceId}}" { + router_id = "{{index $.Vars "edgenetwork_router_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example router." + network = google_edgenetwork_network.example_network.id + labels = { + "environment" : "dev" + } + interface { + name = "interface-ipv4" + ipv4_cidr = "1.1.1.1/24" + subnetwork = google_edgenetwork_subnet.example_subnet.id + linked_interconnect_attachment = google_edgenetwork_interconnect_attachment.example_interconnect_attachment.id + } + interface { + name = "interface-ipv6" + ipv6_cidr = "4444:4444:4444:4444::1/64" + subnetwork = google_edgenetwork_subnet.example_subnet.id + linked_interconnect_attachment = google_edgenetwork_interconnect_attachment.example_interconnect_attachment.id + } + interface { + name = "interface-loopback" + loopback_ip_addresses = ["2.2.2.2", "2.2.2.3"] + } + bgp_peer { + name = "peer-ipv4" + interface = "interface-ipv4" + interface_ipv4_cidr = "1.1.1.1/24" + peer_ipv4_cidr = "9.9.9.9/24" + peer_asn = 123 + } + bgp_peer { + name = "peer-ipv6" + interface = "interface-ipv6" + interface_ipv6_cidr = "4444:4444:4444:4444::1/64" + peer_ipv6_cidr = "8888:8888:8888:8888::1/64" + peer_asn = 789 + } + bgp { + asn = 456 + keepalive_interval_in_seconds = 40 + } + route_advertisements = ["3.3.3.3/24", "4.4.4.4/24"] +} + +resource "google_edgenetwork_interconnect_attachment" "example_interconnect_attachment" { + interconnect_attachment_id = "{{index $.Vars "edgenetwork_interconnect_attachment_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example interconnect attachment." + network = google_edgenetwork_network.example_network.id + interconnect = "11111111-2222-3333-4444-555555555555" + vlan_id = 55 + mtu = 9000 + labels = { + "environment" : "dev" + } +} + +resource "google_edgenetwork_subnet" "example_subnet" { + subnet_id = "{{index $.Vars "edgenetwork_subnet_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example subnet." + network = google_edgenetwork_network.example_network.id + ipv4_cidr = ["4.4.4.1/24"] + vlan_id = 55 + labels = { + "environment" : "dev" + } +} + +resource "google_edgenetwork_network" "example_network" { + network_id = "{{index $.Vars "edgenetwork_network_id"}}" + location = "{{index $.TestEnvVars "location"}}" + zone = "{{index $.TestEnvVars "zone"}}" + description = "Example network." + mtu = 9000 +} +