turbot/aws_insights

Query: ec2_ami_shared_with

Usage

powerpipe query aws_insights.query.ec2_ami_shared_with

Steampipe Tables

SQL

with sharing as (
select
lp
from
aws_ec2_ami as ami,
jsonb_array_elements(ami.launch_permissions) as lp
where image_id = $1
)
-- Accounts
select
lp ->> 'UserId' as "Shared With"
from
sharing
where
lp ->> 'UserId' is not null
-- Organization
union all
select
lp ->> 'OrganizationArn' as "Shared With"
from
sharing
where
lp ->> 'OrganizationArn' is not null
-- Organizational Unit
union all
select
lp ->> 'OrganizationalUnitArn' as "Shared With"
from
sharing
where
lp ->> 'OrganizationalUnitArn' is not null

Dashboards

The query is used in the dashboards: