Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Source Interpolation ? #18063

Closed
octravis opened this issue May 16, 2018 · 8 comments
Closed

Module Source Interpolation ? #18063

octravis opened this issue May 16, 2018 · 8 comments

Comments

@octravis
Copy link

octravis commented May 16, 2018

Hi Support,

I was attempting use interpolation on the module source. Is this allowed ?, seems to pass the string with not interpolation?

from variables.tf 
variable "github_location" {
  type = "string"
  default = "https://github.com/xxxxx"
}
from main.tf
module "push_hostfile" {
  source = “${format(“%s%s”, var.github_location, “/vmware_provision”)}”

terraform init
Initializing modules...
- module.deployVM_singlenode
  Getting source "${format(\"%s%s\", var.github_location, \"/vmware_provision\")}"

Terraform Version

Terraform v0.11.7

Expected Behavior

Initialize the module with the interpolated github_location

Actual Behavior

Initializing modules...

  • module.deployVM_singlenode
    Getting source "${format("%s%s", var.github_location, "/vmware_provision")}"
@jbardin
Copy link
Member

jbardin commented May 16, 2018

Hi @octravis,

Sorry this tripped you up. Interpolations are not allowed in that field, because the module need to be fetched early on before we have a complete config for interpolation.

I just checked though, and it seems this is only called out in passing here: https://www.terraform.io/docs/modules/sources.html#private-github-repos, so we should probably highlight it better in the documentation.

@deryadorian
Copy link

Hi! So is that planned for futuru releases or no? Any idea?

@dtzar
Copy link
Contributor

dtzar commented Apr 2, 2019

@jbardin It would be very nice to have the ability for interpolation here (or even just the ability to specify a variable!) for allowing easier ability to switch between local development (i.e. ../) and people referencing the same code in an external source (i.e. Github). This becomes a pain point when running a PR/CI system against a module which references an external source; you're not able to easily test the updated code since it only pulls the external source.

@pcj
Copy link

pcj commented Apr 2, 2019

Duplicate of #1439

@apparentlymart
Copy link
Contributor

Indeed, this is the same as #1439, so I'm going to close this out. The other issue has some extensive discussion on why this isn't allowed and what you might do instead for certain use-cases. If you have a use-case that isn't covered by it, please open a new Feature Request issue about what you are trying to achieve; your problem will not be solved by supporting arbitrary expressions in the source argument, but we can hopefully find some other way to address it that works within the Terraform architecture.

@dtzar
Copy link
Contributor

dtzar commented Apr 2, 2019

This issue was to document that this isn't supported somewhere in the public documentation...

@apparentlymart
Copy link
Contributor

apparentlymart commented Apr 2, 2019

The forthcoming Terraform v0.12.0 release includes a specific error message for this case that will be shown if you try to use variables or functions in the source argument.

The documentation also already reflects that constraint:

This value must be a literal string with no template sequences; arbitrary expressions are not allowed.

The older documentation for Terraform v0.11 also reflects this, using more v0.11-oriented terminology:

This value must be a literal string with no template sequences; interpolations are not allowed.

(Templates are the extended idea of "interpolations" in v0.12, after conditionals and repetition were added.)

@ghost
Copy link

ghost commented Aug 13, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants