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

Infracost Appears Broken with terragrunt v0.37.1 + Terraform v1.2.1 #1694

Closed
armenr opened this issue May 29, 2022 · 16 comments
Closed

Infracost Appears Broken with terragrunt v0.37.1 + Terraform v1.2.1 #1694

armenr opened this issue May 29, 2022 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@armenr
Copy link

armenr commented May 29, 2022

System Info:

Infracost v0.10.0
Terraform v1.2.1
terragrunt version v0.37.1

I have been happily using infracost for a few weeks. I recently updated to the latest version of Terraform + Terragrunt, and when I attempt to run Infracost, I now get the following panic/exit:

❯ infracost breakdown --path .
Detected Terragrunt directory at .
panic: must not call MapVal with empty map

goroutine 82 [running]:
github.com/zclconf/go-cty/cty.MapVal(0x140001ee770?)
	github.com/zclconf/go-cty@v1.10.0/cty/value_init.go:212 +0x4ac
github.com/infracost/infracost/internal/providers/terraform.(*TerragruntHCLProvider).fetchDependencyOutputs(0x1400078e210, 0x140001b8900)
	github.com/infracost/infracost/internal/providers/terraform/terragrunt_hcl_provider.go:316 +0x4d0
github.com/infracost/infracost/internal/providers/terraform.(*TerragruntHCLProvider).runTerragrunt(0x1400078e210, 0x140001b8900)
	github.com/infracost/infracost/internal/providers/terraform/terragrunt_hcl_provider.go:183 +0x48
github.com/infracost/infracost/internal/providers/terraform.(*TerragruntHCLProvider).prepWorkingDirs.func1(0x140004c0930?)
	github.com/infracost/infracost/internal/providers/terraform/terragrunt_hcl_provider.go:141 +0x34
github.com/gruntwork-io/terragrunt/configstack.(*runningModule).runNow(0x14000063540)
	github.com/gruntwork-io/terragrunt@v0.36.9/configstack/running_module.go:239 +0x10c
github.com/gruntwork-io/terragrunt/configstack.(*runningModule).runModuleWhenReady(0x0?, 0x1400018e420)
	github.com/gruntwork-io/terragrunt@v0.36.9/configstack/running_module.go:202 +0x84
github.com/gruntwork-io/terragrunt/configstack.runModules.func1(0x1400056e9c0?)
	github.com/gruntwork-io/terragrunt@v0.36.9/configstack/running_module.go:172 +0x54
created by github.com/gruntwork-io/terragrunt/configstack.runModules
	github.com/gruntwork-io/terragrunt@v0.36.9/configstack/running_module.go:170 +0x78

Please advise. Thank you!

@hugorut
Copy link
Contributor

hugorut commented May 29, 2022

Hey @armenr. Thanks for reporting this. I believe this is the same issue as: #1641. We have a fix for this in a branch and is due to be released next week. It would be great if you could test it out and check if it fixes your issue. You can get it by running the following:

curl -o infracost-build https://infracost-public-dumps.s3.amazonaws.com/builds/2705/infracost-darwin-arm64
chmod +x ./infracost-build
./infracost-build breakdown --path=${TF_ROOT}

You'll need to replace infracost-darwin-arm64 with whichever OS system you use. Valid binaries are:

infracost-arm64.exe
infracost-darwin-amd64
infracost-darwin-arm64
infracost-linux-amd64
infracost-linux-arm64
infracost.exe

@hugorut hugorut added the bug Something isn't working label May 29, 2022
@armenr
Copy link
Author

armenr commented May 29, 2022

@hugorut - Just saw this, thank you! It's not working in my case... :-\

As a note - this was working fine 2 weeks ago, with the same terragrunt/terraform modules & codebase. There has been no major changes to my system, to our terragrunt/terraform, etc.

The only "thing that changed" is that I ran a brew update on terragrunt, terraform, and infracost.

I'm sorry for what I'm about to paste, but we use terragrunt extensively, and we isolate each of the "layers" of our infra into a "module" (to separate terragrunt state locks & concerns). This is going to be very hard to parse, but for the sake of being useful to you I'm including the full stack trace/error.

Please let me know what else I can provide or do to help you guys debug this. WE SINCERELY APPRECIATE ALL OF YOUR WORK AND ATTENTION! :)


Detected Terragrunt directory at config/dev-account/us-west-2/gravity-01
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory

Error: Failed to parse the Terragrunt code using the Terragrunt library:
12 errors occurred:
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/karpenter/karpenter (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* error downloading 'file:///Users/armenr/Development/my_project/terraform_aws': unexpected EOF
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/uat/5k (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_rds, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_elasticache, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_elasticsearch, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_amq, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_rds]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_elasticsearch (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]), finished with an error: error downloading 'file:///Users/armenr/Development/my_project/terraform_aws': unexpected EOF
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/kube-system/kube-state-metrics (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/apps/apps_wowza/terragrunt.hcl:73,51-73: Attempt to get attribute from null value; This value is null, so it does not have any attributes., and 2 other diagnostic(s)
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/kube-system/cluster-autoscaler (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/kube-system/aws-vpc-cni (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/kube-system/metrics-server (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/kube-system/external-dns (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* Cannot process module Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/kube-system/aws-load-balancer-controller (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc]) because one of its dependencies, Module /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks (excluded: false, assume applied: false, dependencies: [/Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/network_vpc, /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/storage/storage_efs, /Users/armenr/Development/my_project/terraform_aws/config/dev-account]), finished with an error: /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/terragrunt.hcl:68,50-62: Attempt to get attribute from null value; This value is null, so it does not have any attributes.
	* /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/apps/apps_aspera/terragrunt.hcl:72,51-73: Attempt to get attribute from null value; This value is null, so it does not have any attributes., and 2 other diagnostic(s)

Try setting --path to a Terraform plan JSON file. See https://infracost.io/troubleshoot for how to generate this.

real	0m2.678s
user	0m0.917s
sys	0m0.910s

@hugorut
Copy link
Contributor

hugorut commented May 29, 2022

Ok thanks @armenr , seems like we still have some work to go on fixing this issue. Could ask if I could ping you here again when we have a potential fix for you to try? It would be very useful for us.

In the meantime, if you run infracost breakdown --path . --terraform-force-cli in your directory this should work for you. We recently upgraded Infracost to v0.10.0 which upgraded behaviour to read Terraform/Terragrunt configuration files directly. However, we seem to be having a lot of problems with users Terragrunt setups.

@armenr
Copy link
Author

armenr commented May 29, 2022

Happy to help! Let me know. I'll keep an eye out. Thank you again @hugorut

@armenr
Copy link
Author

armenr commented May 29, 2022

YES! infracost breakdown --path . --terraform-force-cli THIS worked!

Thank you for the temporary workaround. It's obviously - probably - slower, but the important part (for our team) is that it works --> which means I can keep feeding useful cost data to our CEO & COO.

This tool is really great!

@hugorut
Copy link
Contributor

hugorut commented May 29, 2022

Great news @armenr! If it's possible, could you share how you're managing dependencies in the /Users/armenr/Development/my_project/terraform_aws/config/dev-account/us-west-2/gravity-01/compute_eks/ project. I'm having a hard time replicating this bug on my machine and it would be great to understand:

  1. what dependency blocks your using
  2. if you use dependencies block
  3. what dependency.outputs your fetching in that file
  4. how these dependency outputs are actually rendered in the Terraform code

Any help you could give would be amazing

@hugorut
Copy link
Contributor

hugorut commented May 30, 2022

Hey @armenr, I have another potential fix which I'd love you to test out if you could. I've uploaded it to the 3005 directory in our public dumps bucket. Could you test it out when you get a sec.

curl -o infracost-build https://infracost-public-dumps.s3.amazonaws.com/builds/3005/infracost-darwin-arm64
chmod +x ./infracost-build
./infracost-build breakdown --path=${TF_ROOT}

As with the prior build, you'll need to replace infracost-darwin-arm64 with whichever OS system you use. Valid binaries are:

infracost-arm64.exe
infracost-darwin-amd64
infracost-darwin-arm64
infracost-linux-amd64
infracost-linux-arm64
infracost.exe

@armenr
Copy link
Author

armenr commented May 31, 2022

@hugorut - having a look! Thank you!! Will report back!

@hugorut
Copy link
Contributor

hugorut commented May 31, 2022

Hey @armenr sorry could you use the 3005-02 build instead, I just updated yesterday evening:

curl -o infracost-build https://infracost-public-dumps.s3.amazonaws.com/builds/3005-02/infracost-darwin-arm64
chmod +x ./infracost-build
./infracost-build breakdown --path=${TF_ROOT}

🙏

@hugorut hugorut self-assigned this Jun 2, 2022
@alikhajeh1
Copy link
Member

@armenr ping - any luck?

@hugorut hugorut added the next release Issue will be resolved with the next release of Infracost. label Jul 20, 2022
@hugorut
Copy link
Contributor

hugorut commented Jul 20, 2022

Hey @armenr could you try this out with the latest release v0.10.8, we've made a lot of improvements to how we deal with Terragrunt values. Hopefully this should resolve your issue.

@armenr
Copy link
Author

armenr commented Jul 20, 2022

@hugorut - I was actually going to pop in here and apologize for my absence - I got really, really sick with the virus we all know keeps going around.

I pulled down the LATEST release 2 days ago, and it worked LIKE A CHARM! It was INCREDIBLY fast, and I didn't hit any bugs or bumps.

The progressive enhancements and changes you've applied have made a significant difference in the speed and usability of the tool, and I can't say I've encountered the same/original issue, or any NEW issues...and we have a fairly wacky and comlpex terragrunt setup...which infracost is handling like a champ.

Thanks again for everyone's hard work, and follow-up @hugorut & @alikhajeh1 !

@armenr armenr closed this as completed Jul 20, 2022
@hugorut
Copy link
Contributor

hugorut commented Jul 20, 2022

Thanks @armenr, glad it's working for you now 🚀

@hugorut hugorut removed the next release Issue will be resolved with the next release of Infracost. label Jul 20, 2022
@armenr
Copy link
Author

armenr commented Jul 20, 2022

@hugorut - Just as a note, I wanted to say that our business is deriving an immense value from this tool, both on the engineering side, and also on the budgeting/cost-management/cost-planning side.

You guys have built something that's really, really valuable. And we are very grateful. I'm glad you're productizing this. It's a hit.

@hugorut
Copy link
Contributor

hugorut commented Jul 20, 2022

nice to hear @armenr, I hope you have a play around with Infracost Cloud and give us your feedback. I know @alikhajeh1 would be thrilled to hear any suggestions or gripes you have with it!

@armenr
Copy link
Author

armenr commented Jul 20, 2022

@hugorut & @alikhajeh1 - We'd gladly beta test stuff for you guys as customers, if you're interested. We're called 5thKind, and our customers are some of the biggest names in Film/TV/Media. :)

Feel free to reach out to me - armen.rostamian@5thkind.com

https://www.linkedin.com/in/armenr/

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

No branches or pull requests

3 participants