infracost: Error: Failed to parse the Terragrunt code using the Terragrunt library:

Hello and thank you for this great tool. I have been using infracost with my cloud provider credentials and wanted to update to hcl paring for faster analysis. I am having a problem with CIDR blocks.

Here is the output for terragrunt output on my vpc. image

Note that I can successfully execute terragrunt plan with the following config. image

Here is my terragrunt config which causes infracost to throw the following error

image

* Recovering panic while parsing '/Users/denizgokcin/codes/fulfillment-api/terragrunt/app/qa/sg/rds/fulfillment/terragrunt.hcl'. Got error of type 'string': unknown type implementation

If I comment out the cidr block line, infracost works fine. image

What might be the reason for hcl parsing to behave like this? Any help is appreciated!!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

Thanks, @dgokcin; these changes are now live in the v0.10.5 version of Infracost. I appreciate your help in getting this resolved. I’ve added your details to our swag roundup list, so keep your eyes peeled for an email in your inbox asking for more information on how we can send you 🧦 ! Thanks again

@dgokcin great news! It should be out in the 0.10.4 release later in the week (tomorrow or thursday)

Attaching the private subnet block. I also would like to note that this block was taken from here.

resource "aws_subnet" "private" {
  count = var.create_vpc && length(var.private_subnets) > 0 ? length(var.private_subnets) : 0

  vpc_id                          = local.vpc_id
  cidr_block                      = var.private_subnets[count.index]
  availability_zone               = length(regexall("^[a-z]{2}-", element(var.azs, count.index))) > 0 ? element(var.azs, count.index) : null
  availability_zone_id            = length(regexall("^[a-z]{2}-", element(var.azs, count.index))) == 0 ? element(var.azs, count.index) : null
  assign_ipv6_address_on_creation = var.private_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.private_subnet_assign_ipv6_address_on_creation

  ipv6_cidr_block = var.enable_ipv6 && length(var.private_subnet_ipv6_prefixes) > 0 ? cidrsubnet(aws_vpc.this[0].ipv6_cidr_block, 8, var.private_subnet_ipv6_prefixes[count.index]) : null

  tags = merge(
    {
      "Name" = format(
        "%s-${var.private_subnet_suffix}-%s",
        var.name,
        element(var.azs, count.index),
      )
    },
    var.tags,
    var.private_subnet_tags,
  )
}