Skip to content

Commit

Permalink
Add prefix to API Config (hashicorp#4193)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Nov 9, 2020
1 parent a4fd4d8 commit 0e63e48
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .changelog/4193.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
apigateway: added api_config_id_prefix field to `google_api_gateway_api_config` resoure
```
18 changes: 0 additions & 18 deletions website/docs/r/api_gateway_api.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ resource "google_api_gateway_api" "api" {
api_id = "api"
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=apigateway_api_full&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Apigateway Api Full


```hcl
resource "google_api_gateway_api" "api" {
provider = google-beta
api_id = "api"
display_name = "MM Dev API"
labels = {
environment = "dev"
}
}
```

## Argument Reference

Expand Down
46 changes: 10 additions & 36 deletions website/docs/r/api_gateway_api_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To get more information about ApiConfig, see:

* [API documentation](https://cloud.google.com/api-gateway/docs/reference/rest/v1beta/projects.locations.apis.configs)
* How-to Guides
* [Official Documentation](https://cloud.google.com/api-gateway/docs/quickstart)
* [Official Documentation](https://cloud.google.com/api-gateway/docs/creating-api-config)

<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=apigateway_api_config_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
Expand All @@ -50,44 +50,16 @@ resource "google_api_gateway_api" "api_cfg" {
resource "google_api_gateway_api_config" "api_cfg" {
provider = google-beta
api = google_api_gateway_api.api_cfg.api_id
api_config_id = "api-cfg"
api_config_id_prefix = "api-cfg-"
openapi_documents {
document {
path = "spec.yaml"
contents = filebase64("test-fixtures/apigateway/openapi.yaml")
}
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=apigateway_api_config_full&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Apigateway Api Config Full


```hcl
resource "google_api_gateway_api" "api_cfg" {
provider = google-beta
api_id = "api-cfg"
}
resource "google_api_gateway_api_config" "api_cfg" {
provider = google-beta
api = google_api_gateway_api.api_cfg.api_id
api_config_id = "api-cfg"
display_name = "MM Dev API Config"
labels = {
environment = "dev"
}
openapi_documents {
document {
path = "spec.yaml"
contents = filebase64("test-fixtures/apigateway/openapi.yaml")
}
lifecycle {
create_before_destroy = true
}
}
```
Expand All @@ -106,10 +78,6 @@ The following arguments are supported:
(Required)
The API to attach the config to.

* `api_config_id` -
(Required)
Identifier to assign to the API Config. Must be unique within scope of the parent resource(api).


The `openapi_documents` block supports:

Expand Down Expand Up @@ -146,9 +114,15 @@ The `document` block supports:
If not specified, backend authentication will be set to use OIDC authentication using the default compute service account
Structure is documented below.

* `api_config_id` -
(Optional)
Identifier to assign to the API Config. Must be unique within scope of the parent resource(api).

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

* `api_config_id_prefix` - (Optional) Creates a unique name beginning with the
specified prefix. If this and api_config_id are unspecified, a random value is chosen for the name.

The `gateway_config` block supports:

Expand Down
41 changes: 3 additions & 38 deletions website/docs/r/api_gateway_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,58 +50,23 @@ resource "google_api_gateway_api" "api_gw" {
resource "google_api_gateway_api_config" "api_gw" {
provider = google-beta
api = google_api_gateway_api.api_gw.api_id
api_config_id = "api-gw"
api_config_id_prefix = "tf-test-"
openapi_documents {
document {
path = "spec.yaml"
contents = filebase64("test-fixtures/apigateway/openapi.yaml")
}
}
}
resource "google_api_gateway_gateway" "api_gw" {
provider = google-beta
api_config = google_api_gateway_api_config.api_gw.id
gateway_id = "api-gw"
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=apigateway_gateway_full&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Apigateway Gateway Full


```hcl
resource "google_api_gateway_api" "api_gw" {
provider = google-beta
api_id = "api-gw"
}
resource "google_api_gateway_api_config" "api_gw" {
provider = google-beta
api = google_api_gateway_api.api_gw.api_id
api_config_id = "api-gw"
openapi_documents {
document {
path = "spec.yaml"
contents = filebase64("test-fixtures/apigateway/openapi.yaml")
}
lifecycle {
create_before_destroy = true
}
}
resource "google_api_gateway_gateway" "api_gw" {
provider = google-beta
region = "us-central1"
api_config = google_api_gateway_api_config.api_gw.id
gateway_id = "api-gw"
display_name = "MM Dev API Gateway"
labels = {
environment = "dev"
}
}
```

Expand Down

0 comments on commit 0e63e48

Please sign in to comment.