Thanks guys. I kind of figured this out by accident right after posting. I was under the impression that the double slash notation was only for use with the terragrunt plan-all
functionality. But that can be used with terragrunt plan
also which solves my problem as I presume under the hood its pulling my entire “modules” repo into the temp dir so the relative paths work.
So just incase it helps others and to ensure I am doing it right. My “live” repo has a terraform.tfvars
file per environemnt like this:
terragrunt = {
terraform {
source = "git@github.com:my-org/my-modules.git//terragrunt_module_foo?ref=v0.6.54"
}
# Include all settings from the root terraform.tfvars file
include = {
path = "${find_in_parent_folders()}"
}
}
aws_region = "eu-west-1"
That terragrunt module looks like this:
provider "aws" {
region = "${var.aws_region}"
version = "~> 1.14"
}
terraform {
backend "s3" {}
}
data "aws_caller_identity" "current" {}
# I pass in state from my VPC module which is a terragrunt module also
data "terraform_remote_state" "network" {
backend = "s3"
config {
bucket = "${var.tfstate_global_bucket}"
key = "${var.tfstate_network_key}"
region = "eu-west-1"
}
}
# Some terraform module A
module "a_terraform_module" {
source = "../my_module"
name = "foo"
}
# Some terraform module B
module "another_terraform_module" {
source = "../cool_module"
name = "bar"
}
A you can see it has relative paths to other modules and it works fine. I can see how if these modules were in a different repo / local path it would not work
Thanks for the help