2

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.

jjhughes57
  • 21
  • 1
  • 3

2 Answers2

2

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/*
jkim
  • 21
  • 2
0

You need to be sure that cloud-init is not running during this time. Otherwise you need to delete it again.

This is especially true if you try to delete /var/lib/cloud/ inside user-data. In this case you should use something like:

echo "rm -rf /var/lib/cloud/*" | at now + 1 min

at the end of user-data script.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129