Skip to content

Instantly share code, notes, and snippets.

@kszarek
Created June 20, 2014 10:37
Show Gist options
  • Save kszarek/f89cac7ddc95562f4e8e to your computer and use it in GitHub Desktop.
Save kszarek/f89cac7ddc95562f4e8e to your computer and use it in GitHub Desktop.
SmartIAM class
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from boto.exception import BotoServerError
from boto.iam import IAMConnection
__author__ = 'Krzysztof Szarek'
class SmartIAM(IAMConnection):
def create_user(self, user):
try:
return super(SmartIAM, self).create_user(user)
except BotoServerError as exception:
if exception.code == 'EntityAlreadyExists':
return super(SmartIAM, self).get_user(user)
else:
raise
def create_group(self, group):
try:
return super(SmartIAM, self).create_group(group)
except BotoServerError as exception:
if exception.code == 'EntityAlreadyExists':
return
else:
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment