Control: Block and Boot volumes attached to stopped instances should be reviewed
Instances that are stopped may no longer need any volumes attached.
Run the control in your terminal:
steampipe check oci_thrifty.control.boot_and_block_volume_attached_stopped_instance
Snapshot and share results via Steampipe Cloud:
steampipe loginsteampipe check --share oci_thrifty.control.boot_and_block_volume_attached_stopped_instance
Plugins & Tables
-- Listing core boot volumes and block volumes associated with running instanceswith vols_with_instances as (selectv.instance_id,v.volume_id as volume_idfromoci_core_volume_attachment as vinner join oci_core_instance as i on i.id = v.instance_idwherei.lifecycle_state = 'RUNNING'unionselectb.instance_id,b.boot_volume_id as volume_idfromoci_core_boot_volume_attachment as binner join oci_core_instance as i on i.id = b.instance_idwherei.lifecycle_state = 'RUNNING'),-- Listing all volumes of both boot volumes and block volumesall_volumes as (selectid,compartment_id,_ctx,tenant_id,region,display_namefromoci_core_volumeunionselectid,compartment_id,_ctx,tenant_id,region,display_namefromoci_core_boot_volume) -- Listing the volumes based on associationsselecta.id as resource,casewhen v.volume_id is null then 'alarm'else 'ok'end as status,casewhen v.volume_id is null then a.display_name || ' not associated with running instance.'else a.display_name || ' associated with running instance.'end as reason,coalesce(c.name, 'root') as compartment,a.regionfromall_volumes as aleft join vols_with_instances as v on v.volume_id = a.idleft join oci_identity_compartment as c on c.id = a.compartment_id;