Gurpal Singh

09/16/2022, 8:02 PM
i'm running this command from atlantis on a PR that modifies the
in a node group.
infracost breakdown \
  --format=json \
  --config-file infracost-generated.yml
  --log-level=info \
  --out-file=$INFRACOST_OUTPUT \
when i check the usage file, i can see that the file contains the live number of nodes for many of the node groups, (if i compare with what i see in the aws console), however, for some node groups it doesn't seem to get the number of nodes at all. you can see in the attached screenshot that a few node groups do not have a value for
. all node groups are in the same eks cluster.
8:16 PM
it seems like it's omitting the number of instances for those node groups where the PR is changing the
8:48 PM
another strange thing made a change to increase the min size on an autoscaling group from 19 --> 40.
# module.asg_worker_on_demand[0].aws_autoscaling_group.asg_launch_template will be updated in-place
  ~ resource "aws_autoscaling_group" "asg_launch_template" {
      ~ enabled_metrics           = [
          - "GroupAndWarmPoolDesiredCapacity",
          - "GroupAndWarmPoolTotalCapacity",
          - "GroupDesiredCapacity",
          - "GroupInServiceCapacity",
          - "GroupInServiceInstances",
          - "GroupMaxSize",
          - "GroupMinSize",
          - "GroupPendingCapacity",
          - "GroupPendingInstances",
          - "GroupStandbyCapacity",
          - "GroupStandbyInstances",
          - "GroupTerminatingCapacity",
          - "GroupTerminatingInstances",
          - "GroupTotalCapacity",
          - "GroupTotalInstances",
          - "WarmPoolDesiredCapacity",
          - "WarmPoolMinSize",
          - "WarmPoolPendingCapacity",
          - "WarmPoolTerminatingCapacity",
          - "WarmPoolTotalCapacity",
          - "WarmPoolWarmedCapacity",
        id                        = "prod-eks-worker-x"
      ~ max_size                  = 19 -> 40
      ~ min_size                  = 19 -> 40
        name                      = "prod-eks-worker-x"
        tags                      = []
        # (21 unchanged attributes hidden)
here is the syncd usage file:
# You can use this file to define resource usage estimates for Infracost to use when calculating
# the cost of usage-based resource, such as AWS S3 or Lambda.
# `infracost breakdown --usage-file infracost-usage.yml [other flags]`
# See <https://infracost.io/usage-file/> for docs
version: 0.1
    instances: 19 # Number of instances in the autoscaling group.
    operating_system: linux # Override the operating system of the instance, can be: linux, windows, suse, rhel.
    # reserved_instance_type: "" # Offering class for Reserved Instances, can be: convertible, standard.
    # reserved_instance_term: "" # Term for Reserved Instances, can be: 1_year, 3_year.
    # reserved_instance_payment_option: "" # Payment option for Reserved Instances, can be: no_upfront, partial_upfront, all_upfront.
    # monthly_cpu_credit_hrs: 0 # Number of hours in the month where the instance is expected to burst. Only applicable with t2, t3 & t4 Instance types. T2 requires credit_specification to be unlimited.
    # vcpu_count: 0 # Number of the vCPUs for the instance type. Only applicable with t2, t3 & t4 Instance types. T2 requires credit_specification to be unlimited.
    # monthly_hrs: 730.0
notice it says 19. and the comment says
1 project has no cost estimate changes.
8:54 PM
update: i can only get the project to show cost changes if i change the instance type. it doesn't seem to detect changes with instance count.
Ali (Infracost)

Ali (Infracost)

09/16/2022, 9:00 PM
Can you re-run with
--log-level debug
to see if that gives any clues? Are you running with
and it still doesn’t fetch the latest instance count from the AWS APIs? It’s been a while since I looked at that code but this file shows the TF params that are read, and this file shows the logic, I don’t think we look at the min instance count, I think it looks at desired_capacity
9:04 PM
BTW, one advanced use-case we have is this, I’m not sure if it’ll help you but just throwing it out there.

Gurpal Singh

09/16/2022, 9:15 PM
so just to recap my messages above. 1. yes, i'm using the sync-usage-file. 2. the first screenshot in this thread shows the sync'd usage file for a terraform plan that changes the
. You can see in the syncd usage file that the
have the
count omitted. Those node groups just so happen to be the node groups which i had changed the
for. 3. The other issue i thought there was that it wasn't responding to a terraform change to the
which actually makes sense. it only makes sense to determine costs on
which i'm not changing, so you can ignore that. it's just point 2 that i have an issue with then. i'll run debug and get back to you