Refacto and add modules
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
locals {
|
||||
app_slug = "${var.instance}${var.component==""?"":"-"}${var.component}"
|
||||
app_slug = "${var.instance}${var.component == "" ? "" : "-"}${var.component}"
|
||||
oauth2_labels = merge(var.labels, {
|
||||
"app.kubernetes.io/component" = "authentik-oauth2"
|
||||
})
|
||||
@@ -20,15 +20,15 @@ data "authentik_scope_mapping" "oauth2" {
|
||||
"goauthentik.io/providers/oauth2/scope-profile"
|
||||
]
|
||||
}
|
||||
data "authentik_flow" "default-authorization-flow" {
|
||||
data "authentik_flow" "default_authorization_flow" {
|
||||
slug = "default-provider-authorization-implicit-consent"
|
||||
}
|
||||
data "authentik_flow" "default-authentication-flow" {
|
||||
data "authentik_flow" "default_authentication_flow" {
|
||||
slug = "default-authentication-flow"
|
||||
}
|
||||
|
||||
resource "authentik_provider_oauth2" "oauth2" {
|
||||
name = "${local.app_slug}"
|
||||
name = local.app_slug
|
||||
client_id = random_password.client_id.result
|
||||
authentication_flow = data.authentik_flow.default-authentication-flow.id
|
||||
authorization_flow = data.authentik_flow.default-authorization-flow.id
|
||||
@@ -64,10 +64,10 @@ resource "kubernetes_secret_v1" "oauth2-client-secret" {
|
||||
}
|
||||
}
|
||||
|
||||
data "kubernetes_secret_v1" "oauth2-client-secret" {
|
||||
depends_on = [kubernetes_secret_v1.oauth2-client-secret]
|
||||
data "kubernetes_secret_v1" "oauth2_client_secret" {
|
||||
depends_on = [kubernetes_secret_v1.oauth2_client_secret]
|
||||
metadata {
|
||||
name = kubernetes_secret_v1.oauth2-client-secret.metadata[0].name
|
||||
name = kubernetes_secret_v1.oauth2_client_secret.metadata[0].name
|
||||
namespace = var.namespace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
output "provider-id" {
|
||||
output "provider_id" {
|
||||
value = authentik_provider_oauth2.oauth2.id
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ output "secret_client_id_name" {
|
||||
value = kubernetes_secret_v1.oauth2-client-secret.metadata[0].name
|
||||
}
|
||||
output "secret_client_secret_name" {
|
||||
value = kubernetes_secret_v1.oauth2-client-secret.metadata[0].name
|
||||
value = kubernetes_secret_v1.oauth2_client_secret.metadata[0].name
|
||||
}
|
||||
output "secret_client_id_key" {
|
||||
value = "client-id"
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.20.0"
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.20.0"
|
||||
}
|
||||
kubectl = {
|
||||
source = "gavinbunney/kubectl"
|
||||
version = "~> 1.14.0"
|
||||
source = "gavinbunney/kubectl"
|
||||
version = "~> 1.14.0"
|
||||
}
|
||||
authentik = {
|
||||
source = "goauthentik/authentik"
|
||||
version = "~> 2023.5.0"
|
||||
source = "goauthentik/authentik"
|
||||
version = "~> 2023.5.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user