Problem
Creating a no-code enabled module through the No-Code Provisioning of a Module within an Organization API or the tfe provider's tfe_no_code_module
resource fails with the following validation error.
{
"errors": [
{
"status": "422",
"title": "unprocessable entity",
"detail": "Validation failed: Organization has already been taken"
}
]
}
Cause
This error indicates that the registry module has already been no-code allowed. The validation is enforcing a uniqueness of the organization and registry module combination on the no-code-allowed module record. When a module is no-code enabled, a "no-code-allowlist" record is created in the backend for the registry module. While the registry module may currently have no-code provisioning disabled (for example, by toggling Enable Module for no-code provisioning in the UI), the "no-code-allowlist" record persists for the organization and registry module pair. Attempting to then create the no-code-allowed module using this API or the tfe_no_code_module
resource results in the error above.
Solution
If a registry module has been no-code-enabled at any point, the "no-code-allowlist" object will already exist. Therefore, the no-code settings of such a registry module will need to be edited using the Update No-Code Provisioning Settings for a Module API. In the context of Terraform, this will require importing any no-code-allowed registry modules intended to be managed by Terraform into the state. To find the unique identifier of a No-Code-Allowed module, navigate to the registry module's module overview page and, under No Code Provisioning, select Configure Settings.
Additional information
If you continue to experience issues, please contact HashiCorp Support.