skip to Main Content

I was wondering if ‘UserData’ can be executed even when the EC2 instances in the Auto-Scalin-Group Warm-Pool are initialized with ‘Stopped’ state, I know when they are initialized and are in ‘Running’ state, the userdata executes.

Note: I am using Launch configuration to add userdata.

2

Answers


  1. The "stopped" state indicates that the EC2 virtual machine is "off". In other words it’s in the same as a physical computer with the power off. There’s no way to run anything in that state.

    Login or Signup to reply.
  2. For me userdata runs, when warm pool is initialized with stopped state.
    For me this has been working perfectly fine, until recently, it seems that its not completing its userdata script on some instances.

    Per @Mark B’s comment, thats only the state that it sits in when its done, but it still hits userdata when it initializes.

    You will find that it does work, but put in some checks to ensure it gets completed, and view the userdata logs to make sure.

    You can look into lifecycle hooks for EC2_INSTANCE_LAUNCHING hook, to get some additional work done, this is the area im being challenged by at the moment .

    Here is additional info on user-data and warm pools (on a Terraform site) https://registry.terraform.io/modules/Young-ook/ssm/aws/latest/examples/warm-pools

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search