infracost: Error loading Terraform modules: can't make path relative
In my Gitlab CI pipeline, I was using infracost/infracost:ci-0.10
version and since the last upgrade went in 3 days back .16
my pipeline has been failing with the following error.
$ cd /tmp/base # collapsed multi-line command
time="2023-01-19T10:25:23Z" level=info msg="Evaluating Terraform directory at ."
time="2023-01-19T10:25:23Z" level=info msg="Starting: Downloading Terraform modules"
time="2023-01-19T10:25:23Z" level=info msg="Evaluating Terraform directory at ."
time="2023-01-19T10:25:23Z" level=info msg="Starting: Downloading Terraform modules"
time="2023-01-19T10:25:23Z" level=info msg="Evaluating Terraform directory at ."
time="2023-01-19T10:25:23Z" level=info msg="Starting: Downloading Terraform modules"
time="2023-01-19T10:25:23Z" level=info msg="Evaluating Terraform directory at ."
time="2023-01-19T10:25:23Z" level=info msg="Starting: Downloading Terraform modules"
Error: Error loading Terraform modules: could not load modules for path . Rel: can't make cloudwatch relative to /builds/swateekj/c[36](https://gitlab.com/swateekj/my-infra/-/jobs/3628005383#L36)0/my-infra/
Everytime I retry the pipeline, the module complained about is different (like cloudwatch in the example above).
From the CI file, the command which runs is
cd /tmp/base
infracost breakdown --config-file=${CI_PROJECT_DIR}/${INFRACOST_CONFIG_FILE} \
--format=json \
--out-file=infracost-base.json
Workaround
For now, I have moved it to the previous infracost/infracost:ci-0.10.15
and it is working fine.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 18 (9 by maintainers)
Commits related to this issue
- fix: change project paths to absolute path if initial --config-file path is abs fixes #2231 With the change to the top-level .infracost folder, if an absolute path is used for config-file or path re... — committed to infracost/infracost by hugorut a year ago
- fix: change project paths to absolute path if initial --config-file path is abs fixes #2231 With the change to the top-level .infracost folder, if an absolute path is used for config-file or path re... — committed to infracost/infracost by hugorut a year ago
- fix: change project paths to absolute path if initial --config-file path is abs fixes #2231 With the change to the top-level .infracost folder, if an absolute path is used for config-file or path re... — committed to infracost/infracost by hugorut a year ago
- fix: change project paths to absolute path if initial --config-file path is abs (#2234) fixes #2231 With the change to the top-level .infracost folder, if an absolute path is used for config-file ... — committed to infracost/infracost by hugorut a year ago
Thanks for reporting this @swateek and the help debugging @nick-ppcprotect, a fix for this issue has been merged into master and will go out with the next release. I’ll ping you here when it’s live.
I was having the same issue - fixing version to 0.10.15 worked for me!
@nick-ppcprotect sorry about that - as a workaround until we get a fix out, you can use the
version
key ininfracost/actions/setup
to force the old CLI version to be used:Workaround until this issue is fixed
If you’re using the CLI binary directly, use this version, and for Docker use
infracost/infracost:ci-0.10.15
.Hello @swateek , @nick-ppcprotect & @confiq - I can confirm that the fix for this issue has been released as part of the v0.10.17 infracost CLI. Thanks for bringing this to our attention. I’m going to close this issue now, but please comment if you still are experiencing problems.
@hugorut looks like that fixed it. I was able to run locally without the error. Thank you!
@nick-ppcprotect / @swateek I’m struggling to replicate this issue locally, any additional information you could give would be great.
Here’s what I’ve tried so far. I have a project like so:
and my infracost.yml file has the following:
running
infracost breakdown --config-file infracost.yml
gives me a successful output.Some further questions for you both:
terraform-elasticache-redis
module look like? Does it include any third party modules?