Skip to content

Commit

Permalink
move api gateway definition to dev main
Browse files Browse the repository at this point in the history
  • Loading branch information
maceto committed Mar 1, 2024
1 parent a209e57 commit 4bd10f9
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
158 changes: 152 additions & 6 deletions terraform/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 4bd10f9

Please sign in to comment.