-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapigateway.tf
132 lines (113 loc) · 3.32 KB
/
apigateway.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#-----------------
# Python registry
#-----------------
resource "google_artifact_registry_repository" "py-repos" {
location = var.region
repository_id = "python-repos"
description = "Python Repositoty"
format = "python"
}
#-----------------
# Docker registry
#-----------------
resource "google_artifact_registry_repository" "docker-repo" {
location = var.region
repository_id = "docker-repository"
description = "Docker repository"
format = "DOCKER"
}
#---------------------------
# App Gateway
#---------------------------
resource "google_api_gateway_api" "api_gw" {
provider = google-beta
api_id = "api"
}
resource "google_api_gateway_api_config" "api_gw_config" {
provider = google-beta
api = google_api_gateway_api.api_gw.api_id
#api_config_id = "api-config"
openapi_documents {
document {
path = "spec.yaml"
contents = filebase64("./apigateway/openapi.yaml")
}
}
lifecycle {
create_before_destroy = true
}
}
resource "google_api_gateway_gateway" "api_gw_gw" {
provider = google-beta
api_config = google_api_gateway_api_config.api_gw_config.id
gateway_id = "api-gateway"
}
#---------------
# LB
#---------------
resource "google_compute_region_network_endpoint_group" "api-gw_neg" {
provider = google-beta
name = "neg-gw"
network_endpoint_type = "SERVERLESS"
region = var.region
serverless_deployment {
platform = "apigateway.googleapis.com"
resource = google_api_gateway_gateway.api_gw_gw.gateway_id
}
}
resource "google_compute_global_address" "api-gw-address" {
name = "lb-api-gw-static-ip"
ip_version = "IPV4"
}
module "lb-http-api-gw" {
source = "GoogleCloudPlatform/lb-http/google//modules/serverless_negs"
version = "~> 9.0.0"
project = var.project_id
name = "apigw"
managed_ssl_certificate_domains = ["api.nine30.com"]
ssl = true
https_redirect = false
address = google_compute_global_address.api-gw-address.address
create_address = false
http_forward = false
backends = {
default = {
groups = [
{
group = google_compute_region_network_endpoint_group.api-gw_neg.id
}
]
protocol = "HTTP"
port_name = "http"
description = null
enable_cdn = false
custom_request_headers = null
custom_response_headers = null
security_policy = null
edge_security_policy = null
compression_mode = null
connection_draining_timeout_sec = null
session_affinity = null
affinity_cookie_ttl_sec = null
log_config = {
enable = true
sample_rate = 1.0
}
iap_config = {
enable = false
oauth2_client_id = null
oauth2_client_secret = null
}
description = null
custom_request_headers = null
security_policy = null
}
}
}
#---------------
# Tasks
#---------------
resource "google_cloud_tasks_queue" "rebalance_queue" {
name = var.rebalance_queue
location = var.region
}