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 = google_api_gateway_api.shopping-list-api-gateway.api_id
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 {
Parameters
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:
google_service_account
- (Required) 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).
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with formatprojects/[[project]]/locations/global/apis/[[api]]/configs/[[api_config_id]]
name
- The resource name of the API Config.service_config_id
- The ID of the associated Service Config (https://cloud.google.com/service-infrastructure/docs/glossary#config).
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:
- API documentation
- How-to Guides
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.