Automatically Creating Workspaces

Hey All - I’m pretty new to terraform. Been spending the last 4 months or so getting the basics down and I finally feel confident enough to put together a POC for Okta as my background is IAM.

I am starting with my applications and am planning on having a single repository labeled terraform-okta and two permanent branches (dev) - which will deploy to a sandbox and main which will deploy to prod.

within each branch will be the “apps” directory that will contain the directories of each module, and later I will add more directories for different module types.

I am wondering A. Does this sound like a reasonable way to have my Repository set up.

B. I am planning on using GitHub actions and I have found plenty of info on the CI pieces and running tests before merge, I’ve also found plenty of info on CD post workspace creation so I’m just going to copy people alot smarter than me.

What I’m really wondering is what is the best way to automatically create my workspaces through CD? Should I not even be doing this because I can hardly find any information on this aspect.

Are you talking about workspaces in the Terraform sense (i.e., different layers within a state, allowing some limited way of using the same code across different environments for each “workspace”), or, more “workspace” in the Terraform cloud / TFE sense?

Normally, if you’re not using TF Cloud, I would call the units that are in a single state “states” or “substates”.

In either case, the first time you apply something, the state or “workspace” should get created the first time you apply it; if you’re trying to build out your own workflows using a CI provider, you may want to make a reusable workflow that’s somewhat parameterized so that you can call it consistently for a given state or workspace.

Hope that kind of answers your question?