# Module source attribute

**URL:** <https://discuss.hashicorp.com/t/module-source-attribute/5739>\
**Category:** Sentinel\
**Created:** [February 6, 2020, 8:04pm UTC](https://discuss.hashicorp.com/t/module-source-attribute/5739 "2020-02-06T20:04:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mizunos](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mizunos/32/4481_2.png) [@mizunos](https://discuss.hashicorp.com/u/mizunos)\
**Post date:** [February 6, 2020, 8:04pm UTC](https://discuss.hashicorp.com/t/module-source-attribute/5739/1 "2020-02-06T20:04:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hcrhall](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/hcrhall/32/968_2.png) [@hcrhall](https://discuss.hashicorp.com/u/hcrhall)\
**Post date:** [February 6, 2020, 8:57pm UTC](https://discuss.hashicorp.com/t/module-source-attribute/5739/2 "2020-02-06T20:57:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mizunos](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mizunos/32/4481_2.png) [@mizunos](https://discuss.hashicorp.com/u/mizunos)\
**Post date:** [February 11, 2020, 2:59am UTC](https://discuss.hashicorp.com/t/module-source-attribute/5739/3 "2020-02-11T02:59:17Z")

</div>

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/sandbox/moduleA.git  
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

---

<div class="post-metadata">

**Author:** ![hcrhall](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/hcrhall/32/968_2.png) [@hcrhall](https://discuss.hashicorp.com/u/hcrhall)\
**Post date:** [February 11, 2020, 3:51am UTC](https://discuss.hashicorp.com/t/module-source-attribute/5739/4 "2020-02-11T03:51:53Z")

</div>

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 🙂

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**

> <https://github.com/hashicorp/terraform/issues/1439>
>
> I'm trying to avoid hard-coding module sources; the simplest approach would be:
> variable "foo\_module\_source" {
> default = "github.com/thisisme/terraform-foo-module"
> }
> module "foo" {
> source =...
