You cannot add a tag on an instance untill it has been completely launced. So, is you want to create a script to add tags to instances, you will also have to make sure that the instance is launched as well as up and running before you can add a tag. So, your script should look something like:
reservation = conn.run_instances( ... )
instance = reservation.instances[0]
# Check up on its status, if it's running then add a tag.
status = instance.update()
while status == 'pending':
time.sleep(10)
status = instance.update()
if status == 'running':
instance.add_tag("Name","{{INSERT NAME}}")
else:
print('Instance status: ' + status)
return None
# Check if the instance is completely up and running. The only way to tell if it's fully up is to try to SSH in.
if status == "running":
retry = True
while retry:
try:
retry = False
except:
time.sleep(10)
# If we've reached this point, the instance is up and running, so we can SSH into it and do as we will with it.