Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ncc rep resource #10573

Merged
merged 22 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9e7b4b9
Add a new resource RegionalEndpoint under product networkconnectivity
May 1, 2024
f7cd29f
Add a new resource RegionalEndpoint under product networkconnectivity…
May 1, 2024
c3de0ac
Add examples for the new resource RegionalEndpoint
May 1, 2024
a4a2ac5
Add examples for regional access for the new resource RegionalEndpoint
May 1, 2024
39b0a62
Fix example names
May 1, 2024
bb0765f
Change regional_endpoints to regional_endpoint
May 1, 2024
0d10826
Fix [key-duplicates] duplication of key name in mapping
May 1, 2024
41d8a70
Fix acceptance tests. Make ip-verion, ip_version
May 1, 2024
0e56f08
Fix acceptance tests. Add values for description, labels and project.
May 1, 2024
a14f799
Fix acceptance tests. Don't assign value for output only fields, name.
May 1, 2024
6b354a6
Fix address_type in google_compute_address resources in tests
May 1, 2024
6177ad1
Remove unnecessary field declarations in RegionalEndpoint.yaml, fix t…
May 1, 2024
0a82096
remove output=true from parameter. fix tests.
May 1, 2024
2cb46b0
add to the examples
May 1, 2024
df669dd
hardcode target-google-api field in tests
May 2, 2024
579a95a
fix region in target-google-api
May 2, 2024
cd85a92
remove address input from tests due to complications regarding ipVers…
May 2, 2024
6f42cbb
add default_from_api: true to address field
May 2, 2024
78a94be
Add default_from_api: true for network and subnetwork fields
May 2, 2024
27dbdf0
Add a note for the address field
May 2, 2024
5cc1fab
Remove trailing space from RegionalEndpoint
May 2, 2024
377dd7a
Make name field required
May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions mmv1/products/networkconnectivity/RegionalEndpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# 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'
simalcubuk marked this conversation as resolved.
Show resolved Hide resolved
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'
immutable: true
simalcubuk marked this conversation as resolved.
Show resolved Hide resolved
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.

simalcubuk marked this conversation as resolved.
Show resolved Hide resolved
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: |
simalcubuk marked this conversation as resolved.
Show resolved Hide resolved
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}`
default_from_api: true
Original file line number Diff line number Diff line change
@@ -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'] %>"
simalcubuk marked this conversation as resolved.
Show resolved Hide resolved
location = "us-central1"
target_google_api = "boqcodelabjaimin-pa.us-central1.p.rep.googleapis.com"
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
access_type = "GLOBAL"
address = "192.168.0.4"
network = google_compute_network.my_network.id
subnetwork = google_compute_subnetwork.my_subnetwork.id
}
Original file line number Diff line number Diff line change
@@ -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"}
}