google_api_gateway_test/terraform/gateway.tf
2024-10-15 22:30:51 -04:00

56 lines
1.3 KiB
HCL

resource "google_api_gateway_api" "api" {
provider = google-beta
project = google_project.project.project_id
api_id = "the-gateway"
depends_on = [google_project_service.service["apigateway"], ]
}
resource "google_api_gateway_api_config" "api_config" {
provider = google-beta
project = google_project.project.project_id
api = google_api_gateway_api.api.api_id
api_config_id = "api-config"
openapi_documents {
document {
path = "spec.yaml"
contents = base64encode(<<-EOF
swagger: "2.0"
info:
title: the-gateway foo
description: "Run auth through Google API Gateway."
version: "1.0.0"
schemes:
- "https"
produces:
- application/json
x-google-backend:
address: ${google_cloud_run_v2_service.api_server.uri}
paths:
"/":
get:
description: "Hello World."
operationId: "helloWorld"
responses:
200:
description: "Success."
schema:
type: string
EOF
)
}
}
}
resource "google_api_gateway_gateway" "gateway" {
provider = google-beta
project = google_project.project.project_id
api_config = google_api_gateway_api_config.api_config.id
gateway_id = "gateway-to-the-api"
}
output "gateway_address" {
value = google_api_gateway_gateway.gateway.default_hostname
}