Skip to content

Commit 233925e

Browse files
committed
Merge branch 'main' into tech-sort-and-versions
2 parents c90362d + f331d4e commit 233925e

File tree

7 files changed

+34
-85
lines changed

7 files changed

+34
-85
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-
service_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-dev"
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: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
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
4+
}
15
variable "region" {
26
default = "us-central1"
37
type = string
48
}
5-
variable "service_name" {
6-
description = "Optional: Can be used to create more than function from the same package"
7-
type = string
8-
default = "report-api"
9-
}
109
variable "environment" {
1110
description = "The 'Environment' that is being created/deployed. Applied as a suffix to many resources."
1211
type = string
1312
default = "dev"
1413
}
15-
variable "source_directory" {
16-
description = "The folder of the package containing function that will be executed when the Google Cloud Function is triggered!"
14+
variable "service_name" {
15+
description = "Optional: Can be used to create more than function from the same package"
1716
type = string
1817
}
1918
variable "service_name" {
2019
description = "Optional: Can be used to create more than function from the same package"
2120
type = string
2221
}
22+
variable "source_directory" {
23+
description = "The folder of the package containing function that will be executed when the Google Cloud Function is triggered!"
24+
type = string
25+
}
2326
variable "entry_point" {
2427
description = "The entry point; This is either what is registered with 'http' or exported from the code as a handler!"
2528
type = string
29+
default = "app"
2630
}
2731
variable "available_memory" {
2832
default = "1Gi"
@@ -34,11 +38,17 @@ variable "available_cpu" {
3438
type = string
3539
description = "The amount of CPU for the Cloud Function"
3640
}
37-
variable "project" {
38-
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
41+
variable "ingress_settings" {
3942
type = string
40-
default = "httparchive"
43+
default = "ALLOW_ALL"
44+
description = "String value that controls what traffic can reach the function. Allowed values are ALLOW_ALL, ALLOW_INTERNAL_AND_GCLB and ALLOW_INTERNAL_ONLY. Check ingress documentation to see the impact of each settings value. Changes to this field will recreate the cloud function."
4145
}
46+
variable "vpc_connector_egress_settings" {
47+
type = string
48+
default = null
49+
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."
50+
}
51+
4252
variable "timeout" {
4353
default = "60s"
4454
type = string
@@ -49,16 +59,16 @@ variable "service_account_email" {
4959
description = "Service account who can invoke this function. This is required!"
5060
default = "[email protected]"
5161
}
62+
variable "min_instances" {
63+
description = "(Optional) The limit on the minimum number of function instances that may coexist at a given time."
64+
type = number
65+
default = 0
66+
}
5267
variable "max_instances" {
5368
default = 2
5469
type = number
5570
description = "(Optional) The limit on the maximum number of function instances that may coexist at a given time."
5671
}
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 = 1
61-
}
6272
variable "max_instance_request_concurrency" {
6373
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."
6474
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-
service_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)