turbot/alicloud_insights

Query: ram_all_policies_for_user

Usage

powerpipe query alicloud_insights.query.ram_all_policies_for_user

SQL

-- Policies (attached to groups)
select
p.title as "Policy",
'Group: ' || g.title as "Via"
from
alicloud_ram_user as u,
alicloud_ram_policy as p,
jsonb_array_elements(u.groups) as user_groups
inner join alicloud_ram_group g on g.title = user_groups ->> 'GroupName',
jsonb_array_elements(g.attached_policy) as group_policy
where
group_policy ->> 'PolicyName' = p.title
and u.arn = $1
and u.account_id = split_part($1,':',4)
-- Policies (attached to user)
union select
p.title as "Policy",
'Attached to User' as "Via"
from
alicloud_ram_user as u,
jsonb_array_elements(u.attached_policy) as pol_arn,
alicloud_ram_policy as p
where
pol_arn ->> 'PolicyName' = p.title
and u.arn = $1
and u.account_id = split_part($1,':',4);

Dashboards

The query is used in the dashboards: