-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add API Gateway resources #4066
Changes from all commits
71c3aeb
e1a9488
51eaff6
649e97c
ee373cc
31931f4
13d0a68
f40ad7f
4b7ae0c
da8373b
5279025
5dfaa6c
8feeb1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
# Copyright 2020 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::Product | ||
name: ApiGateway | ||
display_name: API Gateway | ||
versions: | ||
- !ruby/object:Api::Product::Version | ||
name: beta | ||
base_url: https://apigateway.googleapis.com/v1beta/ | ||
scopes: | ||
- https://www.googleapis.com/auth/cloud-platform | ||
async: !ruby/object:Api::OpAsync | ||
operation: !ruby/object:Api::OpAsync::Operation | ||
path: 'name' | ||
base_url: '{{op_id}}' | ||
wait_ms: 1000 | ||
result: !ruby/object:Api::OpAsync::Result | ||
path: 'response' | ||
resource_inside_response: true | ||
status: !ruby/object:Api::OpAsync::Status | ||
path: 'done' | ||
complete: True | ||
allowed: | ||
- True | ||
- False | ||
error: !ruby/object:Api::OpAsync::Error | ||
path: 'error' | ||
message: 'message' | ||
objects: | ||
- !ruby/object:Api::Resource | ||
name: 'Api' | ||
min_version: beta | ||
create_url: projects/{{project}}/locations/global/apis?apiId={{api_id}} | ||
self_link: projects/{{project}}/locations/global/apis/{{api_id}} | ||
base_url: projects/{{project}}/locations/global/apis | ||
update_verb: :PATCH | ||
update_mask: true | ||
description: | | ||
A consumable API that can be used by multiple Gateways. | ||
references: !ruby/object:Api::Resource::ReferenceLinks | ||
guides: | ||
'Official Documentation': | ||
'https://cloud.google.com/api-gateway/docs/quickstart' | ||
api: 'https://cloud.google.com/api-gateway/docs/reference/rest/v1beta/projects.locations.apis' | ||
parameters: | ||
- !ruby/object:Api::Type::String | ||
name: apiId | ||
description: | | ||
Identifier to assign to the API. Must be unique within scope of the parent resource(project) | ||
required: true | ||
input: true | ||
url_param_only: true | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: 'name' | ||
description: | | ||
The resource name of the API. Format `projects/{{project}}/locations/global/apis/{{apiId}}` | ||
output: true | ||
- !ruby/object:Api::Type::String | ||
name: 'displayName' | ||
description: | | ||
A user-visible name for the API. | ||
- !ruby/object:Api::Type::String | ||
name: 'managedService' | ||
input: true | ||
description: | | ||
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). | ||
If not specified, a new Service will automatically be created in the same project as this API. | ||
- !ruby/object:Api::Type::Time | ||
name: 'createTime' | ||
description: Creation timestamp in RFC3339 text format. | ||
output: true | ||
- !ruby/object:Api::Type::KeyValuePairs | ||
name: 'labels' | ||
description: | | ||
Resource labels to represent user-provided metadata. | ||
- !ruby/object:Api::Resource | ||
name: 'ApiConfig' | ||
min_version: beta | ||
create_url: projects/{{project}}/locations/global/apis/{{api}}/configs?apiConfigId={{api_config_id}} | ||
self_link: projects/{{project}}/locations/global/apis/{{api}}/configs/{{api_config_id}} | ||
base_url: projects/{{project}}/locations/global/apis/{{api}}/configs | ||
read_query_params: '?view=FULL' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried just setting this on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't but I generated one now and it doesn't work. It replaced all the urls including Create and Delete methods
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to go with the mm attribute. |
||
update_verb: :PATCH | ||
update_mask: true | ||
description: | | ||
An API Configuration is an association of an API Controller Config and a Gateway Config | ||
references: !ruby/object:Api::Resource::ReferenceLinks | ||
guides: | ||
'Official Documentation': | ||
'https://cloud.google.com/api-gateway/docs/quickstart' | ||
api: 'https://cloud.google.com/api-gateway/docs/reference/rest/v1beta/projects.locations.apis.configs' | ||
parameters: | ||
- !ruby/object:Api::Type::String | ||
name: api | ||
description: | | ||
The API to attach the config to. | ||
required: true | ||
input: true | ||
url_param_only: true | ||
- !ruby/object:Api::Type::String | ||
name: apiConfigId | ||
description: | | ||
Identifier to assign to the API Config. Must be unique within scope of the parent resource(api). | ||
required: true | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
input: true | ||
url_param_only: true | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: 'name' | ||
description: The resource name of the API Config. | ||
output: true | ||
- !ruby/object:Api::Type::String | ||
name: 'displayName' | ||
description: | | ||
A user-visible name for the API. | ||
- !ruby/object:Api::Type::String | ||
name: 'serviceConfigId' | ||
output: true | ||
description: | | ||
The ID of the associated Service Config (https://cloud.google.com/service-infrastructure/docs/glossary#config). | ||
- !ruby/object:Api::Type::KeyValuePairs | ||
name: 'labels' | ||
description: | | ||
Resource labels to represent user-provided metadata. | ||
- !ruby/object:Api::Type::NestedObject | ||
name: 'gatewayConfig' | ||
input: true | ||
description: | | ||
Immutable. Gateway specific configuration. | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
If not specified, backend authentication will be set to use OIDC authentication using the default compute service account | ||
properties: | ||
- !ruby/object:Api::Type::NestedObject | ||
name: 'backendConfig' | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: true | ||
description: | | ||
Backend settings that are applied to all backends of the Gateway. | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: 'googleServiceAccount' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it defaults to the GCE default service account. Same with the parent field. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That true if the user doesn't specify a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i see, make it required on googleServiceAccount but not on backendConfig There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess my question is, is there a functional difference between these three scenarios?
2:
3:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The null is tested in the basic example and there are no problems there. The other two.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not about whether or not there are problems, but about providing a consistent interface to our users and helping them write their configs correctly. If there are two ways of doing the exact same thing, we can simplify and make it so that there's only one way. hashicorp/terraform-provider-google#3928 has more context on why we try not to allow objects with only optional fields. It's a thing we allow only when there is a specific need. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't follow. Are you saying make all the child fields mandatory and the top level field (gatewayConfig) optional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, did that in my last commit. |
||
input: true | ||
required: true | ||
description: | | ||
Google Cloud IAM service account used to sign OIDC tokens for backends that have authentication configured | ||
(https://cloud.google.com/service-infrastructure/docs/service-management/reference/rest/v1/services.configs#backend). | ||
- !ruby/object:Api::Type::Array | ||
name: 'openapiDocuments' | ||
description: | | ||
An OpenAPI Specification Document describing an API. | ||
required: true | ||
item_type: !ruby/object:Api::Type::NestedObject | ||
properties: | ||
- !ruby/object:Api::Type::NestedObject | ||
name: 'document' | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: true | ||
description: The OpenAPI Specification document file. | ||
properties: | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- !ruby/object:Api::Type::String | ||
name: 'path' | ||
required: true | ||
input: true | ||
description: | | ||
The file path (full or relative path). This is typically the path of the file when it is uploaded. | ||
- !ruby/object:Api::Type::String | ||
name: 'contents' | ||
required: true | ||
input: true | ||
description: | | ||
Base64 encoded content of the file. | ||
- !ruby/object:Api::Resource | ||
name: 'Gateway' | ||
min_version: beta | ||
create_url: projects/{{project}}/locations/{{region}}/gateways?gatewayId={{gateway_id}} | ||
self_link: projects/{{project}}/locations/{{region}}/gateways/{{gateway_id}} | ||
base_url: projects/{{project}}/locations/{{region}}/gateways | ||
update_verb: :PATCH | ||
update_mask: true | ||
description: | | ||
A consumable API that can be used by multiple Gateways. | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
references: !ruby/object:Api::Resource::ReferenceLinks | ||
guides: | ||
'Official Documentation': | ||
'https://cloud.google.com/api-gateway/docs/quickstart' | ||
api: 'https://cloud.google.com/api-gateway/docs/reference/rest/v1beta/projects.locations.apis' | ||
parameters: | ||
- !ruby/object:Api::Type::String | ||
name: 'region' | ||
description: | | ||
The region of the gateway for the API. | ||
input: true | ||
url_param_only: true | ||
- !ruby/object:Api::Type::String | ||
name: gatewayId | ||
description: | | ||
Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project). | ||
required: true | ||
input: true | ||
url_param_only: true | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: 'name' | ||
description: | | ||
Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway} | ||
output: true | ||
- !ruby/object:Api::Type::String | ||
name: 'displayName' | ||
description: | | ||
A user-visible name for the API. | ||
- !ruby/object:Api::Type::String | ||
name: 'apiConfig' | ||
required: true | ||
input: true | ||
description: | | ||
Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig} | ||
- !ruby/object:Api::Type::String | ||
name: 'defaultHostname' | ||
output: true | ||
description: The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev. | ||
- !ruby/object:Api::Type::KeyValuePairs | ||
name: 'labels' | ||
description: | | ||
Resource labels to represent user-provided metadata. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Copyright 2020 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:Provider::Terraform::Config | ||
overrides: !ruby/object:Overrides::ResourceOverrides | ||
Api: !ruby/object:Overrides::Terraform::ResourceOverride | ||
timeouts: !ruby/object:Api::Timeouts | ||
insert_minutes: 6 | ||
update_minutes: 6 | ||
delete_minutes: 6 | ||
autogen_async: true | ||
iam_policy: !ruby/object:Api::Resource::IamPolicy | ||
allowed_iam_role: 'roles/apigateway.viewer' | ||
method_name_separator: ':' | ||
parent_resource_attribute: 'api' | ||
base_url: projects/{{project}}/locations/global/apis/{{api}} | ||
examples: | ||
- !ruby/object:Provider::Terraform::Examples | ||
min_version: beta | ||
name: "apigateway_api_basic" | ||
primary_resource_id: "api" | ||
vars: | ||
name: "api" | ||
- !ruby/object:Provider::Terraform::Examples | ||
min_version: beta | ||
name: "apigateway_api_full" | ||
primary_resource_id: "api" | ||
vars: | ||
name: "api" | ||
properties: | ||
displayName: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
managedService: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
ApiConfig: !ruby/object:Overrides::Terraform::ResourceOverride | ||
timeouts: !ruby/object:Api::Timeouts | ||
insert_minutes: 6 | ||
update_minutes: 6 | ||
delete_minutes: 6 | ||
autogen_async: true | ||
iam_policy: !ruby/object:Api::Resource::IamPolicy | ||
allowed_iam_role: 'roles/apigateway.viewer' | ||
parent_resource_attribute: api_config | ||
base_url: projects/{{project}}/locations/global/apis/{{api}}/configs/{{api_config}} | ||
example_config_body: 'templates/terraform/iam/example_config_body/api_gateway_api_config.tf.erb' | ||
method_name_separator: ':' | ||
import_format: ["projects/{{project}}/locations/global/apis/{{api}}/configs/{{api_config}}", "{{project}}/{{api}}/{{api_config}}", "{{api}}/{{api_config}}", "{{api_config}}"] | ||
examples: | ||
- !ruby/object:Provider::Terraform::Examples | ||
min_version: beta | ||
name: "apigateway_api_config_basic" | ||
primary_resource_id: "api_cfg" | ||
vars: | ||
name: "api-cfg" | ||
- !ruby/object:Provider::Terraform::Examples | ||
min_version: beta | ||
name: "apigateway_api_config_full" | ||
primary_resource_id: "api_cfg" | ||
vars: | ||
name: "api-cfg" | ||
properties: | ||
displayName: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
gatewayConfig: !ruby/object:Overrides::Terraform::PropertyOverride | ||
ignore_read: true | ||
Gateway: !ruby/object:Overrides::Terraform::ResourceOverride | ||
timeouts: !ruby/object:Api::Timeouts | ||
insert_minutes: 6 | ||
update_minutes: 6 | ||
delete_minutes: 6 | ||
autogen_async: true | ||
iam_policy: !ruby/object:Api::Resource::IamPolicy | ||
allowed_iam_role: 'roles/apigateway.viewer' | ||
method_name_separator: ':' | ||
parent_resource_attribute: 'gateway' | ||
base_url: projects/{{project}}/locations/{{region}}/gateways/{{gateway}} | ||
examples: | ||
- !ruby/object:Provider::Terraform::Examples | ||
min_version: beta | ||
name: "apigateway_gateway_basic" | ||
primary_resource_id: "api_gw" | ||
vars: | ||
name: "api-gw" | ||
- !ruby/object:Provider::Terraform::Examples | ||
min_version: beta | ||
name: "apigateway_gateway_full" | ||
primary_resource_id: "api_gw" | ||
vars: | ||
name: "api-gw" | ||
properties: | ||
displayName: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
region: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
|
||
# This is for copying files over | ||
files: !ruby/object:Provider::Config::Files | ||
# These files have templating (ERB) code that will be run. | ||
# This is usually to add licensing info, autogeneration notices, etc. | ||
compile: | ||
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "google_api_gateway_api" "<%= ctx[:primary_resource_id] %>" { | ||
upodroid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
provider = google-beta | ||
api_id = "<%= ctx[:vars]["name"] %>" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think our users typically care about having createTime in state, so this can be removed (but it's not super important)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^