diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index 3337293..b0b6a8f 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -54,9 +54,9 @@ jobs: id: init run: terraform init - # - name: Terraform Validate - # id: validate - # run: terraform validate -no-color + - name: Terraform Validate + id: validate + run: terraform validate -no-color - name: Terraform Plan id: plan diff --git a/terraform/dev/main.tf b/terraform/dev/main.tf index ab8805f..8a8cb78 100644 --- a/terraform/dev/main.tf +++ b/terraform/dev/main.tf @@ -12,12 +12,158 @@ terraform { } } -module "backend-api" { - source = "./../modules/api-gateway" - environment = "dev" - project = "httparchive" - region = "us-east1" - service_account_email = var.google_service_account_api_gateway +resource "google_api_gateway_api" "api" { + provider = google-beta + api_id = "api-gw-dev" + display_name = "The dev API Gateway" + project = "httparchive" +} + +# A Configuration, consisting of an OpenAPI specification +resource "google_api_gateway_api_config" "api_config" { + provider = google-beta + api = google_api_gateway_api.api.api_id + api_config_id_prefix = "api" + project = "httparchive" + display_name = "The dev Config" + openapi_documents { + document { + path = "spec.yaml" + contents = base64encode(<<-EOF +swagger: "2.0" +info: + title: reports-backend-api + description: API tech report + version: 1.0.0 +schemes: + - https +produces: + - application/json +paths: + /v1/categories: + get: + summary: categories + operationId: getCategories + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/categories-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/adoption: + get: + summary: adoption + operationId: getadoptionReports + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/adoption-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/page-weight: + get: + summary: pageWeight + operationId: getpageWeight + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/page-weight-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/lighthouse: + get: + summary: lighthouse + operationId: getLighthouseReports + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/lighthouse-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/cwv: + get: + summary: cwv + operationId: getCwv + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/cwvtech-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/ranks: + get: + summary: ranks + operationId: getRanks + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/ranks-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/geos: + get: + summary: geos + operationId: getGeos + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/geos-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String + /v1/technologies: + get: + summary: geos + operationId: getTechnologies + x-google-backend: + address: https://us-east1-httparchive.cloudfunctions.net/technologies-dev + deadline: 60 + # security: + # - api_key: [] + responses: + 200: + description: String +EOF + ) + } + } + gateway_config { + backend_config { + google_service_account = var.google_service_account_api_gateway + } + } +} +# The actual API Gateway +resource "google_api_gateway_gateway" "gateway" { + provider = google-beta + project = "httparchive" + region = "us-east1" + api_config = google_api_gateway_api_config.api_config.id + gateway_id = "dev-gw" + display_name = "devApi Gateway" + labels = { + owner = "tech_report_api" + environment = "dev" + } + depends_on = [google_api_gateway_api_config.api_config] + lifecycle { + replace_triggered_by = [ + google_api_gateway_api_config.api_config + ] + } } module "cwvtech" {