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

Terragrunt source results in error #5841

Closed
1 task done
dwc0011 opened this issue Oct 6, 2022 · 3 comments · Fixed by #7502
Closed
1 task done

Terragrunt source results in error #5841

dwc0011 opened this issue Oct 6, 2022 · 3 comments · Fixed by #7502
Labels
L: terraform Terraform packages T: bug 🐞 Something isn't working

Comments

@dwc0011
Copy link
Contributor

dwc0011 commented Oct 6, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Package ecosystem

Terraform

Package manager version

No response

Language version

No response

Manifest location and content before the Dependabot update

No response

dependabot.yml content

No response

Updated dependency

No response

What you expected to see, versus what you actually saw

What I expected: The terragrunt source to be evaluated and if unable to, an error message would be logged and dependabot would continue processing the remainder of the reposititory.
What I saw: The path was incorrectly thought to be a registry source and found invalid. Dependabot threw an error and stopped processing the remainder of the repository.

/home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:213:in `registry_source_details_from': Invalid registry source specified: '${path_relative_from_include()}/..//.ci/${path_relative_to_include()}' (Dependabot::DependencyFileNotEvaluatable)
--
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:180:in `source_from'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:145:in `build_terragrunt_dependency'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:71:in `block (2 levels) in parse_terragrunt_files'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:68:in `each'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:68:in `block in parse_terragrunt_files'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:66:in `each'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:66:in `parse_terragrunt_files'
from /home/dependabot/dependabot-script/vendor/ruby/2.7.0/gems/dependabot-terraform-0.211.0/lib/dependabot/terraform/file_parser.rb:34:in `parse'
from /home/dependabot/dependabot-script/updater.rb:81:in `update'

Native package manager behavior

Terragrunt will evaluate the path from the method and use it as a local path.

Images of the diff or a link to the PR, issue, or logs

No response

Smallest manifest that reproduces the issue

terraform {
 source          = "${path_relative_from_include()}/..//.ci/${path_relative_to_include()}"
 }
@dwc0011 dwc0011 added the T: bug 🐞 Something isn't working label Oct 6, 2022
@jeffwidman jeffwidman added the L: terraform Terraform packages label Oct 6, 2022
@jeffwidman
Copy link
Member

👋 I'm not a terraform expert, but as best I understand it, Terragrunt is a wrapper around Terraform... so will your manifest above not be supported under native Terraform? IE, does it require Terragrunt in order to read that syntax?

I agree that it would be better to throw a nicer error, provided that we definitively knew under native Terraform that this wasn't a registry source... I doubt we'll get to this anytime soon, but as you know a PR is always welcome. 😄

@dwc0011
Copy link
Contributor Author

dwc0011 commented Oct 6, 2022

Yes, it is a wrapper and is a terragrunt function, so native terraform wouldn't evaluate it, but if it's an unknown source then dependabot should report error and continue processing IMHO. Plus, dependabot does support terragrunt at least partially.

In this case it is also incorrectly identifying it as a registry source, which is a bug as well. I think this is a two part fix, identify it as an unknown source and report "error" and continue. As this is valid terragrunt and not truly an error, it is just that dependabot cannot evaluate it.

We do plan on working a PR for this as our schedule allows.

@dwc0011
Copy link
Contributor Author

dwc0011 commented Oct 6, 2022

After more thought and conversations, we have determined terraform does not allow interpolation for sources. Terragrunt supports interpolation more widely for sources and this is the issue. There are some cases where the terragrunt interpolation would work but that type would be detected and returned prior to reaching our approach.
A valid approach we suggest is to have a regex that detects interpolation syntax i.e. ${.....} as an additional source type, checked after all other valid source types. if interpolation is detected report a warning that Dependabot does not support interpolation and continue processing other sources.

We will begin work on a PR as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: terraform Terraform packages T: bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants