2

We configure AWS EC2 instances (ubuntu-20) with cloud-init using user-data scripts. We're noticing the user-data scripts don't execute if they are run on instance which is launched from a custom AMI created from another launched instance.

We create an intermediate AMI which has common tools & frameworks and reuse it for specific needs -

  1. First, we launch an instance from a published AMI. The user-data scripts get executed perfectly fine as first boot on this instance.
  2. We create an intermediate AMI from the instance launched in first step.
  3. Then launch another instance from the intermediate AMI.

We provide user-data script in the instance launched from intermediate AMI as well but somehow the script doesn't execute.

We've already tried to clean the cloud-init cache before creating the intermediate AMI so that the cloud-init can run as first boot on the new instance [Reference] -

sudo cloud-init clean --logs --seed

And I've also tried to clean the /etc/machine-id as shared here but nothing works.

Is there anything I'm missing to clean for cloud-init so that it can run as first boot for new instances?

0 Answers0