Terraform "The connection (Name) does not exist" error when creating a user

Hi there!

Yesterday I set up a new connection for our tenant as well as a client connected to it through our Terraform IaC. I wanted to create a user for tests on that connection as well. However, terraform now constantly errors out on that last step with:

Error: 400 Bad Request: The connection (Name) does not exist.

My corresponding Terraform snippets are:

# The client accessing the new connection
resource "auth0_client" "name_access_application" {
  name = "Name_access"
  description = "Some description"
  app_type = "non_interactive"

  is_first_party = true
  is_token_endpoint_ip_header_trusted = false
  oidc_conformant = true

  allowed_origins = local.allowed_origins
  grant_types = local.auth0_api_grants
  jwt_configuration {
    lifetime_in_seconds = 36000
    secret_encoded = true
    alg = "RS256"
  }
}

# The new connection
resource "auth0_connection" "name_connection" {
  name = "Name"
  strategy = "auth0"
  options {
    password_policy = "good"
    password_complexity_options {
      min_length = 8
    }
    brute_force_protection = true
    enabled_database_customization = false
    requires_username = false
    disable_signup = true
  }
  enabled_clients = [
    auth0_client.name_access_application.client_id,
    local.auth0_terraform_client_id
  ]
}

# The actual test user
resource "auth0_user" "name_test_user" {
  connection_name = auth0_connection.name_connection.name
  user_id = local.test_user.user_id
  name = local.test_user.name
  given_name = local.test_user.given_name
  family_name = local.test_user.family_name
  email = local.test_user.email
  email_verified = local.test_user.email_verified
  password = random_password.test_user_password.result
}

I don’t want to set this new connection to be the default directory for our tenant as we’re using it for a very small subset of users.

If I skip the user creation part and run the whole code (i.e. commenting out the last auth0_user resource), Terraform applies it straight away. The new connection as well as the client are created. Furthermore, on the Auth0 console online I am able to simply create a user with the new connection. Hence, my confusion as of why I get this 400 exception above.

Well, if someone is running into a similar problem, try to update the Auth-0 Terraform provider to the current verison (0.21.0). That did the trick for me.

1 Like

Perfect! Glad to hear that and thanks for sharing with the rest of community!