diff --git a/mmv1/products/networkconnectivity/RegionalEndpoint.yaml b/mmv1/products/networkconnectivity/RegionalEndpoint.yaml new file mode 100644 index 000000000000..9f0dd05125a2 --- /dev/null +++ b/mmv1/products/networkconnectivity/RegionalEndpoint.yaml @@ -0,0 +1,129 @@ +# 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. + +--- !ruby/object:Api::Resource +name: 'RegionalEndpoint' +description: | + Regional Private Service Connect (PSC) endpoint resource. +references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Access regional Google APIs through endpoints': 'https://cloud.google.com/vpc/docs/access-regional-google-apis-endpoints' + api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1/projects.locations.regionalEndpoints' +base_url: 'projects/{{project}}/locations/{{location}}/regionalEndpoints' +self_link: 'projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}' +immutable: true +create_url: 'projects/{{project}}/locations/{{location}}/regionalEndpoints?regional_endpoint_id={{name}}' +delete_url: 'projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}' +autogen_async: true +async: !ruby/object:Api::OpAsync + actions: ['create', 'delete'] + operation: !ruby/object:Api::OpAsync::Operation + base_url: '{{op_id}}' + result: !ruby/object:Api::OpAsync::Result + path: 'response' + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: true + allowed: + - true + - false + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + +examples: + - !ruby/object:Provider::Terraform::Examples + name: 'network_connectivity_regional_endpoint_regional_access' + primary_resource_id: 'default' + vars: + rep_name: 'my-rep' + rep_network: 'my-network' + rep_subnetwork: 'my-subnetwork' + - !ruby/object:Provider::Terraform::Examples + name: 'network_connectivity_regional_endpoint_global_access' + primary_resource_id: 'default' + vars: + rep_name: 'my-rep' + rep_network: 'my-network' + rep_subnetwork: 'my-subnetwork' + +parameters: + - !ruby/object:Api::Type::String + name: 'name' + required: true + immutable: true + url_param_only: true + description: | + The name of the RegionalEndpoint. + - !ruby/object:Api::Type::String + name: 'location' + required: true + immutable: true + url_param_only: true + description: | + The location of the RegionalEndpoint. + +properties: + - !ruby/object:Api::Type::Time + name: 'createTime' + output: true + description: | + Time when the RegionalEndpoint was created. + - !ruby/object:Api::Type::Time + name: 'updateTime' + output: true + description: | + Time when the RegionalEndpoint was updated. + - !ruby/object:Api::Type::KeyValueLabels + name: 'labels' + description: | + User-defined labels. + - !ruby/object:Api::Type::String + name: 'description' + description: | + A description of this resource. + - !ruby/object:Api::Type::String + name: 'targetGoogleApi' + required: true + description: | + The service endpoint this private regional endpoint connects to. Format: `{apiname}.{region}.p.rep.googleapis.com` Example: \"cloudkms.us-central1.p.rep.googleapis.com\". + - !ruby/object:Api::Type::String + name: 'network' + description: | + The name of the VPC network for this private regional endpoint. Format: `projects/{project}/global/networks/{network}` + default_from_api: true + - !ruby/object:Api::Type::String + name: 'subnetwork' + description: | + The name of the subnetwork from which the IP address will be allocated. Format: `projects/{project}/regions/{region}/subnetworks/{subnetwork}` + default_from_api: true + - !ruby/object:Api::Type::Enum + name: accessType + required: true + description: | + The access type of this regional endpoint. This field is reflected in the PSC Forwarding Rule configuration to enable global access. + values: + - :GLOBAL + - :REGIONAL + - !ruby/object:Api::Type::String + name: 'pscForwardingRule' + output: true + description: | + The resource reference of the PSC Forwarding Rule created on behalf of the customer. Format: `//compute.googleapis.com/projects/{project}/regions/{region}/forwardingRules/{forwarding_rule_name}` + - !ruby/object:Api::Type::String + name: 'address' + description: | + The IP Address of the Regional Endpoint. When no address is provided, an IP from the subnetwork is allocated. Use one of the following formats: * IPv4 address as in `10.0.0.1` * Address resource URI as in `projects/{project}/regions/{region}/addresses/{address_name}` + + ~> **Note:** This field accepts both a reference to a Compute Address resource, which is the resource name of which format is given in the description, and IP literal value. If the user chooses to input a reserved address value; they need to make sure that the reserved address is in IPv4 version, its purpose is GCE_ENDPOINT, its type is INTERNAL and its status is RESERVED. If the user chooses to input an IP literal, they need to make sure that it's a valid IPv4 address (x.x.x.x) within the subnetwork. + default_from_api: true diff --git a/mmv1/templates/terraform/examples/network_connectivity_regional_endpoint_global_access.tf.erb b/mmv1/templates/terraform/examples/network_connectivity_regional_endpoint_global_access.tf.erb new file mode 100644 index 000000000000..b730a0b27ba7 --- /dev/null +++ b/mmv1/templates/terraform/examples/network_connectivity_regional_endpoint_global_access.tf.erb @@ -0,0 +1,21 @@ +resource "google_compute_network" "my_network" { + name = "<%= ctx[:vars]['rep_network'] %>" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "my_subnetwork" { + name = "<%= ctx[:vars]['rep_subnetwork'] %>" + ip_cidr_range = "192.168.0.0/24" + region = "us-central1" + network = google_compute_network.my_network.id +} + +resource "google_network_connectivity_regional_endpoint" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]['rep_name'] %>" + location = "us-central1" + target_google_api = "boqcodelabjaimin-pa.us-central1.p.rep.googleapis.com" + access_type = "GLOBAL" + address = "192.168.0.4" + network = google_compute_network.my_network.id + subnetwork = google_compute_subnetwork.my_subnetwork.id +} diff --git a/mmv1/templates/terraform/examples/network_connectivity_regional_endpoint_regional_access.tf.erb b/mmv1/templates/terraform/examples/network_connectivity_regional_endpoint_regional_access.tf.erb new file mode 100644 index 000000000000..10e947d698eb --- /dev/null +++ b/mmv1/templates/terraform/examples/network_connectivity_regional_endpoint_regional_access.tf.erb @@ -0,0 +1,23 @@ +resource "google_compute_network" "my_network" { + name = "<%= ctx[:vars]['rep_network'] %>" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "my_subnetwork" { + name = "<%= ctx[:vars]['rep_subnetwork'] %>" + ip_cidr_range = "192.168.0.0/24" + region = "us-central1" + network = google_compute_network.my_network.id +} + +resource "google_network_connectivity_regional_endpoint" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]['rep_name'] %>" + location = "us-central1" + target_google_api = "boqcodelabjaimin-pa.us-central1.p.rep.googleapis.com" + access_type = "REGIONAL" + address = "192.168.0.5" + network = google_compute_network.my_network.id + subnetwork = google_compute_subnetwork.my_subnetwork.id + description = "My RegionalEndpoint targeting Google API boqcodelabjaimin-pa.us-central1.p.rep.googleapis.com" + labels = {env = "default"} +}