EC2 via autoscaling, how long until tags propagate?

230 Views Asked by At

I'm trying to use userdata to run some code on autoscaled EC2 instances. It's important that the instance tags ("name", etc) are already set. I know that doesn't happen immediately on creation.

As a start, I'm adding sleep 20 in my userdata script. Obviously that's a code smell.

So, how long does it take tags to propagate? How can I detect it- can I use instance metadata (http://169.254.169.254/latest/) to detect that the machine is healthy?

If not, I know I could determine my instance ID and then query the API (perhaps with boto) and wait for tags. There are several yaks necessary to do this- for instance, I must ensure dependencies are installed and that I have IAM Role rights. So I'd prefer not to go that route.

0

There are 0 best solutions below