Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gene1wood/cc9d7e857f9114626b52 to your computer and use it in GitHub Desktop.
Save gene1wood/cc9d7e857f9114626b52 to your computer and use it in GitHub Desktop.
Code snipit to create the Security Monkey trusted IAM role
import boto.iam
conn_iam = boto.iam.connect_to_region('universal')
role_name='SecurityMonkeyInstanceProfile'
assume_role_policy_document = '''{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'''
policy_document = '''{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ses:SendEmail"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "*"
}
]
}'''
create_role_result = conn_iam.create_role(role_name=role_name,
assume_role_policy_document=assume_role_policy_document)
put_role_policy_result = conn_iam.put_role_policy(role_name=role_name,
policy_name="SecurityMonkeyLaunchPerms",
policy_document=policy_document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment