Refacto and add modules
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
locals {
|
||||
forward_outpost_providers = jsondecode(data.http.get_forward_outpost.response_body).results[0].providers
|
||||
forward_outpost_pk = jsondecode(data.http.get_forward_outpost.response_body).results[0].pk
|
||||
app_slug = "${var.instance}${var.component==""?"":"-"}${var.component}"
|
||||
app_slug = "${var.instance}${var.component == "" ? "" : "-"}${var.component}"
|
||||
forward_labels = merge(var.labels, {
|
||||
"app.kubernetes.io/component" = "authentik-forward"
|
||||
})
|
||||
main_group = format("app-%s", var.app_name)
|
||||
external_url = format("https://%s", var.dns_names[0])
|
||||
main_group = format("app-%s", var.app_name)
|
||||
external_url = format("https://%s", var.dns_names[0])
|
||||
rules_icons = [for v in var.dns_names : {
|
||||
"host" = "${v}"
|
||||
"http" = {
|
||||
@@ -19,9 +17,11 @@ locals {
|
||||
}]
|
||||
}
|
||||
}]
|
||||
forward_outpost_providers = jsondecode(data.http.get_forward_outpost.response_body).results[0].providers
|
||||
forward_outpost_pk = jsondecode(data.http.get_forward_outpost.response_body).results[0].pk
|
||||
}
|
||||
|
||||
resource "kubectl_manifest" "prj_ingress_icon" {
|
||||
resource "kubectl_manifest" "ingress_icon" {
|
||||
force_conflicts = true
|
||||
yaml_body = <<-EOF
|
||||
apiVersion: "networking.k8s.io/v1"
|
||||
@@ -39,20 +39,20 @@ resource "kubectl_manifest" "prj_ingress_icon" {
|
||||
EOF
|
||||
}
|
||||
|
||||
data "authentik_flow" "default-authorization-flow" {
|
||||
data "authentik_flow" "default_authorization_flow" {
|
||||
slug = "default-provider-authorization-implicit-consent"
|
||||
}
|
||||
|
||||
resource "authentik_provider_proxy" "prj_forward" {
|
||||
resource "authentik_provider_proxy" "forward" {
|
||||
name = local.app_slug
|
||||
external_host = local.external_url
|
||||
authorization_flow = data.authentik_flow.default-authorization-flow.id
|
||||
authorization_flow = data.authentik_flow.default_authorization_flow.id
|
||||
mode = "forward_single"
|
||||
access_token_validity = var.access_token_validity
|
||||
}
|
||||
|
||||
data "http" "get_forward_outpost" {
|
||||
depends_on = [authentik_provider_proxy.prj_forward]
|
||||
depends_on = [authentik_provider_proxy.forward]
|
||||
url = "http://authentik.${var.domain}-auth.svc/api/v3/outposts/instances/?name__iexact=forward"
|
||||
method = "GET"
|
||||
request_headers = var.request_headers
|
||||
@@ -68,11 +68,11 @@ resource "restapi_object" "forward_outpost_binding" {
|
||||
path = "/outposts/instances/${local.forward_outpost_pk}/"
|
||||
data = jsonencode({
|
||||
name = "forward"
|
||||
providers = contains(local.forward_outpost_providers, authentik_provider_proxy.prj_forward.id) ? local.forward_outpost_providers : concat(local.forward_outpost_providers, [authentik_provider_proxy.prj_forward.id])
|
||||
providers = contains(local.forward_outpost_providers, authentik_provider_proxy.forward.id) ? local.forward_outpost_providers : concat(local.forward_outpost_providers, [authentik_provider_proxy.forward.id])
|
||||
})
|
||||
}
|
||||
|
||||
resource "kubectl_manifest" "prj_middleware" {
|
||||
resource "kubectl_manifest" "middleware" {
|
||||
yaml_body = <<-EOF
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
|
||||
Reference in New Issue
Block a user