Module source attribute

Is there a way to specify a source using a variables instead of hard coded value? Specifically, was trying to specify a git path to the module that need to vary depending on whether we are deploying to one environment vs a sandbox

Hi @mizunos. Thanks for reaching out. Is it possible for you to provide a snippet of code to provide context for your question?

Thanks @hcrhall

I have 2 repos in gitlab

“org1/sandbox” for my sandbox to develop and play with module approach
“org1/prod-modules” for my finish module code

git package is the same - for example : moduleA.git

so the path to the module would be

org1/prod-modules/moduleA.git depending on whether I build/test for sandbox or for prod

So I am looking to substitute the parent path as an environment variable that can be set dynamically at build time so that I can automate .gitlab-ci.yml. The objective is not to have to hard coded the source name in the code

so the terraform code would be

variable “parent_path” {
default = “org1/sandbox”

module “add-res” {
source = “${var.parent_path}/moduleA.git”

Have not been able to get that to work yet. Keep getting the error along the line of variable are not allowed for source

Hi @mizunos,

It looks like your question is regarding Terraform and not Sentinel. All good though, I can answer the question because I have come across this query previously :slight_smile:

The module source value must be a literal string with no template sequences and therefore interpolations are not allowed. There is a lengthy thread on this topic available in the reference below that may be of interest.

Hope this helps clear up the confusion regarding the behaviour you are experiencing.

Online References