Skip to content

Commit 8014bb7

Browse files
committed
Update Jupyterhub to allow user specification of a base URL and path
for the public facing proxy
1 parent 13f526f commit 8014bb7

File tree

11 files changed

+53
-6
lines changed

11 files changed

+53
-6
lines changed

dev_env/cognito/cognito_client.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ resource "aws_cognito_user_pool_client" "jupyter_cognito_client" {
66
name = "${var.resource_prefix}-jupyter-${var.tenant_identifier}-client"
77
user_pool_id = tolist(data.aws_cognito_user_pools.unity_user_pool.ids)[0]
88

9-
callback_urls = var.jupyter_base_url != null ? ["${var.jupyter_base_url}/hub/oauth_callback"] : null
10-
logout_urls = var.jupyter_base_url != null ? ["${var.jupyter_base_url}/hub/login/oauth_callback/logout"] : null
9+
callback_urls = var.jupyter_base_url != null ? ["${var.jupyter_base_url}/${var.jupyter_base_path}/hub/oauth_callback"] : null
10+
logout_urls = var.jupyter_base_url != null ? ["${var.jupyter_base_url}/${var.jupyter_base_path}/hub/login/oauth_callback/logout"] : null
1111

1212
allowed_oauth_flows = var.jupyter_base_url != null ? ["code"] : null
1313
allowed_oauth_flows_user_pool_client = var.jupyter_base_url != null ? true : null

dev_env/cognito/jupyter_url_env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ fi
1313
cd $(realpath $script_dir/..)/jupyterhub
1414

1515
jupyter_url=$(terraform output -raw jupyter_base_url)
16+
jupyter_url=$(terraform output -raw jupyter_base_path)
1617

1718
echo "export TF_VAR_jupyter_base_url=\"${jupyter_url}\""
19+
echo "export TF_VAR_jupyter_base_path=\"${jupyter_path}\""

dev_env/cognito/local_variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ variable "jupyter_base_url" {
99
type = string
1010
default = null
1111
}
12+
13+
variable "jupyter_base_path" {
14+
description = "Base path after URL of the JupyterHub instance"
15+
type = string
16+
default = null
17+
}

dev_env/jupyterhub/frontend.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ module "frontend" {
3636
load_balancer_port = var.load_balancer_port
3737
jupyter_proxy_port = var.jupyter_proxy_port
3838

39+
jupyter_base_url = var.jupyter_base_url
40+
jupyter_base_path = var.jupyter_base_path
41+
3942
vpc_id = data.aws_ssm_parameter.vpc_id.value
4043
lb_subnet_ids = local.subnet_map["public"]
4144
security_group_id = aws_security_group.jupyter_lb_sg.id

dev_env/jupyterhub/jupyter_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ hub:
6464
binaryData: ${unity_auth_py}
6565
config:
6666
OAuthenticator:
67-
oauth_callback_url: ${jupyter_base_url}/hub/oauth_callback
67+
oauth_callback_url: ${oauth_callback_url}
6868
client_id: ${oauth_client_id}
6969
client_secret: ${oauth_client_secret}
7070
admin_users: ${admin_users}

dev_env/jupyterhub/jupyter_helm.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ resource "helm_release" "jupyter_helm" {
1313
cognito_oauth_base_url = var.cognito_oauth_base_url
1414
oauth_client_id = var.cognito_oauth_client_id
1515
oauth_client_secret = var.cognito_oauth_client_secret
16+
oauth_callback_url = module.frontend.jupyter_base_path != "" ? "${module.frontend.jupyter_base_url}/${module.frontend.jupyter_base_path}/hub/oauth_callback" : "${module.frontend.jupyter_base_url}/hub/oauth_callback"
1617
jupyter_base_path = module.frontend.jupyter_base_path != "" ? "/${module.frontend.jupyter_base_path}/" : "/"
1718
jupyter_base_url = module.frontend.jupyter_base_url
1819
jupyter_proxy_port = var.jupyter_proxy_port

dev_env/jupyterhub/jupyter_variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ variable "jupyter_proxy_port" {
1616
default = 32232
1717
}
1818

19+
# Public facing URL minus jupyter_base_path
20+
# Do not supply trailing slashes
21+
variable "jupyter_base_url" {
22+
description = "Base URL minus path for Jupyter as accessed at its public facing location"
23+
type = string
24+
default = null
25+
}
26+
27+
# Base path for jupyter appended to base path of frontend module
28+
# Do not supply leading or trailing slashes
29+
variable "jupyter_base_path" {
30+
description = "Base path for Jupyter as accessed at its public facing location"
31+
type = string
32+
default = ""
33+
}
34+
1935
variable "cognito_oauth_base_url" {
2036
description = "Base URL for using the Cognito Open Auth 2 interface"
2137
type = string

dev_env/jupyterhub/modules/load_balancer/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ resource "aws_lb_target_group" "jupyter_alb_target_group" {
2626

2727
# alter the destination of the health check
2828
health_check {
29-
path = "/hub/health"
29+
path = var.jupyter_base_path != "" ? "/${var.jupyter_base_path}/hub/health" : "/hub/health"
3030
port = var.jupyter_proxy_port
3131
}
3232
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
output "jupyter_base_path" {
2-
value = ""
2+
value = var.jupyter_base_path
33
}
44

55
output "jupyter_base_url" {
6-
value = "https://${aws_lb.jupyter_alb.dns_name}:${var.load_balancer_port}"
6+
value = var.jupyter_base_url != null ? var.jupyter_base_url : "https://${aws_lb.jupyter_alb.dns_name}:${var.load_balancer_port}"
77
}

dev_env/jupyterhub/modules/load_balancer/variables.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ variable "jupyter_proxy_port" {
2222
type = number
2323
}
2424

25+
# Do not supply trailing slashes
26+
variable "jupyter_base_url" {
27+
description = "Base URL minus path for Jupyter as accessed at its public facing location"
28+
type = string
29+
default = null
30+
}
31+
32+
# Do not include leading or training slashes
33+
variable "jupyter_base_path" {
34+
description = "Base path for Jupyter as accessed at its public facing location"
35+
type = string
36+
default = ""
37+
}
38+
2539
###################################
2640
# Frontend module common variables
2741

0 commit comments

Comments
 (0)