From 5cd739f137165f3e67ec1e0ac31d201adc19b900 Mon Sep 17 00:00:00 2001 From: Sebastian Kaliszewski Date: Fri, 27 Sep 2024 13:52:19 +0000 Subject: [PATCH 1/3] Support FOR_MIGRATION InternalRange objects --- .../networkconnectivity/InternalRange.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mmv1/products/networkconnectivity/InternalRange.yaml b/mmv1/products/networkconnectivity/InternalRange.yaml index 232c7a1ac139..fde559401cee 100644 --- a/mmv1/products/networkconnectivity/InternalRange.yaml +++ b/mmv1/products/networkconnectivity/InternalRange.yaml @@ -108,6 +108,7 @@ properties: enum_values: - 'FOR_VPC' - 'EXTERNAL_TO_VPC' + - 'FOR_MIGRATION' - name: 'peering' type: Enum description: | @@ -149,3 +150,25 @@ properties: enum_values: - 'OVERLAP_ROUTE_RANGE' - 'OVERLAP_EXISTING_SUBNET_RANGE' + - name: 'migration' + type: NestedObject + description: | + Specification for migration with source and target resource names. + immutable: true + properties: + - name: 'source' + type: String + description: | + Resource path as an URI of the source resource, for example a subnet. + The project for the source resource should match the project for the + InternalRange. + An example /projects/{project}/regions/{region}/subnetworks/{subnet} + requred: true + - name: 'target' + type: String + description: | + Resource path of the target resource. The target project can be + different, as in the cases when migrating to peer networks. The resource + may not exist yet. + For example /projects/{project}/regions/{region}/subnetworks/{subnet} + required: true From 4abc4696f54cb05b24ca49a4172fa0af4a4e1e75 Mon Sep 17 00:00:00 2001 From: Sebastian Kaliszewski Date: Fri, 4 Oct 2024 10:59:16 +0000 Subject: [PATCH 2/3] Added an example of FOR_MIGRATION InternalRange config (also used in acceptance test). --- mmv1/products/networkconnectivity/InternalRange.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/InternalRange.yaml b/mmv1/products/networkconnectivity/InternalRange.yaml index fde559401cee..6b84faa36a5c 100644 --- a/mmv1/products/networkconnectivity/InternalRange.yaml +++ b/mmv1/products/networkconnectivity/InternalRange.yaml @@ -71,6 +71,12 @@ examples: vars: internal_range_name: 'overlap-range' network_name: 'internal-ranges' + - name: 'network_connectivity_internal_ranges_migration' + primary_resource_id: 'default' + vars: + internal_range_name: 'migration' + network_name: 'internal-ranges' + source_subnet_name: 'source-subnet' parameters: properties: - name: 'name' @@ -163,7 +169,7 @@ properties: The project for the source resource should match the project for the InternalRange. An example /projects/{project}/regions/{region}/subnetworks/{subnet} - requred: true + required: true - name: 'target' type: String description: | From 0a85baac02a841f7fad442bc99647d7ffd569276 Mon Sep 17 00:00:00 2001 From: Sebastian Kaliszewski Date: Fri, 4 Oct 2024 11:14:36 +0000 Subject: [PATCH 3/3] Template for the migration InternalRange test --- ...ectivity_internal_ranges_migration.tf.tmpl | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 mmv1/templates/terraform/examples/network_connectivity_internal_ranges_migration.tf.tmpl diff --git a/mmv1/templates/terraform/examples/network_connectivity_internal_ranges_migration.tf.tmpl b/mmv1/templates/terraform/examples/network_connectivity_internal_ranges_migration.tf.tmpl new file mode 100644 index 000000000000..0fc7820880b6 --- /dev/null +++ b/mmv1/templates/terraform/examples/network_connectivity_internal_ranges_migration.tf.tmpl @@ -0,0 +1,27 @@ +resource "google_network_connectivity_internal_range" "{{$.PrimaryResourceId}}" { + name = "{{index $.Vars "internal_range_name"}}" + description = "Test internal range" + network = google_compute_network.default.self_link + usage = "FOR_MIGRATION" + peering = "FOR_SELF" + ip_cidr_range = "10.1.0.0/16" + migration { + source = google_compute_subnetwork.source.self_link + target = "projects/${data.google_project.target_project.project_id}/regions/us-central1/subnetworks/target-subnet" + } +} + +resource "google_compute_network" "default" { + name = "{{index $.Vars "network_name"}}" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "source" { + name = "{{index $.Vars "source_subnet_name"}}" + ip_cidr_range = "10.1.0.0/16" + region = "us-central1" + network = google_compute_network.default.name +} + +data "google_project" "target_project" { +}