turbot/aws_insights

Query: iam_all_policies_for_role

Usage

powerpipe query aws_insights.query.iam_all_policies_for_role

SQL

-- Policies (attached to groups)
select
p.name as "Policy",
policy_arn as "ARN",
'Attached to Role' as "Via"
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
i ->> 'PolicyName' as "Policy",
'N/A' as "ARN",
'Inline' as "Via"
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: