Google API Gateway Gateway
This page shows how to write Terraform for API Gateway Gateway and write them securely.
google_api_gateway_gateway (Terraform)
The Gateway in API Gateway can be configured in Terraform with the resource name google_api_gateway_gateway
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_api_gateway_gateway" "gw" {
provider = google-beta
region = var.region
api_config = google_api_gateway_api_config.api_cfg.id
resource "google_api_gateway_gateway" "webhook" {
provider = google-beta
api_config = google_api_gateway_api_config.webhook.id
gateway_id = "tfc-notifications"
}
resource "google_api_gateway_gateway" "shopping-list-gateway" {
provider = google-beta
api_config = google_api_gateway_api_config.shopping-list-api-config.id
gateway_id = "shopping-list-gateway-id"
}
resource "google_api_gateway_gateway" "api_gateway" {
provider = google-beta
gateway_id = "api-gateway"
api_config = google_api_gateway_api_config.api_config.name
}
resource "google_api_gateway_gateway" "api_cfg4" {
provider = google-beta
api_config = google_api_gateway_api_config.api_cfg4.id
gateway_id = "api-gw4"
project = var.project_id
region = var.region
Parameters
The following arguments are supported:
api_config
- (Required) Resource name of the API Config for this Gateway. Format: projects/[project]/locations/global/apis/[api]/configs/[apiConfig]. When changing api configs please ensure the new config is a new resource and the lifecycle rulecreate_before_destroy
is set.gateway_id
- (Required) Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
display_name
- (Optional) A user-visible name for the API.labels
- (Optional) Resource labels to represent user-provided metadata.region
- (Optional) The region of the gateway for the API.project
- (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with formatprojects/[[project]]/locations/[[region]]/gateways/[[gateway_id]]
name
- Resource name of the Gateway. Format: projects/[project]/locations/[region]/gateways/[gateway]default_hostname
- The default API Gateway host name of the form [gatewayId]-[hash].[region_code].gateway.dev.
Explanation in Terraform Registry
A consumable API that can be used by multiple Gateways.
Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources. To get more information about Gateway, see:
- API documentation
- How-to Guides
Frequently asked questions
What is Google API Gateway Gateway?
Google API Gateway Gateway is a resource for API Gateway of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google API Gateway Gateway?
For Terraform, the femrtnz/google-cloud-api-gateway, binxio/terraform-google-terraform-cloud-notification-sink and MihaelaLazar/shopping-list-serverless-poc source code examples are useful. See the Terraform Example section for further details.