Using variables with remote backend

Hello, and welcome to the forum!

To both create an organization and the workspace - from that workspace - presents a bit of a chicken or the egg problem - specifically, you’re trying to configure the remote backend for a workspace that doesn’t exist yet and attempting to be provisioned from the same workspace!

However, the sort of ‘bootstrapping’ you wish to do here is a common pattern: you have a ‘bootstrap’ or ‘meta’ workspace in TFC which will provision everything else you want in TFC (including separate organizations, if you like).

  • Create an organization in Terraform Cloud.
  • Configure the remote backend to use that organization. Set a workspaces name to whatever you want - if it doesn’t exist in the organization already, the remote backend will create it for you!
  • In this ‘bootstrap’ workspace, you can set the token for the TFE provider in workspace variables, and then pass it to your configuration here (like var.provider_token).
  • Now you can provision any other organizations/workspaces/whatever from this workspace! :tada:

There’s a lot of other things you can do depending on finer details about your situation, but I hope that’s a good start!