Hi there,
I’m working on porting terraspace to managing our 290~ workspaces (About 90 stacks) in TFC, but am struggling with a few things:
As the documentation states, you need to check in the .terraspace-cache
folder into source control in order for TFC to be able to execute your terraform code with VCS enabled. Great, no problem. In my case, I’ve got 10 different AWS accounts that I manage, but each account does not use every stack that I have available. I need to ensure that any code that’s checked in to source control has terraspace build placeholder
run against the appropriate environment, but it should only generate a folder in cache if the environment actually exists (i.e - existence of a tfvars file). Here’s an example:
app/
|-- stacks/
|-- ec2/
|-- main.tf
|-- tfvars/
|-- dev.tfvars
|-- qa.tfvars
|-- prod.tfvars
With this, I would only expect an environment to be built for dev, qa and prod. My other environments (uat, stage, etc) should not have a cache folder built for them as these don’t actually exist for this stack. How would I go about this?
Second, it seems that terraspace build placeholder
takes awhile to run when I need to run it for all of my environments each time I push. I need to make sure that what’s in the cache folder is accurate before checking in to source control as the PR will trigger a plan in TFC against this folder. Right now, a build for my 10 environments can take a few minutes to complete as it iterates through each one. All I really need is terraspace to convert my terraspace files to actual terraform and that’s it, but it seems to be doing a lot more in the background. Can you elaborate if there’s a better way to do this? I’m really using terraspace for it’s DRY stance and templating, which work great - but generating the actual terraform takes awhile when working at scale.
Here’s an example of how long running terraspace build
takes regardless if it’s one stack or using placeholder
(all stacks):
> time TS_ENV=rd terraspace build stack
Building .terraspace-cache/us-east-1/rd/stacks/stack
Built in .terraspace-cache/us-east-1/rd/stacks/stack
real 0m33.366s
user 0m7.465s
sys 0m0.710s
Thanks for your help.