Skip to content

Unrelated Resources Incorrectly Flagged as Removed in Plan #68

@FayizMohideen

Description

@FayizMohideen

Bug Report: openinfraquote incorrectly identifies data resources as removed

Summary

openinfraquote is incorrectly identifying Terraform unrelated resources as being removed when processing a plan.json file. This leads to erroneous cost estimations because these resources aren't part of actual infrastructure changes. The bug seems to be in how the tool processes the plan, as it's considering unrelated blocks instead of focusing only on resource_changes with create or delete actions.
The issue specifically is that it includes prices for data block changes that can cause the final value to be incorrect.


Steps to Reproduce

  • Unsure of the steps to reproduce but it seems to have something to do with data resource blocks.
  • A plan file can be shared privately to be used to demonstrate this behaviour.
  • This behaviour may be related to the depends_on block of resources outputted by oiq match

Steps to Identify this behavior

  1. Generate a Terraform plan JSON file:
    terraform plan -out=tfplan && terraform show -json tfplan > plan.json
  2. Run openinfraquote against the plan.json file:
    oiq match --pricesheet prices.csv plan.json
  3. Filter the output to see removed resources:
    oiq match --pricesheet prices.csv plan.json | jq '.matches[] | select(.change == "remove") | .resource.address'

Expected Behavior

openinfraquote should only consider resources with a change_actions of create or delete from the resource_changes block. The output should not include any unrelated resources.


Actual Behavior

The jq command reveals that openinfraquote lists unrelated resources as being removed, which is incorrect.


Proposed Fix

Modify the oiq parser to only look at resource_changes[] in the plan json. This will ensure that only genuine infrastructure changes are considered for cost analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions