Skip to content

Commit

Permalink
fix: configure OIDC after bootstrap
Browse files Browse the repository at this point in the history
When the OIDC issuer runs on the devops-stack, it cannot be configured
at bootstrap time.
  • Loading branch information
John Doe authored and fsismondi committed May 19, 2022
1 parent 8ae2272 commit a18b7ad
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
8 changes: 0 additions & 8 deletions bootstrap/local.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ locals {

argocd_server_secretkey = var.argocd_server_secretkey == null ? random_password.argocd_server_secretkey.result : var.argocd_server_secretkey

oidc_default = {
client_id = "alive"
client_secret = "alive"
issuer_url = "http://z"
}

oidc = merge(local.oidc_default, var.oidc)

argocd_default = {
namespace = "argocd"
domain = "argocd.apps.${var.cluster_name}.${var.base_domain}"
Expand Down
19 changes: 2 additions & 17 deletions bootstrap/values.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ locals {
argocdServerAdminPassword = "${htpasswd_password.argocd_server_admin.bcrypt}"
argocdServerAdminPasswordMtime = "2020-07-23T11:31:23Z"
extra = {
"oidc.default.clientSecret" = "${replace(local.oidc.client_secret, "\\\"", "\"")}"
"accounts.pipeline.tokens" = "${replace(local.argocd.accounts_pipeline_tokens, "\\\"", "\"")}"
"server.secretkey" = "${replace(local.argocd.server_secretkey, "\\\"", "\"")}"
"accounts.pipeline.tokens" = "${replace(local.argocd.accounts_pipeline_tokens, "\\\"", "\"")}"
"server.secretkey" = "${replace(local.argocd.server_secretkey, "\\\"", "\"")}"
}
}
})
Expand Down Expand Up @@ -66,20 +65,6 @@ locals {
args: ["echo \"$HELM_VALUES\" | helm template . --name-template $ARGOCD_APP_NAME --namespace $ARGOCD_APP_NAMESPACE $HELM_ARGS -f - --include-crds > all.yaml && kustomize build"]
EOT
url = "https://${local.argocd.domain}"
# TODO check and potentially change the following var references
"oidc.config" = <<-EOT
name: OIDC
issuer: "${replace(local.oidc.issuer_url, "\"", "\\\"")}"
clientID: "${replace(local.oidc.client_id, "\"", "\\\"")}"
clientSecret: "${local.oidc.client_secret}"
requestedIDTokenClaims:
groups:
essential: true
requestedScopes:
- openid
- profile
- email
EOT
}
ingress = {
enabled = true
Expand Down
12 changes: 11 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ resource "null_resource" "dependencies" {
triggers = var.dependency_ids
}

locals {
oidc_default = {
client_id = "alive"
client_secret = "alive"
issuer_url = "http://z"
}

oidc = merge(local.oidc_default, var.oidc)
}

resource "argocd_project" "this" {
metadata {
name = "argocd"
Expand Down Expand Up @@ -32,7 +42,7 @@ resource "argocd_project" "this" {
}

data "utils_deep_merge_yaml" "values" {
input = [for i in concat(var.bootstrap_values, var.helm_values) : yamlencode(i)]
input = [for i in concat(var.bootstrap_values, local.helm_values, var.helm_values) : yamlencode(i)]
}

resource "argocd_application" "this" {
Expand Down
31 changes: 31 additions & 0 deletions values.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
locals {
helm_values = [{
argo-cd = {
configs = {
secret = {
extra = {
"oidc.default.clientSecret" = "${replace(local.oidc.client_secret, "\\\"", "\"")}"
}
}
}
server = {
config = {
# TODO check and potentially change the following var references
"oidc.config" = <<-EOT
name: OIDC
issuer: "${replace(local.oidc.issuer_url, "\"", "\\\"")}"
clientID: "${replace(local.oidc.client_id, "\"", "\\\"")}"
clientSecret: "${local.oidc.client_secret}"
requestedIDTokenClaims:
groups:
essential: true
requestedScopes:
- openid
- profile
- email
EOT
}
}
}
}]
}

0 comments on commit a18b7ad

Please sign in to comment.