import boto.ec2
import botocross as bc
import logging

# configure command line argument parsing
parser = argparse.ArgumentParser(
    description="Describe EBS snapshots in all/some available EC2 regions",
    parents=[bc.build_region_parser(), bc.build_filter_parser("EBS snapshots"), bc.build_common_parser()],
)
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger("botocross")
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
regions = bc.filter_regions(boto.ec2.regions(), args.region)
filter = bc.build_filter(args.filter, args.exclude)
log.info(args.resource_ids)

# execute business logic
log.info("Describing EBS snapshots:")

for region in regions:
    try:
        ec2 = boto.connect_ec2(region=region, **credentials)
        snapshots = ec2.get_all_snapshots(snapshot_ids=args.resource_ids, owner="self", filters=filter["filters"])
        if filter["excludes"]:
            exclusions = ec2.get_all_snapshots(owner="self", filters=filter["excludes"])
            snapshots = bc.filter_list_by_attribute(snapshots, exclusions, "id")
        print region.name + ": " + str(len(snapshots)) + " snapshots"
        for snapshot in snapshots:
Example #2
0
group.add_argument("-n", "--name", help="The security group name")
group.add_argument("-i",
                   "--id",
                   help="The security group id (required in VPC)")
parser.add_argument(
    "-f",
    "--force",
    action="store_true",
    help="Delete security groups even when assigned to instances.")
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger('botocross')
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
regions = bc.filter_regions(boto.ec2.regions(), args.region)

# execute business logic
groupname = args.name if args.name else ""
group_id = args.id if args.id else ""
log.info("Deleting EC2 security groups '" + groupname + group_id + "':")

groupnames = [args.name] if args.name else None
group_ids = [args.id] if args.id else None

for region in regions:
    pprint(region.name, indent=2)
    try:
        ec2 = boto.connect_ec2(region=region, **credentials)
        groups = ec2.get_all_security_groups(groupnames=groupnames,
                                             group_ids=group_ids)
Example #3
0
    parents=[bc.build_region_parser(),
             bc.build_common_parser()])
parser.add_argument("topic", help="A topic name")
parser.add_argument(
    "-d",
    "--display_name",
    help=
    "Override the topics display name (will get region suffix) [default: topic name]"
)
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger('botocross')
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
regions = bc.filter_regions(boto.sns.regions(), args.region)

# execute business logic
log.info("Creating SNS topics named '" + args.topic + "':")

for region in regions:
    pprint(region.name, indent=2)
    try:
        sns = boto.connect_sns(region=region, **credentials)
        topic = sns.create_topic(args.topic)
        arn = topic['CreateTopicResponse']['CreateTopicResult']['TopicArn']
        print arn
        display_name = args.display_name if args.display_name else args.topic
        display_name += '-' + region.name
        sns.set_topic_attributes(arn, 'DisplayName', display_name)
    except boto.exception.BotoServerError, e:
Example #4
0
import boto
import boto.cloudformation
import botocross as bc
import logging

# configure command line argument parsing
parser = argparse.ArgumentParser(description='Delete a CloudFormation stack in all/some available CloudFormation regions',
                                 parents=[bc.build_region_parser(), bc.build_common_parser()])
parser.add_argument("stack_name_or_id", metavar='stack_name', help="A stack name or id (ARN)")
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger('botocross')
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
regions = bc.filter_regions(boto.cloudformation.regions(), args.region)

# execute business logic
log.info("Deleting CloudFormation stacks named '" + args.stack_name_or_id + "':")

for region in regions:
    pprint(region.name, indent=2)
    try:
        cfn = boto.connect_cloudformation(region=region, **credentials)
        stacks = cfn.describe_stacks(args.stack_name_or_id)
        for stack in stacks:
            print 'Deleting stack ' + args.stack_name_or_id
            cfn.delete_stack(args.stack_name_or_id)
    except boto.exception.BotoServerError, e:
        log.error(e.error_message)
import boto
import boto.sns
import botocross as bc
import logging

# configure command line argument parsing
parser = argparse.ArgumentParser(description='Describe SNS subscriptions in all/some available EC2 regions',
                                 parents=[bc.build_region_parser(), bc.build_common_parser()])
parser.add_argument("-t", "--topic", help="A topic name. [default: None]")
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger('botocross')
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
regions = bc.filter_regions(boto.sns.regions(), args.region)

# execute business logic
log.info("Describing SNS topics:")

if args.topic:
    iam = boto.connect_iam(**credentials)
for region in regions:
    try:
        sns = boto.connect_sns(region=region, **credentials)

        subscriptions = []
        next_token = None
        while True:
            if not args.topic:
                result = sns.get_all_subscriptions(next_token)