broad-zoo-34077
06/29/2022, 10:22 AMlittle-author-61621
stocky-salesmen-15167
06/29/2022, 10:25 AMinfracost breakdown --path . --sync-usage-file --usage-file /tmp/ignore.yml
I see no usage is fetched for the S3 resource which is created inside the module I call in my main.tf.stocky-salesmen-15167
06/29/2022, 10:26 AMstocky-salesmen-15167
06/29/2022, 10:28 AM…mock
things coming from.
Are the tags used to fetch the corresponding metrics from cloudwatch?little-author-61621
aws
cli uses. So you might need to export creds with AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
env variables.
2. S3 storage should be synced by default but for S3 requests to appear in CloudWatch you’ll need to set up a metrics filter in AWS.little-author-61621
Are the tags used to fetch the corresponding metrics from cloudwatch?Those tags we pull from your Terraform code and just display next to the resource here, they’re not used to sync usage - we use the bucket name for syncing.
stocky-salesmen-15167
06/29/2022, 10:35 AMmock
is solved as I forgot to point the TF backend to the TFC workspace, so no workspace variables were fetched.
I’ll dig into the metrics filter.
Thanks so far.little-author-61621
--log-level=debug
there might be more clues.stocky-salesmen-15167
06/29/2022, 10:44 AMlittle-author-61621
--path
pointing to that? Maybe it’s not getting the correct bucket name when doing HCL parsing.stocky-salesmen-15167
06/29/2022, 10:49 AMstocky-salesmen-15167
06/29/2022, 11:30 AMrandom_pet
. it seems that infracost’s HCL parsing is not fully working if resource name attributes are using random_pets
… that’s probably the NPE I’m seeingstocky-salesmen-15167
06/29/2022, 11:32 AMtime="2022-06-29T13:32:26+02:00" level=debug parser=terraform_hcl msg="could not evaluate value for attr: id err: runtime error: invalid memory address or nil pointer dereference\ngoroutine 70 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x65\<http://ngithub.com/infracost/infracost/internal/hcl.(*Attribute).value.func1()\n\tgithub.com/infracost/infracost/internal/hcl/attribute.go:71|ngithub.com/infracost/infracost/internal/hcl.(*Attribute).value.func1()\n\tgithub.com/infracost/infracost/internal/hcl/attribute.go:71> +0x79\npanic({0x2995700, 0x4203840})\n\truntime/panic.go:838 +0x207\<http://ngithub.com/zclconf/go-cty/cty.Type.FriendlyName(...)\n\tgithub.com/zclconf/go-cty@v1.10.0/cty/type.go:47\ngithub.com/hashicorp/hcl/v2/hclsyntax.describeConditionalTypeMismatch(|ngithub.com/zclconf/go-cty/cty.Type.FriendlyName(...)\n\tgithub.com/zclconf/go-cty@v1.10.0/cty/type.go:47\ngithub.com/hashicorp/hcl/v2/hclsyntax.describeConditionalTypeMismatch(>{{0x0?, 0x0?}}, {{0x32d5ca0?, 0xc000200255?}})\n\<http://tgithub.com/hashicorp/hcl/v2@v2.12.0/hclsyntax/expression.go:833|tgithub.com/hashicorp/hcl/v2@v2.12.0/hclsyntax/expression.go:833> +0x3ee\<http://ngithub.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(0xc0001ae2a0|ngithub.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(0xc0001ae2a0>, 0xc000b271b8)\n\<http://tgithub.com/hashicorp/hcl/v2@v2.12.0/hclsyntax/expression.go:620|tgithub.com/hashicorp/hcl/v2@v2.12.0/hclsyntax/expression.go:620> +0x1306\<http://ngithub.com/infracost/infracost/internal/hcl.(*Attribute).value(0xc000cd8320|ngithub.com/infracost/infracost/internal/hcl.(*Attribute).value(0xc000cd8320>, 0x0)\n\<http://tgithub.com/infracost/infracost/internal/hcl/attribute.go:77|tgithub.com/infracost/infracost/internal/hcl/attribute.go:77> +0xce\<http://ngithub.com/infracost/infracost/internal/hcl.(*Attribute).Value(...)\n\tgithub.com/infracost/infracost/internal/hcl/attribute.go:65\ngithub.com/infracost/infracost/internal/hcl.(*Block).Values(0xc000d2c8e0?)\n\tgithub.com/infracost/infracost/internal/hcl/block.go:740|ngithub.com/infracost/infracost/internal/hcl.(*Attribute).Value(...)\n\tgithub.com/infracost/infracost/internal/hcl/attribute.go:65\ngithub.com/infracost/infracost/internal/hcl.(*Block).Values(0xc000d2c8e0?)\n\tgithub.com/infracost/infracost/internal/hcl/block.go:740> +0xf0\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).getValuesByBlockType|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).getValuesByBlockType>(0xc000a48b40, {0x2e86fa4, 0x6})\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:469|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:469> +0x285\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateStep(0xc000a48b40|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateStep(0xc000a48b40>, 0x1)\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:192|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:192> +0x14b\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluate|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluate>(0xc000a48b40, {0x0?, 0x0?, 0x0?})\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:170|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:170> +0x7c\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).Run(0xc000a48b40)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:141|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).Run(0xc000a48b40)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:141> +0xc5\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateModules(0xc000a46900)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:240|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateModules(0xc000a46900)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:240> +0x333\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateStep|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateStep>(0xc000a46900, 0x0)\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:203|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:203> +0x3b3\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluate|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluate>(0xc000a46900, {0x0?, 0x0?, 0x0?})\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:170|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:170> +0x7c\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).Run(0xc000a46900)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:145|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).Run(0xc000a46900)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:145> +0x108\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateModules(0xc00095d0e0)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:240|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateModules(0xc00095d0e0)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:240> +0x333\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateStep|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluateStep>(0xc00095d0e0, 0x0)\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:203|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:203> +0x3b3\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluate|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).evaluate>(0xc00095d0e0, {0x0?, 0x0?, 0x0?})\n\<http://tgithub.com/infracost/infracost/internal/hcl/evaluator.go:170|tgithub.com/infracost/infracost/internal/hcl/evaluator.go:170> +0x7c\<http://ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).Run(0xc00095d0e0)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:145|ngithub.com/infracost/infracost/internal/hcl.(*Evaluator).Run(0xc00095d0e0)\n\tgithub.com/infracost/infracost/internal/hcl/evaluator.go:145> +0x108\<http://ngithub.com/infracost/infracost/internal/hcl.(*Parser).ParseDirectory(0xc0003e62c0)\n\tgithub.com/infracost/infracost/internal/hcl/parser.go:329|ngithub.com/infracost/infracost/internal/hcl.(*Parser).ParseDirectory(0xc0003e62c0)\n\tgithub.com/infracost/infracost/internal/hcl/parser.go:329> +0x4b0\<http://ngithub.com/infracost/infracost/internal/providers/terraform.(*HCLProvider).Modules(0xc00045a240)\n\tgithub.com/infracost/infracost/internal/providers/terraform/hcl_provider.go:248|ngithub.com/infracost/infracost/internal/providers/terraform.(*HCLProvider).Modules(0xc00045a240)\n\tgithub.com/infracost/infracost/internal/providers/terraform/hcl_provider.go:248> +0x139\<http://ngithub.com/infracost/infracost/internal/providers/terraform.(*HCLProvider).LoadPlanJSONs(0xc00045a240)\n\tgithub.com/infracost/infracost/internal/providers/terraform/hcl_provider.go:216|ngithub.com/infracost/infracost/internal/providers/terraform.(*HCLProvider).LoadPlanJSONs(0xc00045a240)\n\tgithub.com/infracost/infracost/internal/providers/terraform/hcl_provider.go:216> +0x4a\<http://ngithub.com/infracost/infracost/internal/providers/terraform.(*HCLProvider).LoadResources(0xc0001906c0|ngithub.com/infracost/infracost/internal/providers/terraform.(*HCLProvider).LoadResources(0xc0001906c0>?, 0x4?)\n\<http://tgithub.com/infracost/infracost/internal/providers/terraform/hcl_provider.go:171|tgithub.com/infracost/infracost/internal/providers/terraform/hcl_provider.go:171> +0x35\nmain.(*parallelRunner).runProjectConfig(0xc000371230, 0xc0003517c0)\n\<http://tgithub.com/infracost/infracost/cmd/infracost/run.go:474|tgithub.com/infracost/infracost/cmd/infracost/run.go:474> +0x1269\nmain.(*parallelRunner).run.func1()\n\<http://tgithub.com/infracost/infracost/cmd/infracost/run.go:310|tgithub.com/infracost/infracost/cmd/infracost/run.go:310> +0x1c5\<http://ngolang.org/x/sync/errgroup.(*Group).Go.func1()\n\tgolang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57|ngolang.org/x/sync/errgroup.(*Group).Go.func1()\n\tgolang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57> +0x67\ncreated by <http://golang.org/x/sync/errgroup.(*Group).Go\n\tgolang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:54|golang.org/x/sync/errgroup.(*Group).Go\n\tgolang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:54> +0x8d\n"
stocky-salesmen-15167
06/29/2022, 11:38 AMresource "random_pet" "s3" {
}
locals {
pet = (var.ci_mode == true ? "ci-pet" : random_pet.s3.id)
}
resource "aws_s3_bucket" "public" {
bucket = "testbucket-${local.pet}"
}
stocky-salesmen-15167
06/29/2022, 11:40 AMlocal.pet
in between?!little-author-61621
little-author-61621
getting a plan from TFC is nasty and only possible via API, but anyway … got it.Yes, I know this pain. We have to this like https://gitlab.com/infracost/infracost-gitlab-ci/-/blob/master/examples/plan-json/terraform-cloud-enterprise/README.md#L43-53 in our examples currently.
mysterious-teacher-68276
06/29/2022, 12:14 PMrandom_pet.s3.id
will evaluate each time as a different mock
value, this is where the -mock
values are coming from in the dashboard/share link. HCL parsing doesn’t have the idea of state, so random generation will be random each time. So if you’re trying to sync a bucket which relies on a random value this won’t work. Or at least I don’t think it will. The panic debug log looks like a problem generating these mock attributes, but I’m not entirely sure this should matter. Something I’ll fix anyway.stocky-salesmen-15167
06/29/2022, 12:17 PMstocky-salesmen-15167
06/29/2022, 12:18 PMlittle-author-61621
So if you’re trying to sync a bucket which relies on a random value this won’t work.Yep, this is something we have some ideas on how to get round - e.g. query buckets that could match, or introduce some tag matching.
The panic debug log looks like a problem generating these mock attributes, but I’m not entirely sure this should matter.Thanks @mysterious-teacher-68276. @stocky-salesmen-15167 are you able to file an issue for this panic?
stocky-salesmen-15167
06/29/2022, 12:19 PMlittle-author-61621
Sorry, for this little rabbit hole I went into.I love rabbit holes! 🐰
stocky-salesmen-15167
06/29/2022, 12:59 PMlittle-author-61621