Skip to content

Commit f331d4e

Browse files
committed
update Terraform configurations and clean up unused variables
1 parent b312132 commit f331d4e

File tree

7 files changed

+23
-90
lines changed

7 files changed

+23
-90
lines changed

terraform/dev/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
terraform {
2+
required_version = ">=1.11.0"
3+
24
backend "gcs" {
35
bucket = "tfstate-httparchive"
46
prefix = "tech-report-apis/dev"
57
}
68
required_providers {
79
docker = {
810
source = "kreuzwerker/docker"
9-
version = "3.6.2"
11+
version = ">=3.6.2"
1012
}
1113
google = {
1214
source = "hashicorp/google"
15+
version = ">=7.13.0"
1316
}
1417
}
1518
}
1619

1720
provider "google" {
1821
project = var.project
1922
region = var.region
20-
request_timeout = "60m"
2123
}
2224

2325
module "endpoints" {
2426
source = "./../modules/run-service"
25-
entry_point = "app"
2627
project = var.project
2728
environment = var.environment
2829
source_directory = "../../src"
29-
function_name = "tech-report-api"
30+
service_name = "report-api"
3031
region = var.region
31-
min_instances = var.min_instances
3232
environment_variables = {
3333
"PROJECT" = var.project
3434
"DATABASE" = var.project_database

terraform/dev/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,3 @@ 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 "min_instances" {
21-
description = "(Optional) The limit on the minimum number of function instances that may coexist at a given time."
22-
type = number
23-
default = 0
24-
}

terraform/modules/cdn-glb/variables.tf

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ variable "project" {
22
description = "The GCP project ID"
33
type = string
44
}
5-
65
variable "region" {
76
description = "The GCP region for the Cloud Run service"
87
type = string
@@ -12,23 +11,19 @@ variable "environment" {
1211
description = "The 'Environment' that is being created/deployed. Applied as a suffix to many resources."
1312
type = string
1413
}
15-
1614
variable "cloud_run_service_name" {
1715
description = "The name of the Cloud Run service to route traffic to"
1816
type = string
1917
}
20-
2118
variable "domain" {
2219
description = "The domain name for the SSL certificate"
2320
type = string
2421
}
25-
2622
variable "name_prefix" {
2723
description = "Prefix for naming resources"
2824
type = string
2925
default = "report-api"
3026
}
31-
3227
variable "load_balancer_name" {
3328
description = "Name for the load balancer (URL map)"
3429
type = string
@@ -40,37 +35,31 @@ variable "enable_cdn" {
4035
type = bool
4136
default = true
4237
}
43-
4438
variable "cdn_cache_mode" {
4539
description = "CDN cache mode (CACHE_ALL_STATIC, USE_ORIGIN_HEADERS, FORCE_CACHE_ALL)"
4640
type = string
4741
default = "CACHE_ALL_STATIC"
4842
}
49-
5043
variable "cdn_default_ttl" {
5144
description = "Default TTL for cached content in seconds"
5245
type = number
5346
default = 2592000 # 30 days
5447
}
55-
5648
variable "cdn_max_ttl" {
5749
description = "Maximum TTL for cached content in seconds"
5850
type = number
5951
default = 2592000 # 30 days
6052
}
61-
6253
variable "cdn_client_ttl" {
6354
description = "Client TTL for cached content in seconds (browser cache)"
6455
type = number
6556
default = 28800 # 8 hours
6657
}
67-
6858
variable "cdn_serve_while_stale" {
6959
description = "Time to serve stale content while revalidating in seconds"
7060
type = number
7161
default = 0
7262
}
73-
7463
variable "cdn_negative_caching" {
7564
description = "Whether to enable negative caching"
7665
type = bool
@@ -83,39 +72,23 @@ variable "neg_name" {
8372
type = string
8473
default = null
8574
}
86-
8775
variable "backend_service_name" {
8876
description = "Name for the backend service (overrides name_prefix)"
8977
type = string
9078
default = null
9179
}
92-
9380
variable "ssl_cert_name" {
9481
description = "Name for the SSL certificate (overrides name_prefix-ssl-cert)"
9582
type = string
9683
default = null
9784
}
98-
9985
variable "https_proxy_name" {
10086
description = "Name for the HTTPS proxy (overrides load_balancer_name-target-proxy)"
10187
type = string
10288
default = null
10389
}
104-
105-
variable "http_proxy_name" {
106-
description = "Name for the HTTP proxy"
107-
type = string
108-
default = null
109-
}
110-
11190
variable "https_forwarding_rule_name" {
11291
description = "Name for the HTTPS forwarding rule"
11392
type = string
11493
default = null
11594
}
116-
117-
variable "http_forwarding_rule_name" {
118-
description = "Name for the HTTP forwarding rule"
119-
type = string
120-
default = null
121-
}

terraform/modules/run-service/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ terraform {
22
required_providers {
33
docker = {
44
source = "kreuzwerker/docker"
5-
version = "3.6.2"
6-
}
7-
google = {
8-
source = "hashicorp/google"
9-
}
10-
archive = {
11-
source = "hashicorp/archive"
125
}
136
}
147
}

terraform/modules/run-service/variables.tf

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
1-
variable "secrets" {
2-
default = []
1+
variable "project" {
2+
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
3+
type = string
34
}
45
variable "region" {
56
default = "us-central1"
67
type = string
78
}
8-
variable "service_name" {
9-
description = "Optional: Can be used to create more than function from the same package"
10-
type = string
11-
default = "report-api"
12-
}
139
variable "environment" {
1410
description = "The 'Environment' that is being created/deployed. Applied as a suffix to many resources."
1511
type = string
1612
}
17-
variable "source_directory" {
18-
description = "The folder of the package containing function that will be executed when the Google Cloud Function is triggered!"
13+
variable "service_name" {
14+
description = "Optional: Can be used to create more than function from the same package"
1915
type = string
2016
}
21-
variable "function_name" {
22-
description = "Optional: Can be used to create more than function from the same package"
17+
variable "source_directory" {
18+
description = "The folder of the package containing function that will be executed when the Google Cloud Function is triggered!"
2319
type = string
2420
}
2521
variable "entry_point" {
2622
description = "The entry point; This is either what is registered with 'http' or exported from the code as a handler!"
2723
type = string
24+
default = "app"
2825
}
2926
variable "available_memory" {
3027
default = "1Gi"
@@ -46,10 +43,7 @@ variable "vpc_connector_egress_settings" {
4643
default = null
4744
description = "The egress settings for the connector, controlling what traffic is diverted through it. Allowed values are ALL_TRAFFIC and PRIVATE_RANGES_ONLY. Defaults to PRIVATE_RANGES_ONLY. If unset, this field preserves the previously set value."
4845
}
49-
variable "project" {
50-
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
51-
type = string
52-
}
46+
5347
variable "timeout" {
5448
default = "60s"
5549
type = string
@@ -60,16 +54,16 @@ variable "service_account_email" {
6054
description = "Service account who can invoke this function. This is required!"
6155
default = "cloud-function@httparchive.iam.gserviceaccount.com"
6256
}
57+
variable "min_instances" {
58+
description = "(Optional) The limit on the minimum number of function instances that may coexist at a given time."
59+
type = number
60+
default = 0
61+
}
6362
variable "max_instances" {
6463
default = 2
6564
type = number
6665
description = "(Optional) The limit on the maximum number of function instances that may coexist at a given time."
6766
}
68-
variable "min_instances" {
69-
description = "(Optional) The limit on the minimum number of function instances that may coexist at a given time."
70-
type = number
71-
default = 1
72-
}
7367
variable "max_instance_request_concurrency" {
7468
description = "(Optional) The limit on the maximum number of requests that an instance can handle simultaneously. This can be used to control costs when scaling. Defaults to 1."
7569
type = number

terraform/prod/main.tf

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@ terraform {
1717
provider "google" {
1818
project = var.project
1919
region = var.region
20-
request_timeout = "60m"
2120
}
2221

2322
module "endpoints" {
2423
source = "./../modules/run-service"
25-
entry_point = "app"
2624
project = var.project
2725
environment = var.environment
2826
source_directory = "../../src"
29-
function_name = "tech-report-api"
27+
service_name = "report-api"
3028
region = var.region
31-
min_instances = var.min_instances
29+
min_instances = 1
3230
environment_variables = {
3331
"PROJECT" = var.project
3432
"DATABASE" = var.project_database
@@ -43,16 +41,13 @@ module "cdn_glb" {
4341
environment = var.environment
4442

4543
cloud_run_service_name = module.endpoints.name
46-
domain = var.cdn_domain
47-
load_balancer_name = var.load_balancer_name
44+
domain = "cdn.httparchive.org"
45+
load_balancer_name = "httparchive-load-balancer"
4846
name_prefix = "report-api"
4947

50-
# Resource name overrides to match existing resources
5148
neg_name = "report-api-prod"
5249
backend_service_name = "report-api"
5350
ssl_cert_name = "google-managed2"
5451
https_proxy_name = "httparchive-load-balancer-target-proxy-2"
55-
http_proxy_name = "httparchive-load-balancer-target-proxy"
5652
https_forwarding_rule_name = "httparchive-load-balancer-forwarding-rule-2"
57-
http_forwarding_rule_name = "httparchive-load-balancer-forwarding-rule"
5853
}

terraform/prod/variables.tf

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,3 @@ variable "project_database" {
1717
description = "The database name"
1818
default = "tech-report-api-prod"
1919
}
20-
variable "min_instances" {
21-
description = "(Optional) The limit on the minimum number of function instances that may coexist at a given time."
22-
type = number
23-
default = 1
24-
}
25-
26-
variable "cdn_domain" {
27-
description = "The domain name for the CDN SSL certificate"
28-
type = string
29-
default = "cdn.httparchive.org"
30-
}
31-
32-
variable "load_balancer_name" {
33-
description = "The name for the load balancer (URL map)"
34-
type = string
35-
default = "httparchive-load-balancer"
36-
}

0 commit comments

Comments
 (0)