Bootstrapping Terraform Cloud | chicken and egg paradox

I’d like to achieve automation with Terraform Cloud and I’d like to know if this is the best approach.

I want to create a workspace (will call it bootstrapper) which will bootstrap several other workspaces.
I want to create the bootstrapper workspace using Terraform, that will connect to GitHub, bootstrap itself, and create all other workspaces.

What did I do?

  • Created the bootstrapper repo
  • Cloned it
  • Created a token in tfc
  • Set the token as an environment variable (terraform cli)

When I perform terraform init everything works fine and the bootstraper workspace is created at tfc.

However, performing terraform apply tf throws this error: Error creating workspace bootstrapper for organization XXXorg: invalid attribute

So, I’ve imported the bootstrapper workspace, terraform import tfe_workspace.bootstrapper XXXorg/bootstrapper

It works!

I don’t know the side effects of using this approach and would like to share here and know if there is a better approach to achieve such automation, to create terraform workspace using terraform itself.