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

Create resource gateway #7489

Merged
merged 15 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
132 changes: 132 additions & 0 deletions mmv1/products/networkservices/Gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Copyright 2023 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: 'Gateway'
base_url: 'projects/{{project}}/locations/{{location}}/gateways'
create_url: 'projects/{{project}}/locations/{{location}}/gateways?gatewayId={{name}}'
self_link: 'projects/{{project}}/locations/{{location}}/gateways/{{name}}'
min_version: beta
update_verb: :PATCH
update_mask: true
description: |
Gateway represents the configuration for a proxy, typically a load balancer.
It captures the ip:port over which the services are exposed by the proxy,
along with any policy configurations. Routes have reference to to Gateways
to dictate how requests should be routed by this Gateway.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/traffic-director/docs/reference/network-services/rest/v1beta1/projects.locations.gateways'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 30
update_minutes: 30
delete_minutes: 30
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'
autogen_async: true
import_format: ['projects/{{project}}/locations/{{location}}/gateways/{{name}}']
examples:
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: 'network_services_gateway_basic'
primary_resource_id: 'default'
vars:
resource_name: 'my-gateway'
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: 'network_services_gateway_advanced'
primary_resource_id: 'default'
vars:
resource_name: 'my-gateway'
parameters:
- !ruby/object:Api::Type::String
name: 'name'
required: true
url_param_only: true
description: |
Short name of the Gateway resource to be created.
- !ruby/object:Api::Type::String
name: 'location'
default_value: 'global'
description: |
The location of the gateway.
The default value is `global`.
url_param_only: true
properties:
- !ruby/object:Api::Type::String
name: 'selfLink'
description: |
Server-defined URL of this resource.
output: true
- !ruby/object:Api::Type::Time
name: 'createTime'
description: |
Time the AccessPolicy was created in UTC.
output: true
- !ruby/object:Api::Type::Time
name: 'updateTime'
description: |
Time the AccessPolicy was updated in UTC.
output: true
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: Set of label tags associated with the Gateway resource.
- !ruby/object:Api::Type::String
name: 'description'
description: |
A free-text description of the resource. Max length 1024 characters.
- !ruby/object:Api::Type::Enum
name: 'type'
required: true
immutable: true
description: |
Immutable. The type of the customer-managed gateway. Possible values are: * OPEN_MESH * SECURE_WEB_GATEWAY.
values:
- :TYPE_UNSPECIFIED
- :OPEN_MESH
- :SECURE_WEB_GATEWAY
- !ruby/object:Api::Type::Array
name: 'ports'
felipegc marked this conversation as resolved.
Show resolved Hide resolved
required: true
immutable: true
description: |
One or more port numbers (1-65535), on which the Gateway will receive traffic.
The proxy binds to the specified ports. Gateways of type 'SECURE_WEB_GATEWAY' are
limited to 1 port. Gateways of type 'OPEN_MESH' listen on 0.0.0.0 and support multiple ports.
item_type: Api::Type::Integer
- !ruby/object:Api::Type::String
name: 'scope'
required: true
description: |
Immutable. Scope determines how configuration across multiple Gateway instances are merged.
The configuration for multiple Gateway instances with the same scope will be merged as presented as
a single coniguration to the proxy/load balancer.
Max length 64 characters. Scope should start with a letter and can only have letters, numbers, hyphens.
- !ruby/object:Api::Type::String
name: 'serverTlsPolicy'
description: |
A fully-qualified ServerTLSPolicy URL reference. Specifies how TLS traffic is terminated.
If empty, TLS termination is disabled.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "google_network_services_gateway" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]['resource_name'] %>"
labels = {
foo = "bar"
}
description = "my description"
type = "OPEN_MESH"
ports = [443]
scope = "default-scope-advance"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_network_services_gateway" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]['resource_name'] %>"
scope = "default-scope-basic"
type = "OPEN_MESH"
ports = [443]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccNetworkServicesGateway_update(t *testing.T) {
t.Parallel()

gatewayName := fmt.Sprintf("tf-test-gateway-%s", RandString(t, 10))

VcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: TestAccProviders,
CheckDestroy: testAccCheckNetworkServicesGatewayDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccNetworkServicesGateway_basic(gatewayName),
},
{
ResourceName: "google_network_services_gateway.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccNetworkServicesGateway_update(gatewayName),
},
{
ResourceName: "google_network_services_gateway.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccNetworkServicesGateway_basic(gatewayName string) string {
return fmt.Sprintf(`
resource "google_network_services_gateway" "foobar" {
name = "%s"
scope = "default-scope-update"
type = "OPEN_MESH"
ports = [443]
description = "my description"
}
`, gatewayName)
}

func testAccNetworkServicesGateway_update(gatewayName string) string {
return fmt.Sprintf(`
resource "google_network_services_gateway" "foobar" {
name = "%s"
scope = "default-scope-update"
type = "OPEN_MESH"
ports = [443]
description = "update description"
labels = {
foo = "bar"
}
}
`, gatewayName)
}

<% end -%>