I need instance group manager created multiple instances and then let each instance run a start-up script. But I hope this instance creation has some order or intervals. Cause if multiple nodes run same start up script at same time. This will made some conflict results. And only one node can join to my distributed cluster. I thought add some random sleep into my start up script to let different instance can trigger start up script at different timestamp. But this is too hacky and unpredictable for our infra.

I also tried to change instance_group_manager target size in my local start up script like set that target_size from 1 to n. But this will take too long time to destroy and create one instance and each time it will refresh a new ip for each instance. This will let my master node really confuse about data nodes IP.

So does any one know how to set up dependency in instance_group_manager to create multiple instances especially by using terraform?

  • Are you able to describe the underlying software that requires this? Is it a commercial application or a private piece of software? – Andy Shinn Jan 18 '20 at 21:51

This is perhaps a more heavyweight solution. But might make sense in a larger cluster.

You could use a locking mechanism controlled by an external store. Consul comes to mind as a piece of software that has this built in to their client: https://www.consul.io/docs/commands/lock.html.

This would also require you to bootstrap the Consul Agent in client mode on the instance as part of your script.

Then, assuming your boot script did something like:

mybinary register

You might instead do:

consul lock mykeyprefix mybinary register

This would force your script to acquire the lock before continuing. Once on process completes another would acquire the lock and continue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.