Answers: <p>If I am understanding you correctly, you have one AMI used in several autoscaling groups and want to run a specific “bootstrap” sequence on it depending on the autoscaling group it belongs to.</p>
  
  <p>This is not difficult to accomplish because the <a href="https://docs.aws.amazon.com/cli/latest/reference/autoscaling/create-launch-configuration.html" rel="nofollow noreferrer">launch configuration</a> you created to map the autoscaling group to the AMI can <a href="https://docs.aws.amazon.com/cli/latest/reference/autoscaling/create-launch-configuration.html" rel="nofollow noreferrer">accomodate user data</a> which can be a shell script.</p>
  
  <p>In the shell script provided as user data, it is customary to <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html" rel="nofollow noreferrer">retrieve meta data</a> so that the instances can correctly identify itself in logs and arrange other similar last minute details.  This meta-data could also contain a reference to the auto-scaling group, which you could take advantage of to reduce the little overhead due to autoscaling-group management.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-07-20T05:13:04.863Z
Answers: 2018-07-20T05:13:04.863Z
Answers: Michaël Le Barbier
Body: <p>I have a custom AMI that contains the dependencies for several applications. </p>
  
  <p>The only difference between the applications is several configuration options that can be configured by a bash script. (i.e. enabling/disabling certain supervisor groups.)</p>
  
  <p>Each different app is triggered by an different autoscale instance.</p>
  
  <p>How do I get the instance to run a different script on boot by an autoscaler?</p>
  
Tags: <amazon-web-services><amazon-ec2><autoscaling>
Title: I have an custom AMI and want to run certain config commands at initial boot, depending on the autoscale instance that starts it. How do I do this?
UserDisplayName: Dr. Chocolate
ThreadText: # I have an custom AMI and want to run certain config commands at initial boot, depending on the autoscale instance that starts it. How do I do this?
  
  (Asked by: username_0 on 2018-07-19)
  
  I have a custom AMI that contains the dependencies for several applications.
  
  The only difference between the applications is several configuration options that can be configured by a bash script. (i.e. enabling/disabling certain supervisor groups.)
  
  Each different app is triggered by an different autoscale instance.
  
  How do I get the instance to run a different script on boot by an autoscaler?
  
  **Tags:** amazon-web-services, amazon-ec2, autoscaling
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-07-20. Score: 4
  
  If I am understanding you correctly, you have one AMI used in several autoscaling groups and want to run a specific “bootstrap” sequence on it depending on the autoscaling group it belongs to.
  
  This is not difficult to accomplish because the [launch configuration](https://docs.aws.amazon.com/cli/latest/reference/autoscaling/create-launch-configuration.html) you created to map the autoscaling group to the AMI can [accomodate user data](https://docs.aws.amazon.com/cli/latest/reference/autoscaling/create-launch-configuration.html) which can be a shell script.
  
  In the shell script provided as user data, it is customary to [retrieve meta data](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) so that the instances can correctly identify itself in logs and arrange other similar last minute details. This meta-data could also contain a reference to the auto-scaling group, which you could take advantage of to reduce the little overhead due to autoscaling-group management.
  
  
  ---
  
  