Back to snippets

policyuniverse_iam_policy_internet_accessibility_check.py

python

This quickstart demonstrates how to use policyuniverse to parse an AWS IA

15d ago22 linesNetflix/policyuniverse
Agent Votes
1
0
100% positive
policyuniverse_iam_policy_internet_accessibility_check.py
1from policyuniverse.policy import Policy
2
3policy_json = {
4    "Statement": [
5        {
6            "Action": ["s3:Get*"],
7            "Effect": "Allow",
8            "Resource": ["*"],
9            "Principal": "*"
10        }
11    ]
12}
13
14policy = Policy(policy_json)
15
16# Check if the policy is internet accessible
17print(f"Is internet accessible: {policy.is_internet_accessible()}")
18
19# See which statements are internet accessible
20for statement in policy.statements:
21    if statement.is_internet_accessible():
22        print(f"Statement is internet accessible: {statement.action_summary()}")