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

Add API Gateway resources #4066

Merged
merged 13 commits into from
Oct 23, 2020
3 changes: 3 additions & 0 deletions api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ module Properties
attr_reader :update_verb
# [Optional] The HTTP verb used during delete. Defaults to :DELETE.
attr_reader :delete_verb
# [Optional] Additional Query Parameters to append to GET. Defaults to ""
attr_reader :read_query_params
# ====================
# Collection / Identity URL Configuration
# ====================
Expand Down Expand Up @@ -137,6 +139,7 @@ def validate
check :create_url, type: String
check :delete_url, type: String
check :update_url, type: String
check :read_query_params, type: String
check :update_mask, type: :boolean
check :description, type: String, required: true
check :exclude, type: :boolean
Expand Down
3 changes: 3 additions & 0 deletions api/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ module Fields
attr_reader :url_param_only
attr_reader :required

# [Additional query Parameters to append to GET calls.
attr_reader :read_query_params
attr_reader :update_verb
attr_reader :update_url
# Some updates only allow updating certain fields at once (generally each
Expand Down Expand Up @@ -114,6 +116,7 @@ def validate
check :send_empty_value, type: :boolean
check :allow_empty_object, type: :boolean
check :url_param_only, type: :boolean
check :read_query_params, type: ::String

raise 'Property cannot be output and required at the same time.' \
if @output && @required
Expand Down
233 changes: 233 additions & 0 deletions products/apigateway/api.yaml
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
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried just setting this on self_link? If that works, then you can avoid having to add an extra MM attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

2020/10/21 19:23:23 [DEBUG] Google API Request Details:
---[ REQUEST ]---------------------------------------
DELETE /v1beta/projects/REDACTED/locations/global/apis/test/configs/tf-test-api-cfgwn1ovme2i3?alt=json&view=FULL HTTP/1.1
Host: apigateway.googleapis.com
User-Agent: Terraform/0.12.29 (+https://www.terraform.io) Terraform-Plugin-SDK/2.0.3 terraform-provider-google-beta/acc 
Content-Type: application/json
Accept-Encoding: gzip


-----------------------------------------------------
2020/10/21 19:23:24 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 400 Bad Request
Connection: close
Transfer-Encoding: chunked
Alt-Svc: h3-Q050=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Wed, 21 Oct 2020 18:23:24 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

229
{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"view\": Cannot bind query parameter. Field 'view' could not be found in request message.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "description": "Invalid JSON payload received. Unknown name \"view\": Cannot bind query parameter. Field 'view' could not be found in request message."
          }
        ]
      }
    ]
  }
}

0

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That true if the user doesn't specify a gatewayConfig though, right? If so, then we can just allow users that don't set one to have the API-given default, and require users that do set it to actually specify the field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, make it required on googleServiceAccount but not on backendConfig

Copy link
Contributor

Choose a reason for hiding this comment

The 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?
1:

gatewayConfig: null

2:

gatewayConfig: {}

3:

gatewayConfig: {
  backendConfig: {}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

 REDACTED  MCW0CDP3YY  ~  $  echo '{"openapiDocuments":[{"document":{"contents":"c3dhZ2dlcjogJzIuMCcKaW5mbzoKICB0aXRsZTogZGV2IAogIGRlc2NyaXB0aW9uOiBTYW1wbGUgQVBJIG9uIEFQSSBHYXRld2F5IHdpdGggYSBDbG91ZCBSdW4gYmFja2VuZAogIHZlcnNpb246IDEuMC4wCnNjaGVtZXM6CiAgLSBodHRwcwpwcm9kdWNlczoKICAtIGFwcGxpY2F0aW9uL2pzb24KcGF0aHM6CiAgL2hlbGxvOgogICAgZ2V0OgogICAgICBzdW1tYXJ5OiBHcmVldCBhIHVzZXIKICAgICAgb3BlcmF0aW9uSWQ6IGhlbGxvCiAgICAgIHgtZ29vZ2xlLWJhY2tlbmQ6CiAgICAgICAgYWRkcmVzczogaHR0cHM6Ly9nb29nbGUuY29tCiAgICAgIHJlc3BvbnNlczoKICAgICAgICAnMjAwJzoKICAgICAgICAgIGRlc2NyaXB0aW9uOiBBIHN1Y2Nlc3NmdWwgcmVzcG9uc2UKICAgICAgICAgIHNjaGVtYToKICAgICAgICAgICAgdHlwZTogc3RyaW5n","path":"spec.yaml"}}],"gatewayConfig":{"backendConfig":{}}}' | http POST "https://apigateway.googleapis.com/v1beta/projects/REDACTED/locations/global/apis/test/configs?alt=json&apiConfigId=potato" "Authorization: Bearer $(gcloud auth print-access-token)"
HTTP/1.1 200 OK
Alt-Svc: h3-Q050=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Wed, 21 Oct 2020 18:35:45 GMT
Server: ESF
Transfer-Encoding: chunked
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0

{
    "done": false,
    "metadata": {
        "@type": "type.googleapis.com/google.cloud.apigateway.v1beta.OperationMetadata",
        "apiVersion": "v1beta",
        "createTime": "2020-10-21T18:35:45.486637683Z",
        "requestedCancellation": false,
        "target": "projects/REDACTED/locations/global/apis/test/configs/potato",
        "verb": "create"
    },
    "name": "projects/REDACTED/locations/global/operations/operation-1603305344956-5b2329d8d7825-80f08ca0-cb70a3e5"
}

 REDACTED  MCW0CDP3YY  ~  SIGINT  $  echo '{"openapiDocuments":[{"document":{"contents":"c3dhZ2dlcjogJzIuMCcKaW5mbzoKICB0aXRsZTogZGV2IAogIGRlc2NyaXB0aW9uOiBTYW1wbGUgQVBJIG9uIEFQSSBHYXRld2F5IHdpdGggYSBDbG91ZCBSdW4gYmFja2VuZAogIHZlcnNpb246IDEuMC4wCnNjaGVtZXM6CiAgLSBodHRwcwpwcm9kdWNlczoKICAtIGFwcGxpY2F0aW9uL2pzb24KcGF0aHM6CiAgL2hlbGxvOgogICAgZ2V0OgogICAgICBzdW1tYXJ5OiBHcmVldCBhIHVzZXIKICAgICAgb3BlcmF0aW9uSWQ6IGhlbGxvCiAgICAgIHgtZ29vZ2xlLWJhY2tlbmQ6CiAgICAgICAgYWRkcmVzczogaHR0cHM6Ly9nb29nbGUuY29tCiAgICAgIHJlc3BvbnNlczoKICAgICAgICAnMjAwJzoKICAgICAgICAgIGRlc2NyaXB0aW9uOiBBIHN1Y2Nlc3NmdWwgcmVzcG9uc2UKICAgICAgICAgIHNjaGVtYToKICAgICAgICAgICAgdHlwZTogc3RyaW5n","path":"spec.yaml"}}],"gatewayConfig":{}}' | http POST "https://apigateway.googleapis.com/v1beta/projects/REDACTED/locations/global/apis/test/configs?alt=json&apiConfigId=tf-test-api-cfgvjqjfh298j" "Authorization: Bearer $(gcloud auth print-access-token)"
HTTP/1.1 200 OK
Alt-Svc: h3-Q050=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Wed, 21 Oct 2020 18:31:53 GMT
Server: ESF
Transfer-Encoding: chunked
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0

{
    "done": false,
    "metadata": {
        "@type": "type.googleapis.com/google.cloud.apigateway.v1beta.OperationMetadata",
        "apiVersion": "v1beta",
        "createTime": "2020-10-21T18:31:53.702041935Z",
        "requestedCancellation": false,
        "target": "projects/REDACTED/locations/global/apis/test/configs/tf-test-api-cfgvjqjfh298j",
        "verb": "create"
    },
    "name": "projects/REDACTED/locations/global/operations/operation-1603305113163-5b2328fbc959d-c44b83b5-1c27fca5"
}

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
111 changes: 111 additions & 0 deletions products/apigateway/terraform.yaml
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)) -%>
4 changes: 4 additions & 0 deletions templates/terraform/examples/apigateway_api_basic.tf.erb
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"] %>"
}
Loading