turbot/aws_insights

Query: iam_user_manage_policies_hierarchy

Usage

powerpipe query aws_insights.query.iam_user_manage_policies_hierarchy

SQL

select
$1 as id,
$1 as title,
'role' as category,
null as from_id
-- Policies (attached to groups)
union select
policy_arn as id,
p.name as title,
'managed_policy' as category,
r.arn as from_id
from
aws_iam_role as r,
jsonb_array_elements_text(r.attached_policy_arns) as policy_arn,
aws_iam_policy as p
where
p.arn = policy_arn
and r.arn = $1
and r.account_id = split_part($1, ':', 5)
-- Inline Policies (defined on role)
union select
concat('inline_', i ->> 'PolicyName') as id,
i ->> 'PolicyName' as title,
'inline_policy' as category,
r.arn as from_id
from
aws_iam_role as r,
jsonb_array_elements(inline_policies_std) as i
where
arn = $1
and account_id = split_part($1, ':', 5)

Dashboards

The query is used in the dashboards: