gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.04k stars 974 forks source link

WARN[] No double-slash (//) found - on remote modules without submodules #1675

Closed nkaravias closed 1 year ago

nkaravias commented 3 years ago

When doing a plan using a module that doesn't have submodules, terragrunt keeps throwing a warning. The double slash would address the issue if using submodules but the warning is redundant if you have a single flat module.

Example:

terragrunt run-all plan  --terragrunt-working-dir "resources/platform" --terragrunt-log-level INFO
INFO[0000] Stack at resources/platform:
  => Module /<my home>/terraform/cloud-factory/resources/platform/folders/root (excluded: false, dependencies: [])
WARN[0000] No double-slash (//) found in source URL /terraform-google-modules/terraform-google-folders.git. 
Relative paths in downloaded Terraform code may not work.  
prefix=[/<my home>/terraform/cloud-factory/resources/platform/folders/root]

The terragrunt.hcl configuration used in this example:

terraform {
  source = "git::git@github.com:terraform-google-modules/terraform-google-folders.git?ref=v3.0.0"
}

The module in question has a flat structure with no submodules: https://github.com/terraform-google-modules/terraform-google-folders. I've seen a few threads about this but nothing with a permanent solution that addresses this for simple modules like the above mentioned one.

Using:

terragrunt version v0.29.2

Terraform v0.15.3 on darwin_amd64

jevon71-work commented 3 years ago

I am also seeing this issue.

danielcrisap commented 3 years ago

I'm using in this way and showing the same warning

terraform {
  source = "github.com/terraform-aws-modules/terraform-aws-acm?ref=v3.0.0"
}
WARN[0000] No double-slash (//) found in source URL /terraform-aws-modules/terraform-aws-acm. Relative paths in downloaded Terraform code may not work.  prefix=[/Users/MY_PATH/] 
k911 commented 3 years ago

It would be great if we could disable this warning deliberately via some flag / ENV variable/configuration.

brikis98 commented 3 years ago

Ah, that's a good point. That logic needs to handle modules in the root of a repo better. PR to fix this is very welcome!

sebastianmacarescu commented 3 years ago

I see the same warning

j3ffrw commented 3 years ago

workaround for source without submodules terraform { source = "github.com/terraform-aws-modules/terraform-aws-acm//.?ref=v3.0.0" }

double-slash(//) and a period (.)

Frituurpanda commented 3 years ago

We are getting the same issue when using the tfr source method. For instance:

terraform {
  source = "tfr:///terraform-aws-modules/vpc/aws?version=3.5.0"
}

results in a:

No double-slash (//) found in source URL /terraform-aws-modules/vpc/aws. Relative paths in downloaded Terraform code may not work...

The above fix also works for tfr sources:

terraform {
  source = "tfr:///terraform-aws-modules/vpc/aws//.?version=3.5.0"
}

A more systemic solution would be appreciated though as this is a Terragrunt issue, not a module issue.

NesManrique commented 2 years ago

Just hit this issue. Commenting for visibility.

adv4000 commented 2 years ago

Getting same error for: source = "git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git" Fixed by adding //. source = "git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//."

adamwshero commented 2 years ago

As others have mentioned, adding a trailing '.' at the end of the path solves but would appreciate a better solve for this.

source = "git::git@github.com:terraform-aws-modules/terraform-aws-autoscaling.git//.?ref=v4.11.0"

jaydeland commented 2 years ago

The //. doesn't work when using the find_in_parent_folders function.

terraform {
  source = find_in_parent_folders("_resources///_vpc")
}
josefloressv commented 2 years ago

Workaround when you use functions. See de triple slash at the end, that works for me

terraform {
  #source = "${get_parent_terragrunt_dir()}/../modules/stacks/${local.stack_name}/"
  source = "${get_parent_terragrunt_dir()}/../modules/stacks/${local.stack_name}///"
}
OriBenHur-akeyless commented 1 year ago

this is working for me

terraform {
  source = "${find_in_parent_folders("modules/global/dns")}///"
}

The trick here is the /// at the end

drueck commented 1 year ago

I did a little digging into this today, and it looks like this issue happens because terragrunt is using the getter.Detect function from https://github.com/hashicorp/go-getter to parse the source strings, and if the source string is in a somewhat non-canonical format such as git::git@github.com:foo..., getter.Detect transforms it into git::ssh://git@github.com/foo.... When it does this, if there are trailing // at the end of the source string, it removes them.

So, if your source is git::github.com:terraform-aws-modules/terraform-aws-acm//?ref=v3.0.0 for example, getter.Detect will transform it into git::ssh://git@github.com/terraform-aws-modules/terraform-aws-acm?ref=v3.0.0. Note that it has removed the //.

Then when this sourceUrl is passed into the splitSourceUrl function in the terragrunt code, it raises this warning because there is now no // in the transformed source url even though the original source had it.

So, yet another workaround is to use the more canonical URL (git::ssh://git@github.com/terraform-aws-modules/terraform-aws-acm//?ref=v3.0.0) to begin with, which getter.Detect will not have to transform. In this case it leaves the // in, and terragrunt's splitSourceUrl function no longer throws the warning.

I'm not sure if the go-getter library could/should be patched to leave the trailing // in, or if there's a good reason for it to remove them, but it seems like maybe it could be an issue for them to consider there.

gotheguy commented 1 year ago

this is working for me

terraform {
  source = "${find_in_parent_folders("modules/global/dns")}///"
}

The trick here is the /// at the end

That did it for me, thank you, bud

stv-io commented 1 year ago

This is also an issue for /dev/null (hack used for decommissioned modules 😅 )

terraform {
  source = "/dev/null"
  # switched off since not needed
}

..

level=warning msg=No double-slash (//) found in source URL /dev/null. Relative paths in downloaded Terraform code may not work...
jcarlson commented 1 year ago

I'm seeing this as well after following this tutorial using Terragrunt 0.50.9: https://blog.gruntwork.io/how-to-manage-multiple-environments-with-terraform-using-terragrunt-2c3e32fc60a8

That blog even uses relative module paths as an example:

image
denis256 commented 1 year ago

Improved checking of module path in release https://github.com/gruntwork-io/terragrunt/releases/tag/v0.50.13

faelp22 commented 4 months ago

We are getting the same issue when using the tfr source method. For instance:

terraform {
  source = "tfr:///terraform-aws-modules/vpc/aws?version=3.5.0"
}

results in a:

No double-slash (//) found in source URL /terraform-aws-modules/vpc/aws. Relative paths in downloaded Terraform code may not work...

The above fix also works for tfr sources:

terraform {
  source = "tfr:///terraform-aws-modules/vpc/aws//.?version=3.5.0"
}

A more systemic solution would be appreciated though as this is a Terragrunt issue, not a module issue.

Isso resolveu para mim, apenas adicionei as duas // no final antes da versão

Antes:

terraform {
  source = "tfr:///terraform-aws-modules/vpc/aws?version=5.8.1"
}

Depois:

terraform {
  source = "tfr:///terraform-aws-modules/vpc/aws//?version=5.8.1"
}