Terragrunt: How to pass local path to SOURCE of main.tf! BIG-TEAM workflow

Created on 27 Feb 2018  路  3Comments  路  Source: gruntwork-io/terragrunt

Hi,

This is a question that I tried to find in the docs and other issues here but I failed.

What I want to achieve here is.

I have terragrunt live infra that use a terragrunt module that module has dependencies of other modules I don't want to copy and paste the same variables (DRY) for two diferent modules you might be asking yourself why you need to break your service in two modules the reason behind is that in my organization networking team does network on our DC's and also in the cloud too if I want to make my company use terragrunt need to break DB, Network in different modules for the same services.

So I want my module to depend in another module that uses the same variables so my service module (asg, launch configs, ec2 instance) will depend on the network module (elb, security groups).

I had this working in a production environment when the path relies on git repo but for development is painful this is my example.

1) Live live/stage/web -> terraform.tfvars (this is live)

terraform {
    # local path just for development
    source = "../modules/asg-service/"
  }

aws_region   = "xxxxx"
name         = "xxxx"
server_port = "8080"
elb_port = "8080"

.
.
.
all good here 

2) this is my main module that has another module dependency /modules/ags-service/main.tf
.

here I put my dependencies to the network modules I already knew that terragrunt will have a hard time finding the relative path if I use a local path if I use git path everything works perfectly for me
but makes development really painful


provider "aws" {
  region = "${var.aws_region}"
}

module "project_network" {
  #source = "[email protected]:something/terraform-test.git?ref=v0.0.16//network/project_network"
  source = "../network/project_network/" .  ----> **NOT WORK**

  aws_region   = "${var.aws_region}"
  name         = "${var.name}"

  server_port = "${var.server_port}"
  elb_port = "${var.elb_port}"

}

# CREATE THE ASG
resource "aws_autoscaling_group" "webserver_example" { 
.
.

if I use the git path all good but if I try to put a local path in the SOURCE of main.tf terragrunt doesn't know about that path and I can't use the build-in function is there a way to pass the relative path the source in main.tf? for development purposes that would make development not painful

  • module.project_network
    Getting source "../network/project_network/"
    Error downloading modules: Error loading modules: error downloading

or any suggestions?

question

Most helpful comment

All 3 comments

Use a double-slash in the source path. See: https://github.com/gruntwork-io/terragrunt#working-locally

Oh i see, i see Thanks man you are the best :)

Was this page helpful?
0 / 5 - 0 ratings