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
In [1]: policy = """{ | |
...: "Statement":[{ | |
...: "Effect":"Allow", | |
...: "Action":["s3:*"], | |
...: "Resource":["arn:aws:s3:::mybucket"]}]}""" | |
In [2]: import boto | |
In [4]: c = boto.connect_iam() | |
In [5]: instance_profile = c.create_instance_profile('myinstanceprofile') | |
In [6]: role = c.create_role('myrole') | |
In [7]: c.add_role_to_instance_profile('myinstanceprofile', 'myrole') |
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
#!/usr/bin/env python | |
""" | |
Launch an AWS Web Console. | |
Usage: | |
awsconsole launch --role=<role_arn> [--profile=<profile_name>] | |
Commands: | |
launch - Launch the AWS Console in your default web browser with | |
the specified credentials. The console will be authenticated |
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 multiprocessing | |
import boto | |
import os | |
import sys | |
import datetime | |
import logging | |
import Queue |
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 boto | |
>>> ec2 = boto.connect_ec2() | |
>>> stats = ec2.get_all_instance_status() | |
>>> stats | |
[InstanceStatus:i-67c81e0c] | |
>>> stat = stats[0] | |
>>> stat | |
InstanceStatus:i-67c81e0c | |
>>> stat.id | |
u'i-67c81e0c' |
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 skew | |
# Add whitelisted CIDR blocks here, e.g. 192.168.1.1/32. | |
# Any addresses not in this list will be flagged. | |
whitelist = [] | |
for secgrp in skew.scan('arn:aws:ec2:*:*:security-group/*'): | |
for ipperms in secgrp.data['IpPermissions']: | |
for ip in ipperms['IpRanges']: | |
if ip['CidrIp'] not in whitelist: |
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 skew | |
for instance in skew.scan('arn:aws:ec2:*:*:instance/*'): | |
if not instance.tags: | |
print('%s is untagged' % instance.arn) |
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 skew | |
total_size = 0 | |
total_volumes = 0 | |
for volume in skew.scan('arn:aws:ec2:*:*:volume/*'): | |
if not volume.data['Attachments']: | |
total_volumes += 1 | |
total_size += volume.data['Size'] | |
print('%s: %dGB' % (volume.arn, volume.data['Size'])) |
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
""" | |
IAM boto examples: | |
In this example we create a group that provides access | |
to all EC2 and S3 resources and actions and then add a | |
user to that group. | |
""" | |
import boto | |
# | |
# First create a connection to the IAM service |
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 boto | |
s3 = boto.connect_s3() | |
bucket = s3.lookup('mybucket') | |
key = bucket.lookup('mykey') | |
# Copy the key onto itself, preserving the ACL but changing the content-type | |
key.copy(key.bucket, key.name, preserve_acl=True, metadata={'Content-Type': 'text/plain'}) | |
key = bucket.lookup('mykey') |
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
[Boto] | |
# Add this line to your boto config file in the Boto section | |
https_validate_certificates = False |
NewerOlder