Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed calculating breakdown cost of google_compute_region_instance_group_manager #3087

Open
YuvalFireFly opened this issue May 30, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@YuvalFireFly
Copy link

I am running Infracost on my Terraform plan output. I use API requests for the /breakdown path.
In my plan, I have an existing resource with no changes with the type google_compute_region_instance_group_manager.
When running Infracost, the results of the past breakdown of the monthly cost of the resource seem correct, while the results of the breakdown are always zero. Therefore, the monthly cost diff always shows a decrease in cost even when no resources were changed.

HCL code:

resource "google_compute_region_instance_group_manager" "instance_group_us_east4" {
  provider = google-beta
  name     = "instance-group-us-east4"

  base_instance_name               = "instance-us-east4"
  region                           = "us-east4"
  distribution_policy_zones        = ["us-east4-a", "us-east4-b", "us-east4-c"]
  distribution_policy_target_shape = "EVEN"

  version {
    instance_template = data.google_compute_instance_template.instance_template.self_link
  }

  auto_healing_policies {
    health_check      = google_compute_health_check.instance_health_check.self_link
    initial_delay_sec = 120
  }

  update_policy {
    instance_redistribution_type   = "PROACTIVE"
    max_surge_fixed                = 3
    max_unavailable_fixed          = 3
    minimal_action                 = "REPLACE"
    replacement_method             = "SUBSTITUTE"
    type                           = "OPPORTUNISTIC"
    most_disruptive_allowed_action = "REPLACE"
  }

  instance_lifecycle_policy {
    force_update_on_repair = "YES"
  }

  lifecycle {
    ignore_changes = [version]
  }
}

Plan output values:

{
  "address": "google_compute_region_instance_group_manager.instance_group_us_east4",
  "mode": "managed",
  "type": "google_compute_region_instance_group_manager",
  "name": "instance_group_us_east4",
  "provider_name": "registry.terraform.io/hashicorp/google-beta",
  "change": {
    "actions": [
      "no-op"
    ],
    "before": {
      "all_instances_config": [
        
      ],
      "auto_healing_policies": [
        {
          "health_check": "https://www.googleapis.com/compute/beta/projects/firefly/global/healthChecks/firefly-instance",
          "initial_delay_sec": 120
        }
      ],
      "base_instance_name": "instance-us-east4",
      "description": "",
      "distribution_policy_target_shape": "EVEN",
      "distribution_policy_zones": [
        "us-east4-a",
        "us-east4-b",
        "us-east4-c"
      ],
      "fingerprint": "WlZjqiGxh_k=",
      "id": "projects/firefly/regions/us-east4/instanceGroupManagers/instance-group-us-east4",
      "instance_group": "https://www.googleapis.com/compute/v1/projects/firefly/regions/us-east4/instanceGroups/instance-group-us-east4",
      "instance_lifecycle_policy": [
        {
          "force_update_on_repair": "YES"
        }
      ],
      "list_managed_instances_results": "PAGELESS",
      "name": "firefly-instance-group-us-east4",
      "named_port": [
        
      ],
      "project": "firefly",
      "region": "us-east4",
      "self_link": "https://www.googleapis.com/compute/v1/projects/firefly/regions/us-east4/instanceGroupManagers/instance-group-us-east4",
      "stateful_disk": [
        
      ],
      "stateful_external_ip": [
        
      ],
      "stateful_internal_ip": [
        
      ],
      "status": [
        {
          "all_instances_config": [
            {
              "effective": true
            }
          ],
          "is_stable": false,
          "stateful": [
            {
              "has_stateful_config": false,
              "per_instance_configs": [
                {
                  "all_effective": true
                }
              ]
            }
          ],
          "version_target": [
            {
              "is_reached": true
            }
          ]
        }
      ],
      "target_pools": [
        
      ],
      "target_size": 120,
      "timeouts": null,
      "update_policy": [
        {
          "instance_redistribution_type": "PROACTIVE",
          "max_surge_fixed": 3,
          "max_surge_percent": 0,
          "max_unavailable_fixed": 3,
          "max_unavailable_percent": 0,
          "min_ready_sec": 0,
          "minimal_action": "REPLACE",
          "most_disruptive_allowed_action": "REPLACE",
          "replacement_method": "SUBSTITUTE",
          "type": "OPPORTUNISTIC"
        }
      ],
      "version": [
        {
          "instance_template": "https://www.googleapis.com/compute/v1/projects/firefly/global/instanceTemplates/instance-template-us-east4",
          "name": "",
          "target_size": [
            
          ]
        }
      ],
      "wait_for_instances": false,
      "wait_for_instances_status": "STABLE"
    },
    "after": {
      "all_instances_config": [
        
      ],
      "auto_healing_policies": [
        {
          "health_check": "https://www.googleapis.com/compute/beta/projects/firefly/global/healthChecks/firefly-instance",
          "initial_delay_sec": 120
        }
      ],
      "base_instance_name": "instance-us-east4",
      "description": "",
      "distribution_policy_target_shape": "EVEN",
      "distribution_policy_zones": [
        "us-east4-a",
        "us-east4-b",
        "us-east4-c"
      ],
      "fingerprint": "WlZjqiGxh_k=",
      "id": "projects/firefly/regions/us-east4/instanceGroupManagers/instance-group-us-east4",
      "instance_group": "https://www.googleapis.com/compute/v1/projects/firefly/regions/us-east4/instanceGroups/instance-group-us-east4",
      "instance_lifecycle_policy": [
        {
          "force_update_on_repair": "YES"
        }
      ],
      "list_managed_instances_results": "PAGELESS",
      "name": "firefly-instance-group-us-east4",
      "named_port": [
        
      ],
      "project": "firefly",
      "region": "us-east4",
      "self_link": "https://www.googleapis.com/compute/v1/projects/firefly/regions/us-east4/instanceGroupManagers/instance-group-us-east4",
      "stateful_disk": [
        
      ],
      "stateful_external_ip": [
        
      ],
      "stateful_internal_ip": [
        
      ],
      "status": [
        {
          "all_instances_config": [
            {
              "effective": true
            }
          ],
          "is_stable": false,
          "stateful": [
            {
              "has_stateful_config": false,
              "per_instance_configs": [
                {
                  "all_effective": true
                }
              ]
            }
          ],
          "version_target": [
            {
              "is_reached": true
            }
          ]
        }
      ],
      "target_pools": [
        
      ],
      "target_size": 120,
      "timeouts": null,
      "update_policy": [
        {
          "instance_redistribution_type": "PROACTIVE",
          "max_surge_fixed": 3,
          "max_surge_percent": 0,
          "max_unavailable_fixed": 3,
          "max_unavailable_percent": 0,
          "min_ready_sec": 0,
          "minimal_action": "REPLACE",
          "most_disruptive_allowed_action": "REPLACE",
          "replacement_method": "SUBSTITUTE",
          "type": "OPPORTUNISTIC"
        }
      ],
      "version": [
        {
          "instance_template": "https://www.googleapis.com/compute/v1/projects/firefly/global/instanceTemplates/instance-template-us-east4",
          "name": "",
          "target_size": [
            
          ]
        }
      ],
      "wait_for_instances": false,
      "wait_for_instances_status": "STABLE"
    },
    "after_unknown": {
      
    },
    "before_sensitive": {
      "all_instances_config": [
        
      ],
      "auto_healing_policies": [
        {
          
        }
      ],
      "distribution_policy_zones": [
        false,
        false,
        false
      ],
      "instance_lifecycle_policy": [
        {
          
        }
      ],
      "named_port": [
        
      ],
      "stateful_disk": [
        
      ],
      "stateful_external_ip": [
        
      ],
      "stateful_internal_ip": [
        
      ],
      "status": [
        {
          "all_instances_config": [
            {
              
            }
          ],
          "stateful": [
            {
              "per_instance_configs": [
                {
                  
                }
              ]
            }
          ],
          "version_target": [
            {
              
            }
          ]
        }
      ],
      "target_pools": [
        
      ],
      "update_policy": [
        {
          
        }
      ],
      "version": [
        {
          "target_size": [
            
          ]
        }
      ]
    },
    "after_sensitive": {
      "all_instances_config": [
        
      ],
      "auto_healing_policies": [
        {
          
        }
      ],
      "distribution_policy_zones": [
        false,
        false,
        false
      ],
      "instance_lifecycle_policy": [
        {
          
        }
      ],
      "named_port": [
        
      ],
      "stateful_disk": [
        
      ],
      "stateful_external_ip": [
        
      ],
      "stateful_internal_ip": [
        
      ],
      "status": [
        {
          "all_instances_config": [
            {
              
            }
          ],
          "stateful": [
            {
              "per_instance_configs": [
                {
                  
                }
              ]
            }
          ],
          "version_target": [
            {
              
            }
          ]
        }
      ],
      "target_pools": [
        
      ],
      "update_policy": [
        {
          
        }
      ],
      "version": [
        {
          "target_size": [
            
          ]
        }
      ]
    }
  }
}

Breakdown response:

{
    "name": "google_compute_region_instance_group_manager.instance_group_us_east4",
    "resourceType": "google_compute_region_instance_group_manager",
    "metadata": {},
    "hourlyCost": "0",
    "monthlyCost": "0",
    "costComponents": [
        {
            "name": "Instance usage (Linux/UNIX, on-demand, )",
            "unit": "hours",
            "hourlyQuantity": "120",
            "monthlyQuantity": "87600",
            "price": "0",
            "hourlyCost": "0",
            "monthlyCost": "0",
            "priceNotFound": true
        }
    ]
}
@aliscott aliscott added the bug Something isn't working label May 30, 2024
@aliscott
Copy link
Member

@YuvalFireFly one thing I'm noticing is the instance type is missing? I wonder if this is causing the issue.

@YuvalFireFly
Copy link
Author

YuvalFireFly commented May 30, 2024

@YuvalFireFly one thing I'm noticing is the instance type is missing? I wonder if this is causing the issue.

@aliscott What do you mean by instance type? There is no such field in google_compute_region_instance_group_manager

@aliscott
Copy link
Member

@YuvalFireFly, sorry I mean machine_type, which it gets from the google_compute_instance_template resource.

@YuvalFireFly
Copy link
Author

@aliscott I guess that it gets it from the instace_template self-link

"version": [
  {
    "instance_template": "https://www.googleapis.com/compute/v1/projects/firefly/global/instanceTemplates/instance-template-us-east4",
    "name": "",
    "target_size": [
      
    ]
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants