espenak / awsfabrictasks

Other
84 stars 26 forks source link

Getting the current Instance #21

Open rmasters opened 10 years ago

rmasters commented 10 years ago

Hi, I can't find a way to access the current instance. I need to create a volume in the same availability zone as the instance (using boto), but need to know the availability zone of the instance it will be attached to (it may be variable). I guess I'm trying to get the Ec2InstanceWrapper or underlying EC2Connection.

For some reason, env.host_string is empty (in fact, the entire env seems to be at it's default values), so I can't look up the instance by it's DNS name either.

@task
@ec2instance(tags={'Group': 'master'})
def build():
    pprint(env)
    #vol = conn.create_volume(VOLUME_SIZE, REGION)

env looks like this:

'ec2ids': None,
'ec2names': None,
'ec2tags': '',
...
'host': '',
'host_string': '',
'hosts': [],