Skip to content

Instantly share code, notes, and snippets.

View garnaat's full-sized avatar

Mitch Garnaat garnaat

View GitHub Profile
@garnaat
garnaat / keybase.md
Last active August 29, 2015 13:57
keybase identity proof

Keybase proof

I hereby claim:

  • I am garnaat on github.
  • I am garnaat (https://keybase.io/garnaat) on keybase.
  • I have a public key whose fingerprint is A6C2 33BA 6313 1605 6E70 1EE4 F2E1 4005 8CC6 80A4

To claim this, I am signing this object:

@garnaat
garnaat / sdcustom
Created April 24, 2014 20:46
A click-based script to upload a custom metric to StackDriver
#!/usr/bin/env python
import requests
import time
import json
import click
@click.command()
@click.option('--name', prompt='metric name',
help='the name of the custom metric', required=True)
@garnaat
garnaat / create_rrs_key.py
Created May 24, 2010 13:23
Use boto to create an RRS Key in S3
# Create a new key in an S3 bucket and specify you want to use
# the Reduced Redundancy Storage (RRS) option of S3
import boto
# create connection to S3 service
s3 = boto.connect_s3()
# lookup my existing bucket
bucket = s3.lookup('mybucket')
@garnaat
garnaat / copy_to_rrs_key.py
Created May 24, 2010 13:58
Use boto to copy an S3 key to an RRS key
# Copy an existing key in an S3 bucket and specify you want to use
# the Reduced Redundancy Storage (RRS) option of S3 for the new copy
import boto
# create connection to S3 service
s3 = boto.connect_s3()
# lookup my existing bucket
bucket = s3.lookup('mybucket')
@garnaat
garnaat / convert_key_to_rrs.py
Created May 24, 2010 15:21
Use boto to convert an S3 key to RRS
# Convert an existing key in an S3 bucket that uses the STANDARD storage class
# to one using the REDUCED_REDUNDANCY storage class. This uses the S3 COPY
# command to copy the key back to the same bucket. The ACL is preserved.
import boto
# create connection to S3 service
s3 = boto.connect_s3()
# lookup my existing bucket
bucket = s3.lookup('mybucket')
@garnaat
garnaat / connect_to_ecc_with_boto.py
Created July 5, 2010 22:07
Connect to Eucalyptus server with boto
import boto
from boto.ec2.regioninfo import RegionInfo
reg = RegionInfo(name='ECC', endpoint='ecc.eucalyptus.com')
c = boto.connect_ec2(aws_access_key_id='<my euca access key>', aws_secret_access_key='<my euca secret key>', region=reg, port=8773, path='/services/Eucalyptus')
c.get_all_images()
@garnaat
garnaat / iam_sdb_example.py
Created September 15, 2010 18:41
IAM boto example showing read-only access to SimpleDB domain
"""
IAM boto examples:
In this example, we create a group that allows read-only access
to a single SimpleDB domain.
"""
import boto
#
# First create a connection to the IAM service
#
<ListGroupsResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<ListGroupsResult>
<IsTruncated>false</IsTruncated>
<Groups>
<member>
<GroupId>AGPAJ3O3FIPZF4F5NUDGO</GroupId>
<GroupName>Admin</GroupName>
<Path>/</Path>
<Arn>arn:aws:iam::963068290131:group/Admin</Arn>
</member>
{u'list_groups_response': {u'list_groups_result': {u'groups': [{u'arn': u'arn:aws:iam::963068290131:group/Admin',
u'group_id': u'AGPAJ3O3FIPZF4F5NUDGO',
u'group_name': u'Admin',
u'path': u'/'},
{u'arn': u'arn:aws:iam::963068290131:group/EC2-S3-Users',
u'group_id': u'AGPAJOINL5IR3W2DHU4MU',
u'group_name': u'EC2-S3-Users',
u'path': u'/'},
{u'arn': u'arn:aws:iam::963068290131:group/SDB-ReadOnly',
u'group_id': u'AGPAIIKY4E53EEXTBKKY6',
>>> r = iam.get_all_groups()
>>> r.groups
[{u'arn': u'arn:aws:iam::963068290131:group/Admin',
u'group_id': u'AGPAJ3O3FIPZF4F5NUDGO',
u'group_name': u'Admin',
u'path': u'/'},
{u'arn': u'arn:aws:iam::963068290131:group/EC2-S3-Users',
u'group_id': u'AGPAJOINL5IR3W2DHU4MU',
u'group_name': u'EC2-S3-Users',
u'path': u'/'},