I’ve been trying to work with Terraspace on a new work project, and have been running into some infuriating issues/bugs with file permissions when trying to run up commands.
When trying to deploy my stacks, I keep getting errors similar to this:
For context, here’s how I’ve installed everything:
ASDF for:
ruby 3.1.3
terraform-docs
terraform 1.4.6
tflint 0.46.1
As of right now, I’ve used the DMG installer to install Terraspace, but this was a troubleshooting exercise to see if the homebrew install was the root cause of my issues
Here’s the command I’m running (this issues comes up whether or not I use a .env file): TS_ENV=prod bundle exec terraspace up <stack-name>
So, here’s where things get weird:
I was completely unable to run operations that involved loading the cache until I ran the bundle cmd. This seemed to fix my issue, but then out of nowhere, the issue seemed to just return for no reason. Now, I can run an up command if there is no cache directory (I’m just manually deleting it), but running a subsequent command on the same exact isolated stack will fail due to file permission errors. On top of this, there’s one stack that simply refuses to work anymore at all, even when I blow out my cache.
Has anyone encountered this issue before and resolved it on an ARM Mac? I’m just about ready to request that we revert back to vanilla Terraform at this point
Bummer. From the sounds of it “Permission denied”. This is a guess. But thinking there’s a chance terraform itself is not owned by your current user. Thinking that because the .terraform/modules/sg_app/.git in the error. This is created by terraform. Terraspace calls out to terraform init, which installs .terraform/modules by evaulating your terraform code. Maybe terraform is downloading that module via git with the permission of the terraform binary. Need to track down what creates it.
Maybe consider using tfenv, though asfd should work similar too. That’s one way to make sure that the terraform binary that is owned by your user.
Would also double-check that the /opt/terraspace directory also belongs to your current user on the machine. Maybe some folders within there or files within there are not. This may mitigate it:
chown `whoami`:staff /opt/terraspace
However, that does not seem to be the problem here.
Generally, recommend:
use tfenv: It’s nice to be able to control which version of terraform your using. Again, asdf should work similar.
I can confirm that all of these binaries have the appropriate permissions.
What seems to be happening is that if I initialize any of the stacks in my permanent stacks directory, then try to run Terraspace commands, any temporary files in my .terraform directories get copied over, but without the appropriate permissions. Is there a proper way to initialize the working directories, or can those be excluded from being copied over?
Still curious on how this is happening. Hoping for reproducible steps. Maybe on a cloud9 machine or something. To be clear, I believe it’s happening. Just think figuring out steps to reproduce it might be half the battle here. Thanks.