Skip to content

Commit

Permalink
create s3 bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Culich committed Oct 18, 2014
1 parent ce9d7a0 commit c3635f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions aws-iam/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ def destroy(target):
# if there was an exception, then the account didn't have an alias
pass

response = s3 = boto.connect_s3()
bucket = s3.get_bucket(target)
keys = bucket.list()
bucket.delete_keys([k.name for k in keys])

### The delete_bucket is intentionally commented out because the
### delete behavior is surprising relative to other delete
### operations in the API. Creating a bucket with the same name as
### one that has been deleted may not even be possible in some
### cases. Typically it takes a few hours for the bucket names to
### be cleared so in practice it is often possible to create a new
### bucket with the same name. Read more at:
### http://psykidellic.github.io/posts/amazon-s3---careful-with-bucket-names/
### https://forums.aws.amazon.com/thread.jspa?threadID=37532
### Interestingly, create_bucket does not behave as expected,
### either; if a bucket already exists, the call to create_bucket
### does not raise an exception about a duplicate
### already existing.
# s3.delete_bucket(target)

for category in ['instructors','students']:
group = target + '-' + category
response = iam.get_group(group)
Expand Down
5 changes: 5 additions & 0 deletions aws-iam/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def create_iam_users(target, category):
for r in resources:
response = apply_policy(group, category + '-' + r)

s3 = boto.connect_s3()
bucket = s3.get_bucket(target)

data = []
for e in email_addresses:
response = iam.create_user(e)
Expand Down Expand Up @@ -89,6 +92,8 @@ def save_credentials(target, category, creds):

def provision(target):
create_signin_url(target)
s3 = boto.connect_s3()
bucket = s3.create_bucket(target)
for category in ['instructors','students']:
creds = create_iam_users(target, category)
save_credentials(target, category, creds)
Expand Down

0 comments on commit c3635f5

Please sign in to comment.