1

My goal is to create a base ami and then for child ami's to use the base ami. I bootstrap the base ami via setting a powershell script in the --user-data flag and it works just fine.

However, when I use the create a child ami from the base ami, the child does not automatically run the script in the --user-data flag.

I understand that RunOnceService registry setting can be used to execute the latest userdata via the metadata call, however this seems hacky.

Is there a way to treat the child ami's as a new machine? Or get EC2 to run the script in the --user-data flag? Any other workarounds?

jonypony3
  • 410
  • 2
  • 19
  • Awesome sir! I'm sure this is what is happening, added the true element to the user-data flag and hopefully it will work as it should. – jonypony3 Nov 03 '15 at 04:13
  • @HyperAnthony answered this question, this works perfectly. Thanks again. – jonypony3 Nov 03 '15 at 21:48

1 Answers1

3

The default behavior of the EC2 Config Service is to NOT persist user-data settings following system startup. When your EC2 instance with the base AMI started up, this setting was toggled off during system startup and did not allow your subsequent child EC2 instances to handle user data.

Easy fix is to add <persist>true</persist> to your user data. An example from the documentation:

<powershell>
    insert script here
</powershell>
<persist>true</persist>

Related:

Anthony Neace
  • 25,013
  • 7
  • 114
  • 129