Google API Gateway API Config

This page shows how to write Terraform for API Gateway API Config and write them securely.

google_api_gateway_api_config (Terraform)

The API Config in API Gateway can be configured in Terraform with the resource name google_api_gateway_api_config. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "google_api_gateway_api_config" "api_config" {
  provider             = google-beta
  api                  = google_api_gateway_api.api.api_id
  api_config_id_prefix = "api-config"

  openapi_documents {
resource "google_api_gateway_api_config" "api_cfg" {
  provider      = google-beta
  api           = google_api_gateway_api.api_gw.api_id
  api_config_id_prefix = local.api_config_id_prefix
  display_name  = "The Config"
resource "google_api_gateway_api_config" "webhook" {
  provider      = google-beta
  api           = google_api_gateway_api.webhook.api_id
  api_config_id = "tfc-notifications"
resource "google_api_gateway_api_config" "shopping-list-api-config" {
  provider = google-beta
  api =
  api_config_id = "shopping-list-api-config-id"

  openapi_documents {
resource "google_api_gateway_api_config" "api-config" {
  provider      = google-beta
  api           = "pub-api"
  api_config_id = "api-config"

  openapi_documents {

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


The following arguments are supported:

  • openapi_documents - (Required) An OpenAPI Specification Document describing an API. Structure is documented below.

  • api - (Required) The API to attach the config to.

The openapi_documents block supports:

  • document - (Required) The OpenAPI Specification document file. Structure is documented below.

The document block supports:

  • path - (Required) The file path (full or relative path). This is typically the path of the file when it is uploaded.

  • contents - (Required) Base64 encoded content of the file.

  • display_name - (Optional) A user-visible name for the API.

  • labels - (Optional) Resource labels to represent user-provided metadata.

  • gateway_config - (Optional) Immutable. Gateway specific configuration. 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:

  • backend_config - (Required) Backend settings that are applied to all backends of the Gateway. Structure is documented below.

The backend_config block supports:

In addition to the arguments listed above, the following computed attributes are exported:

Explanation in Terraform Registry

An API Configuration is an association of an API Controller Config and a Gateway Config

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 ApiConfig, see:

Frequently asked questions

What is Google API Gateway API Config?

Google API Gateway API Config 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 API Config?

For Terraform, the adispen/gcp-apigateway-custom-domain, femrtnz/google-cloud-api-gateway and binxio/terraform-google-terraform-cloud-notification-sink source code examples are useful. See the Terraform Example section for further details.


Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.