Skip to content

Commit 35bc05e

Browse files
committed
refactor: remove API Gateway resources and service account variables from Terraform configuration
1 parent 0fa8f61 commit 35bc05e

File tree

9 files changed

+2
-501
lines changed

9 files changed

+2
-501
lines changed

terraform/dev/main.tf

Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -11,149 +11,6 @@ provider "google" {
1111
request_timeout = "60m"
1212
}
1313

14-
resource "google_api_gateway_api" "api" {
15-
provider = google-beta
16-
api_id = "reports-api-dev"
17-
display_name = "Reports API Gateway DEV"
18-
project = var.project
19-
}
20-
21-
resource "google_api_gateway_api_config" "api_config" {
22-
provider = google-beta
23-
api = google_api_gateway_api.api.api_id
24-
api_config_id_prefix = "reports-api-config-dev"
25-
project = var.project
26-
display_name = "Reports API Config DEV"
27-
openapi_documents {
28-
document {
29-
path = "spec.yaml"
30-
contents = base64encode(<<-EOF
31-
swagger: "2.0"
32-
info:
33-
title: reports_api_config_dev
34-
version: 1.0.0
35-
schemes:
36-
- https
37-
produces:
38-
- application/json
39-
x-google-backend:
40-
address: https://us-central1-httparchive.cloudfunctions.net/tech-report-api-dev
41-
deadline: 60
42-
path_translation: APPEND_PATH_TO_ADDRESS
43-
protocol: h2
44-
paths:
45-
/v1/categories:
46-
get:
47-
summary: categories
48-
operationId: getCategories
49-
responses:
50-
200:
51-
description: String
52-
/v1/adoption:
53-
get:
54-
summary: adoption
55-
operationId: getAdoptionReports
56-
responses:
57-
200:
58-
description: String
59-
/v1/page-weight:
60-
get:
61-
summary: pageWeight
62-
operationId: getPageWeightReports
63-
responses:
64-
200:
65-
description: String
66-
/v1/lighthouse:
67-
get:
68-
summary: lighthouse
69-
operationId: getLighthouseReports
70-
responses:
71-
200:
72-
description: String
73-
/v1/cwv:
74-
get:
75-
summary: cwv
76-
operationId: getCWVReports
77-
responses:
78-
200:
79-
description: String
80-
/v1/ranks:
81-
get:
82-
summary: ranks
83-
operationId: getRanks
84-
responses:
85-
200:
86-
description: String
87-
/v1/geos:
88-
get:
89-
summary: geos
90-
operationId: getGeos
91-
responses:
92-
200:
93-
description: String
94-
/v1/technologies:
95-
get:
96-
summary: technologies
97-
operationId: getTechnologies
98-
responses:
99-
200:
100-
description: String
101-
/v1/audits:
102-
get:
103-
summary: audits
104-
operationId: getAuditReports
105-
responses:
106-
200:
107-
description: String
108-
/v1/versions:
109-
get:
110-
summary: versions
111-
operationId: getVersions
112-
responses:
113-
200:
114-
description: String
115-
/v1/static/{filePath=**}:
116-
get:
117-
summary: static
118-
operationId: getStaticFile
119-
parameters:
120-
- name: filePath
121-
in: path
122-
required: true
123-
type: string
124-
responses:
125-
200:
126-
description: File content
127-
EOF
128-
)
129-
}
130-
}
131-
gateway_config {
132-
backend_config {
133-
google_service_account = var.google_service_account_api_gateway
134-
}
135-
}
136-
}
137-
138-
resource "google_api_gateway_gateway" "gateway" {
139-
provider = google-beta
140-
project = var.project
141-
region = var.region
142-
api_config = google_api_gateway_api_config.api_config.id
143-
gateway_id = "reports-dev"
144-
display_name = "Reports API Gateway DEV"
145-
labels = {
146-
owner = "tech_report_api"
147-
environment = var.environment
148-
}
149-
depends_on = [google_api_gateway_api_config.api_config]
150-
lifecycle {
151-
replace_triggered_by = [
152-
google_api_gateway_api_config.api_config
153-
]
154-
}
155-
}
156-
15714
module "endpoints" {
15815
source = "./../modules/run-service"
15916
entry_point = "app"
@@ -162,8 +19,6 @@ module "endpoints" {
16219
source_directory = "../../src"
16320
function_name = "tech-report-api"
16421
region = var.region
165-
service_account_email = var.google_service_account_cloud_functions
166-
service_account_api_gateway = var.google_service_account_api_gateway
16722
min_instances = var.min_instances
16823
environment_variables = {
16924
"PROJECT" = var.project

terraform/dev/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ variable "project_database" {
1717
description = "The database name"
1818
default = "tech-report-api-prod" // TODO: Update this to the DEV database name
1919
}
20-
variable "google_service_account_cloud_functions" {
21-
type = string
22-
description = "Service account for Cloud Functions"
23-
default = "cloud-function@httparchive.iam.gserviceaccount.com"
24-
}
25-
variable "google_service_account_api_gateway" {
26-
type = string
27-
description = "Service account for API Gateway"
28-
default = "api-gateway@httparchive.iam.gserviceaccount.com"
29-
}
3020
variable "min_instances" {
3121
description = "(Optional) The limit on the minimum number of function instances that may coexist at a given time."
3222
type = number

terraform/modules/api-gateway/main.tf

Lines changed: 0 additions & 50 deletions
This file was deleted.

terraform/modules/api-gateway/networking.tf

Lines changed: 0 additions & 86 deletions
This file was deleted.

terraform/modules/api-gateway/variables.tf

Lines changed: 0 additions & 16 deletions
This file was deleted.

terraform/modules/run-service/main.tf

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,46 +53,12 @@ resource "google_cloudfunctions2_function" "function" {
5353
]
5454
}
5555

56-
resource "google_cloudfunctions2_function_iam_member" "variable_service_account_function_invoker" {
57-
project = google_cloudfunctions2_function.function.project
58-
location = google_cloudfunctions2_function.function.location
59-
cloud_function = google_cloudfunctions2_function.function.name
60-
role = "roles/cloudfunctions.invoker"
61-
member = "serviceAccount:${var.service_account_email}"
62-
depends_on = [google_cloudfunctions2_function.function]
63-
}
64-
6556
data "google_cloud_run_service" "run-service" {
6657
name = google_cloudfunctions2_function.function.name
6758
location = var.region
6859
depends_on = [google_cloudfunctions2_function.function]
6960
}
7061

71-
resource "google_cloud_run_v2_service_iam_member" "variable_service_account_run_invoker" {
72-
project = var.project
73-
location = var.region
74-
name = data.google_cloud_run_service.run-service.name
75-
role = "roles/run.invoker"
76-
member = "serviceAccount:${var.service_account_email}"
77-
}
78-
79-
resource "google_cloudfunctions2_function_iam_member" "api_gw_variable_service_account_function_invoker" {
80-
project = google_cloudfunctions2_function.function.project
81-
location = google_cloudfunctions2_function.function.location
82-
cloud_function = google_cloudfunctions2_function.function.name
83-
role = "roles/cloudfunctions.invoker"
84-
member = "serviceAccount:${var.service_account_api_gateway}"
85-
depends_on = [google_cloudfunctions2_function.function]
86-
}
87-
88-
resource "google_cloud_run_v2_service_iam_member" "api_gw_variable_service_account_run_invoker" {
89-
project = var.project
90-
location = var.region
91-
name = data.google_cloud_run_service.run-service.name
92-
role = "roles/run.invoker"
93-
member = "serviceAccount:${var.service_account_api_gateway}"
94-
}
95-
9662
resource "google_cloud_run_v2_service_iam_member" "allow_unauthenticated" {
9763
project = var.project
9864
location = var.region

terraform/modules/run-service/variables.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ variable "timeout" {
5353
variable "service_account_email" {
5454
type = string
5555
description = "Service account who can invoke this function. This is required!"
56-
}
57-
variable "service_account_api_gateway" {
58-
type = string
59-
description = "API Gateway service account who can invoke this function. This is required!"
56+
default = "cloud-function@httparchive.iam.gserviceaccount.com"
6057
}
6158
variable "max_instances" {
6259
default = 2

0 commit comments

Comments
 (0)