-
Notifications
You must be signed in to change notification settings - Fork 17
Description
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
- Generate a Terraform plan JSON file:
terraform plan -out=tfplan && terraform show -json tfplan > plan.json - Run
openinfraquoteagainst theplan.jsonfile:
oiq match --pricesheet prices.csv plan.json - 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.