We bake AMI's and lately I have wanted to run some user-data scripts to notify cloud formation when the instance is done booting and put it into service. I am using cfn-signal to do this. On the original ubuntu image the script will execute but after baking our custom AMI the user-data script is not run.

If I place "#cloud-boothook" at the top of the script it does execute but because it executes so early its not useful for notifying when the machine is up. I am hoping someone knows where the flag or file is that indicates to cloudinit that it is a first boot of a machine.

I also tried modifying the config as was suggested Here

I know there must be a flag or file I can remove before the AMI creation process but am unable to find any information on what the flag or file might be.


Solution 1:

As I tested, there were some bootstrap data in /var/lib/cloud directory. After I cleared that directory, User Data script worked normally.

rm -rf /var/lib/cloud/*