Skip to content

Instantly share code, notes, and snippets.

@garnaat
Created September 15, 2010 13:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save garnaat/580756 to your computer and use it in GitHub Desktop.
Save garnaat/580756 to your computer and use it in GitHub Desktop.
Use IAM/boto to create an Admin group
"""
IAM boto examples:
In this example, we show how to create a group
for administrators who have full access to IAM
functionality but no access to other AWS services.
"""
import boto
#
# First create a connection to the IAM service
#
iam = boto.connect_iam()
#
# Create an Admin group for users who have admin privilege
# First, create the group
#
response = iam.create_group('Admins')
#
# Next, associate a JSON policy with the group that provides
# access to all IAM actions.
#
admin_policy = """
{
"Statement":[{
"Effect":"Allow",
"Action":"*",
"Resource":"*"
}
]
}"""
response = iam.put_group_policy('Admins', 'AdminPolicy', admin_policy)
#
# Now create a new user and add her to the Admin group.
#
response = iam.create_user('Sue')
user = response.user
response = iam.add_user_to_group('Admins', 'Sue')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment