google_api_gateway_api_config

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

To get more information about ApiConfig, see:

Open in Cloud Shell

Example Usage - Apigateway Api Config Basic

resource "google_api_gateway_api" "api_cfg" {
  provider = google-beta
  api_id = "my-api"
}

resource "google_api_gateway_api_config" "api_cfg" {
  provider = google-beta
  api = google_api_gateway_api.api_cfg.api_id
  api_config_id = "my-config"

  openapi_documents {
    document {
      path = "spec.yaml"
      contents = filebase64("test-fixtures/openapi.yaml")
    }
  }
  lifecycle {
    create_before_destroy = true
  }
}
Open in Cloud Shell

Example Usage - Apigateway Api Config Grpc

resource "google_api_gateway_api" "api_cfg" {
  provider = google-beta
  api_id = "my-api"
}

resource "google_api_gateway_api_config" "api_cfg" {
  provider = google-beta
  api = google_api_gateway_api.api_cfg.api_id
  api_config_id = "my-config"

  grpc_services {
    file_descriptor_set {
      path = "api_descriptor.pb"
      contents = filebase64("test-fixtures/api_descriptor.pb")
    }
  }
  managed_service_configs {
    path = "api_config.yaml"
    contents = base64encode(<<-EOF
      type: google.api.Service
      config_version: 3
      name: ${google_api_gateway_api.api_cfg.managed_service}
      title: gRPC API example
      apis:
        - name: endpoints.examples.bookstore.Bookstore
      usage:
        rules:
        - selector: endpoints.examples.bookstore.Bookstore.ListShelves
          allow_unregistered_calls: true
      backend:
        rules:
          - selector: "*"
            address: grpcs://example.com
            disable_auth: true

    EOF
    )
  }
  lifecycle {
    create_before_destroy = true
  }
}

Argument Reference

The following arguments are supported:


The gateway_config block supports:

The backend_config block supports:

The openapi_documents block supports:

The document block supports:

The grpc_services block supports:

The file_descriptor_set block supports:

The source block supports:

The managed_service_configs block supports:

Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

ApiConfig can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import ApiConfig using one of the formats above. For example:

import {
  id = "projects/{{project}}/locations/global/apis/{{api}}/configs/{{api_config_id}}"
  to = google_api_gateway_api_config.default
}

When using the terraform import command, ApiConfig can be imported using one of the formats above. For example:

$ terraform import google_api_gateway_api_config.default projects/{{project}}/locations/global/apis/{{api}}/configs/{{api_config_id}}
$ terraform import google_api_gateway_api_config.default {{project}}/{{api}}/{{api_config_id}}
$ terraform import google_api_gateway_api_config.default {{api}}/{{api_config_id}}

User Project Overrides

This resource supports User Project Overrides.