Sharing a file across multiple terraform environment folders

hello forum folks.

having just started using remote backend states today, and sharing those states across other terraform environments, i’ve come across having to keep a standards copy of a file in each of my environments folders, but it would be cool just to use a shared one for all my environments.

this file actually picks up values of a local env setup script to set the variables.

eg: a pipeline is currently using assets from the shared terraform remote state from the vpc.



variable "aws_region" {
  default = "{var.aws_region}"
(etc etc)

it appears terraform can’t use a new /shared/ in both the terraform apply for the /vpc and /pipeline folders. if what i’m saying is correct, is there a work around to somehow use a shared file like this?

thank you!

1 Like

What about a simple symlink?

@Wolfsrudel comes in FTW! thank you. that worked perfectly.

1 Like

tip: be careful while running terraform fmt over the symlinks. I have observed in the past that the symlinks get converted to regular files.

1 Like

Thanks for the hint. :+1: