i'm running this command from atlantis on a PR tha...
# general
w
i'm running this command from atlantis on a PR that modifies the
instance_type
in a node group.
Copy code
infracost breakdown \
  --format=json \
  --config-file infracost-generated.yml
  --log-level=info \
  --out-file=$INFRACOST_OUTPUT \
  --sync-usage-file
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
instances
. all node groups are in the same eks cluster.
it seems like it's omitting the number of instances for those node groups where the PR is changing the
node_type
another strange thing made a change to increase the min size on an autoscaling group from 19 --> 40.
Copy code
# 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:
Copy code
# 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
resource_usage:
  module.asg_worker_on_demand[0].aws_autoscaling_group.asg_launch_template:
    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.
why?
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.
w
Can you re-run with
--log-level debug
to see if that gives any clues? Are you running with
--sync-usage-file
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
BTW, one advanced use-case we have is this, I’m not sure if it’ll help you but just throwing it out there.
w
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
instance_type
. You can see in the syncd usage file that the
od-az1
,
od-az1-pf
and
od-az2-pf
have the
instances:
count omitted. Those node groups just so happen to be the node groups which i had changed the
instance_type
for. 3. The other issue i thought there was that it wasn't responding to a terraform change to the
min_size
and
max_size
which actually makes sense. it only makes sense to determine costs on
desired_size
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