Last active
August 20, 2017 03:53
-
-
Save alexcasalboni/07414d62290828ea03a14b4bf2157fd1 to your computer and use it in GitHub Desktop.
AWS IAM Policy body with Python and boto3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
iam = boto3.resource('iam') | |
def get_policy_body(arn, version_id=None): | |
""" Return IAM Policy JSON body """ | |
if version_id: | |
version = iam.PolicyVersion(arn, version_id) | |
else: | |
policy = iam.Policy(arn) | |
version = policy.default_version | |
return version.document | |
POLICY_ARN = "YOUR_POLICY_ARN" | |
body = get_policy_body(POLICY_ARN) # already a dict | |
print("Policy body: %s" % body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment