Creating User via Terraform and Seeing Error "400 Bad Request: The connection is disabled"

Problem statement

When using Terraform to create a temporary connection and test a user, the user creation fails with the error:

400 Bad Request: The connection is disabled

Cause

In order to create users, the client ID that is performing the create user operation must have the targeted connection enabled.

New connections will be, by default, not enabled for pre-existing applications.

Solution

The M2M client ID that Terraform uses to manage resources on the tenant must have the new connection enabled before it can create users on a new connection using the “auth0_connection_client” resource.

For example:

resource "auth0_connection" "test_connection" {
name = "testconnection"
strategy = "auth0"
is_domain_connection = false
options {
password_policy = "excellent"
brute_force_protection = true
enabled_database_customization = false
import_mode = false
requires_username = false
disable_signup = false
strategy_version = 2
password_history {
enable = true
size = 1
}
password_no_personal_info {
enable = true
}
password_dictionary {
enable = true
}
password_complexity_options {
min_length = 6
}
validation {
username {
min = 10
max = 40
}
}
mfa {
active = true
return_enroll_settings = true
}
}
}

resource "auth0_connection_client" "my_conn_client_assoc" {
  connection_id = auth0_connection.test_connection.id
  client_id     = auth0_client.terraform_m2m.client_id
}

resource "auth0_user" "test_user" {

email = "test-user-1@email.com"
name = "Firstname Lastname"
nickname = "test.user"
connection_name = auth0_connection.test_connection.name
email_verified = true
password = "secret123!"
depends_on = [auth0_connection_client.my_conn_client_assoc]
}

Related Reference