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

**URL:** <https://community.auth0.com/t/terraform-the-connection-name-does-not-exist-error-when-creating-a-user/68451>\
**Category:** Get Help\
**Tags:** terraform\
**Created:** [August 24, 2021, 9:15am UTC](https://community.auth0.com/t/terraform-the-connection-name-does-not-exist-error-when-creating-a-user/68451 "2021-08-24T09:15:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rico](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rico/32/24090_2.png) [@rico](https://community.auth0.com/u/rico)\
**Post date:** [August 24, 2021, 9:15am UTC](https://community.auth0.com/t/terraform-the-connection-name-does-not-exist-error-when-creating-a-user/68451/1 "2021-08-24T09:15:58Z")

</div>

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:

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

```

My corresponding Terraform snippets are:

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![rico](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rico/32/24090_2.png) [@rico](https://community.auth0.com/u/rico)\
**Post date:** [August 24, 2021, 3:36pm UTC](https://community.auth0.com/t/terraform-the-connection-name-does-not-exist-error-when-creating-a-user/68451/2 "2021-08-24T15:36:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 26, 2021, 9:35am UTC](https://community.auth0.com/t/terraform-the-connection-name-does-not-exist-error-when-creating-a-user/68451/3 "2021-08-26T09:35:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 26, 2021, 9:35am UTC](https://community.auth0.com/t/terraform-the-connection-name-does-not-exist-error-when-creating-a-user/68451/4 "2021-08-26T09:35:23Z")

</div>


