Terraform: Creating organization is not possible

Hello guys,

I can not create an organization through the terraform provider. I get the following error:

qovery_organization.###: Creating...
╷
│ Error: Error on organization create
│ 
│   with qovery_organization.###,
│   on main.tf line 15, in resource "qovery_organization" "###":
│   15: resource "qovery_organization" "###" {
│ 
│ Could not create organization '###', unexpected error: 500 Internal Server Error - Couldn't create an organization - error adding admin role to organization owner
╵

Through the web interface it works fine.

I hope you can help me here :slight_smile:

Best,
Pierre

Hi @hedgehogs-mind,

Creating an organization via the Terraform provider is subject to some limitations. You can’t create it with an API token. It’s a temporary limitation and the reason is that an API token is attached to the organization itself and not your user.

2 solutions are possible:

  1. Best option: Create from the web console your organization and set the organization ID as an external var on Terraform. You can take a look at this Terraform example.
  2. Not super convenient option: Use your personal token to create at least the organization via Terraform. You can get your personal token via the command cat ~/.qovery/context.json | jq -r .access_token. Note: It’s not convenient since this token expires.

In the future of Qovery, this limitation will be gone since an API token will be possibly attached to your user account.

You can take a look at a few Qovery Terraform examples here.

Thanks for your explanation. Depending on when the changes regarding attaching tokens to a user account will be deployed … I may would propose a change to the documentation to include a hint on how to treat organizations with terraform? Because the example here Terraform | Docs | Qovery was misleading me into thinking it would work out of the box :sweat_smile:

What do you think?

Best,
Pierre