0

I work for an enterprise with a number of different gitlab repositories all deploying applications using Terraform. The majority of these code bases uses a standardised module that defines certain tags for resources in our cloud provider. I am wanting to add the Gitlab project id as one of the default tags and while I know how to use pre-defined vars in Terraform by defining an env var starting with TF_VAR, I don't want to have to modify all code bases in order to set it.

What I want to do is set the project id (env var) in the module so that any codebase that consumes this module will automatically have this environment variable set for use in the gitlab pipeline.

Does anyone have any ideas how I might do this?

Thanks, Adam

2
  • This sounds like you are asking for keyword expansion or keyword substitution. Which git does not provide out of the box. You might want to look at git's smudge and clean filters as a way of doing what you need. And it should be able to modify the terraform code directly, no need for a TF_VAR. This might help Commented Jan 18, 2021 at 13:30
  • If you are executing within a pipeline, then this would be an instrinsic environment variable that can be appended to the base tags map. Commented Jan 18, 2021 at 16:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.