We are going to start out by gathering the inline policy documents attached to our user. Luckily for us, the entire document for any inline policies is included with our user. We will add the following code to our script:
# Create an empty list that will hold all the policies related to our usermy_policies = []# Check if any inline policies are attached to my userif current_user.get('UserPolicyList'): # Iterate through the inline policies to pull their documents for policy in current_user['UserPolicyList']: # Add the policy to our list my_policies.append(policy['PolicyDocument'])
Now my_policies should include all the inline policies that are directly attached to our user. Next, we will gather the managed ...