Hi all, I am trying to work with infracost and I ...
# help
Hi all, I am trying to work with infracost and I have the following issue: The calculated number of a Terraform MSK cluster instances is wrong - I am getting the number using a "data" block. When I put a constant value it calculates well. My solution was to run
terraform show
and then use the file as input. Can I somehow use infracost directly on the module? or there is no other way in my case..
Hi could you possibly share a sanitized tf example that shows the issue?
In general, since infracost only has access to the tf/hcl we can’t get information from data blocks.
Copy code
module "msk_apache_kafka_cluster" {
  source                           = "cloudposse/msk-apache-kafka-cluster/aws"
  version                          = "2.3.0"
  enabled                          = local.enabled
  vpc_id                           = data.aws_vpc.this.id
  subnet_ids                       = data.aws_subnets.this.ids
  kafka_version                    = "3.2.0"
  broker_instance_type             = var.broker_instance_type
  broker_volume_size               = var.broker_volume_size
  storage_autoscaling_max_capacity = var.storage_autoscaling_max_capacity
  client_sasl_scram_enabled        = true
  encryption_at_rest_kms_key_arn   = data.aws_kms_key.this.arn

  client_sasl_scram_secret_association_arns = [
  properties = {
    "auto.create.topics.enable" = true
  allowed_security_group_ids = [module.security_group.id]

  context = module.this.context
This is a module which creates the MSK cluster. The
is gain from a data block. I have private 3 subnets for my region - which received from data. As I hear from you, infracost does not execute TF, thus can't access data. This is the output for this module:
Copy code
 ├─ Instance (kafka.t3.small)                                           19,710  hours                      $1,036.75 
 └─ Storage (autoscaling)                                                   27  GB                             $3.21 
 OVERALL TOTAL                                                                                             $1,040.36