mercredi 7 janvier 2015

Adding an environment variable to an ec2 instance with boto

Pretty simple question, but I can't find anyone addressing it, or really any mention of the problem. Basically I'm looking to add a small amount of information to a remote ec2 box by associating an environment variable with the box when I'm spinning it up.


I've seen some mention of the concept of tags, but I'm looking for something that I can naively check and access from within the instance, and it's not clear if tags provide that functionality.


Ideally the interface to add these environment variables would also not be accessible by any external party after the instance has been instantiated.


I realize I could achieve a similar effect by setting up a secure database, but that seems overly involved for just trying to add a couple pieces of metadata to the instance.


Not looking for a handout, but any link to some documentation on this would be much appreciated. I'm currently using boto (code below), so something that fits into the boto framework would be ideal, but if I have to drop down to amazon's REST api it wouldn't be the end of the world.



def create_instances(connection, type, number, **kwargs):
kwargs.update({
'min_count': number,
'max_count': number
})
return connection.run_instances(**kwargs).instances # maybe if kwargs had an environment variable?




Aucun commentaire:

Enregistrer un commentaire