turbot / steampipe-plugin-aws

Use SQL to instantly query AWS resources across regions and accounts. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/aws
Apache License 2.0
190 stars 104 forks source link

EBS volume attachments for unattached volume is not null #1366

Closed eyalliss closed 2 years ago

eyalliss commented 2 years ago

Describe the bug I'm querying for unattached EBS volumes daily. select volume_id, size, attachments from aws_all.aws_ebs_volume as v where state = 'available' and attachments is null

I've copied it from the examples in the steampipe.io site. It used to work until last update Now attachments is no longer null it is empty array instead, so I modified the script to be: select volume_id, size, attachments from aws_all.aws_ebs_volume as v where state = 'available' and attachments = '[]' The example still on site https://hub.steampipe.io/mods/turbot/aws_thrifty/queries/unattached_ebs_volumes

Steampipe version (steampipe -v) steampipe version 0.16.4

Plugin version (steampipe plugin list) +--------------------------------------------------+---------+----------------------------+ | Name | Version | Connections | +--------------------------------------------------+---------+----------------------------+ | hub.steampipe.io/plugins/turbot/aws@latest | 0.80.0 | aws_dev,aws_sanity,aws_all | | hub.steampipe.io/plugins/turbot/steampipe@latest | 0.6.0 | steampipe | +--------------------------------------------------+---------+----------------------------+

To reproduce select volume_id, size, attachments from aws_all.aws_ebs_volume as v where state = 'available' and attachments is null

Expected behavior It should list the unattached volumes and instead I'm getting an empty result

Additional context Add any other context about the problem here.

misraved commented 2 years ago

Hello @eyalliss, while digging into this bug, we figured out that the SDK(AWS Go SDK V2) changed the API response from null to [] in the event of EBS volumes not having any attachments, hence the attachments column changed the response from null to [].

It might become cumbersome to change the code each time an API response changes, keeping that in mind we decided to update all the instances of aws_ebs_volume queries where the attachments column is being queried.

Updates made across different mods: https://github.com/turbot/steampipe-mod-aws-insights/pull/206 https://github.com/turbot/steampipe-mod-aws-thrifty/pull/102

Update made to the aws_ebs_volume table doc: https://github.com/turbot/steampipe-plugin-aws/pull/1368

Once again, thank you for catching the bug, which had slipped from our radar 👍 .