Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Plugin for StarCluster that configures a boto credentials file for the cluster user
import os
from starcluster import clustersetup
from starcluster.logger import log
aws_access_key_id = %(aws_access_key_id)s
aws_secret_access_key = %(aws_secret_access_key)s
class BotoPlugin(clustersetup.ClusterSetup):
Plugin that configures a ~/.boto file for CLUSTER_USER
def __init__(self, boto_cfg=None):
self.boto_cfg = os.path.expanduser(boto_cfg or '') or None
def run(self, nodes, master, user, shell, volumes):
mssh = master.ssh
botocfg = '/home/%s/.boto' % user
if not mssh.path_exists(botocfg):"Installing AWS credentials for user: %s" % user)
if self.boto_cfg:"Copying %s to %s" % (self.boto_cfg, botocfg))
mssh.put(self.boto_cfg, botocfg)
else:"Installing current credentials to: %s" % botocfg)
f = mssh.remote_file(botocfg, 'w')
f.write(BOTO_CFG_TEMPLATE % master.ec2.__dict__)
mssh.chmod(0400, botocfg)
log.warn("AWS credentials already present - skipping install")

This comment has been minimized.

Copy link
Owner Author

@jtriley jtriley commented Apr 2, 2013

Use the following plugin config to build and install a ~/.boto file using the credentials defined in the StarCluster config (ie from the [aws] section):

[plugin boto]
setup_class = boto.BotoPlugin

If you'd rather maintain your own boto file instead simply set boto_cfg to the path of your .boto file:

[plugin boto]
setup_class = boto.BotoPlugin
boto_cfg = /path/to/your/.boto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment