Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally avoid Keycloak requests in provider setup #136

Merged
merged 7 commits into from
Jul 18, 2019

Conversation

ltscif
Copy link
Contributor

@ltscif ltscif commented Jul 17, 2019

An extension of #89, this adds the option to disable initial login, defaulting to false. This will allow Keycloak itself to be provisioned via terraform and used as input to this provider.

Example:

data "helm_repository" "codecentric" {
  name = "codecentric"
  url  = "https://codecentric.github.io/helm-charts"
}

resource "helm_release" "keycloak" {
  repository = data.helm_repository.codecentric.metadata[0].name
  name       = "keycloak"
  namespace  = "keycloak"
  chart      = "keycloak"
  version    = "5.0.1"
}

resource "random_string" "keycloak_admin_password" {
  length  = 10
  special = false
}

provider "keycloak" {
  client_id     = "admin-cli"
  username      = "keycloak"
  password      = random_string.keycloak_admin_password.result
  url           = "http://keycloak.localhost"
  initial_login = false
}

resource "keycloak_realm" "realm" {
  depends_on = [helm_release.keycloak]
  realm  = "myrealm"
  enabled = true
}

@mrparkers
Copy link
Owner

Here are the differences I can see for the unhappy path when running this change locally:

with initial_login = true:

Error: Error refreshing state: 1 error(s) occurred:

* provider.keycloak: Post http://localhost:8080/auth/realms/master/protocol/openid-connect/token: dial tcp [::1]:8080: connect: connection refused

with initial_login = false:

keycloak_realm.test: Refreshing state... (ID: test)
keycloak_custom_user_federation.custom: Refreshing state... (ID: 7f7abf96-f377-43cc-9e23-5a3696c5df5c)

Error: Error refreshing state: 2 error(s) occurred:

* keycloak_realm.test: 1 error(s) occurred:

* keycloak_realm.test: keycloak_realm.test: error logging in: Post http://localhost:8080/auth/realms/master/protocol/openid-connect/token: dial tcp [::1]:8080: connect: connection refused
* keycloak_custom_user_federation.custom: 1 error(s) occurred:

* keycloak_custom_user_federation.custom: keycloak_custom_user_federation.custom: Get http://localhost:8080/auth/admin/realms/master/components/7f7abf96-f377-43cc-9e23-5a3696c5df5c: dial tcp [::1]:8080: connect: connection refused

While I still think that Terraform does not want providers to be configured with interpolated variables, I don't mind merging this since this is not a workflow that I personally use.

@mrparkers mrparkers merged commit 44f3b56 into mrparkers:master Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants