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

Issue when using --terragrunt-source when a module dependency is on a different Git repository #1358

Closed
michelzanini opened this issue Sep 17, 2020 · 1 comment

Comments

@michelzanini
Copy link

I have the following folder structure:

.
├── eks
│   └── terragrunt.hcl
└── vpc
    └── terragrunt.hcl

On eks I am importing a Git module such as:

terraform {
  source = "[email protected]:company/terraform-aws-eks-module.git?ref=master"
}

dependency "vpc" {
  config_path = "../vpc"
}

On the vpc folder I import another Git module, a totally different repository:

terraform {
  source = "[email protected]:company/terraform-aws-vpc-module.git?ref=master"
}

Sometimes, I am testing local changes to the eks module, and I want to use a local version of the source code to avoid committing changes to a branch to test it.

Both repositories are cloned locally on ~/git folder.

When I do:

cd eks
terragrunt plan --terragrunt-source ~/git/terraform-aws-eks-module

I get:

[terragrunt] 2020/09/17 14:30:54 Did not find any Terraform files (*.tf) in ~/git/terragrunt-project/vpc/.terragrunt-cache/x8mfE_ZvAC1E31uXzInOVIdKsfs/sfAihJo8SRsjA8pstYtGUtBaKmE/terraform-aws-vpc-module

That's because, vpc is a dependency of eks, and that module is not found on ~/git/terraform-aws-eks-module.

I understand usually Terragrunt uses the same "live" repository for all source attributes, so then all modules are on the same repository. If that was the case there would be no problem as it would find both modules on the same place.

I wonder if it is not possible to still be able to use --terragrunt-source on this use case I have.

I see a few options:

  1. Another flag to disallow looking at dependencies with --terragrunt-source, something like:
terragrunt plan --terragrunt-source ~/git/terraform-aws-eks-module --terragrunt-source-no-dependencies
  1. Maybe on the dependency block we could say if we want to participate on --terragrunt-source:
dependency "vpc" {
  config_path = "../vpc"
  terragrunt-source-ignore = true
}
  1. Terragrunt could automatically ignore dependencies for --terragrunt-source if they are coming from different Git repos than the module we are running. So it would work correctly with "live" single repositories by changing the source on all modules, while still avoiding this if the repositories are not the same. Possibly this logic can be tricky but definitely the one with less user configuration.

For now, my workaround is to comment the files while I am doing such work, and revert it after I am done:

terraform {
  //source = "[email protected]:company/terraform-aws-eks-module.git?ref=master"
  source = "/Users/myuser/git/terraform-aws-eks-module"
}

terraform {
  //source = "[email protected]:company/terraform-aws-vpc-module.git?ref=master"
  source = "/Users/myuser/git/terraform-aws-vpc-module"
}

Thanks.

@yorinasub17
Copy link
Contributor

This is a duplicate of #1138. Please follow that ticket for a solution to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants