Terraform: Add support for git tags/branches in module sources

Created on 6 Mar 2015  ยท  10Comments  ยท  Source: hashicorp/terraform

It's only possible to always use master / HEAD of each module repository

module "consul" {
    source = "github.com/hashicorp/consul/terraform/aws"
    servers = 3
}

which makes it:

  • hard to make any reproducible build
  • security hazard - imagine I'm using tf_aws_sg and accidentally upgrade to a version that exposes some ports to 0.0.0.0/0 for example
core enhancement

Most helpful comment

@radeksimko Yeah, we didn't design it that way because it conflates itself with the parameters to the module itself. We want the URL to be a single source of information.

All 10 comments

Sounds good to me. We already thought this through and it wouldn't be too hard to add. Here is how it would look:

Note: Doesn't work yet! Just notes for implementation.

module "consul" {
    source = "github.com/hashicorp/consul/terraform/aws?branch=foo"
    servers = 3
}

That's not bad, I was thinking about something like this:

module "consul" {
    source = "github.com/hashicorp/consul/terraform/aws"
    branch = "foo"
    servers = 3
}

but maybe that's too verbose?

Generally the inspiration to me here was Bundler's Gemfile:

:git => 'https://github.com/rails/rails.git', :ref => '4aded'
:git => 'https://github.com/rails/rails.git', :branch => '2-3-stable'
:git => 'https://github.com/rails/rails.git', :tag => 'v2.3.5'

Go does not support anything out of the box and probably won't be in the nearest future from what I've seen in the mailing list.

@radeksimko Yeah, we didn't design it that way because it conflates itself with the parameters to the module itself. We want the URL to be a single source of information.

I see, that makes sense to me then.

+1

+1

As @clstokes pointed out in #1439, there's a solution for this:
https://terraform.io/docs/modules/sources.html#ref

I just wonder why @mitchellh didn't point me there and more importantly why I didn't notice that bit in documentation...

Any reason why keep this open then?

For some reason I thought I didn't implement it yet, I knew I had PLANNED for it.

_Well then_.

Thanks :)

@radeksimko @mitchellh I think there's a bug in the branch/ref implementation FYI - https://github.com/hashicorp/terraform/issues/1568.

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.

Was this page helpful?
0 / 5 - 0 ratings