-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayer0.tf
131 lines (104 loc) · 3.33 KB
/
layer0.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
# Variables
variable "auth0_domain" {
description = "Auth0 domain"
}
variable "auth0_client_id" {
description = "Auth0 connection name"
}
variable "auth0_client_secret" {
description = "Auth0 client secret"
}
variable "auth0_proxy_deploy_name" {
description = "Name of the auth0 proxy deploy"
default = "auth0-proxy"
}
variable "auth0_proxy_load_balancer_name" {
description = "Name of the auth0-proxy load balancer"
default = "auth0-proxy"
}
variable "auth0_proxy_service_name" {
description = "Name of the auth0-proxy service"
default = "auth0-proxy"
}
variable "auth0_redirect_uri" {
description = "Auth0 redirect URI (must include protocol, must be in the Auth0 client's allowed callback URLs)"
}
variable "docker_image_tag" {
description = "The Docker image tag for the quintilesims/auth0-proxy image"
default = "latest"
}
variable "layer0_environment_id" {
description = "ID of the Layer0 environment in which to build the service"
}
variable "proxy_load_balancer_port" {
description = "Port of the Layer0 load balancer in front of the protected application"
default = 80
}
variable "proxy_load_balancer_scheme" {
description = "Scheme of the Layer0 load balancer in front of the protected application"
default = "http"
}
variable "proxy_load_balancer_url" {
description = "URL of the Layer0 load balancer in front of the protected application (must NOT include protocol)"
}
variable "session_secret" {
description = "Secret key to encrypt Auth0 sessions"
default = "secret potato"
}
variable "session_timeout" {
description = "Timeout for Auth0 sessions"
default = "1h"
}
variable "ssl_certificate_name" {
description = "SSL certificate name for the web load balancer"
}
# Resources
resource "layer0_load_balancer" "proxy" {
name = "${var.auth0_proxy_load_balancer_name}"
environment = "${var.layer0_environment_id}"
port {
host_port = 443
container_port = 80
protocol = "https"
certificate = "${var.ssl_certificate_name}"
}
}
resource "layer0_service" "proxy" {
name = "${var.auth0_proxy_service_name}"
environment = "${var.layer0_environment_id}"
deploy = "${layer0_deploy.proxy.id}"
load_balancer = "${layer0_load_balancer.proxy.id}"
scale = 1
}
resource "layer0_deploy" "proxy" {
name = "${var.auth0_proxy_deploy_name}"
content = "${data.template_file.proxy.rendered}"
}
data "template_file" "proxy" {
template = "${file("${path.module}/Dockerrun.aws.json")}"
vars {
docker_image_tag = "${var.docker_image_tag}"
proxy_host = "${var.proxy_load_balancer_url}"
proxy_port = "${var.proxy_load_balancer_port}"
proxy_scheme = "${var.proxy_load_balancer_scheme}"
auth0_domain = "${var.auth0_domain}"
auth0_client_id = "${var.auth0_client_id}"
auth0_client_secret = "${var.auth0_client_secret}"
auth0_redirect_uri = "${var.auth0_redirect_uri}"
session_secret = "${var.session_secret}"
session_timeout = "${var.session_timeout}"
}
}
# Outputs
output "load_balancer_id" {
value = "${layer0_load_balancer.proxy.id}"
}
output "load_balancer_url" {
value = "${layer0_load_balancer.proxy.url}"
}
output "service_id" {
value = "${layer0_service.proxy.id}"
}
output "deploy_id" {
value = "${layer0_deploy.proxy.id}"
}