Replace cloud-init.cfg

Hey guys!

I’m having the following problem:

I create the custom Debian 11 ami in the packer then run the ami in the terraform.
Logging into the instance there are two entries “admin ALL=(ALL) NOPASSWD:ALL” in the file “/etc/sudoers.d/90-cloud-init-users”
How can I just leave an entry of “admin ALL=(ALL) NOPASSWD:ALL” in 90-cloud-init-users and removing the option “NOPASSWD”?
Or how do I replace the cloud-init.cfg file to the way I want and on the next ami startup apply this new change?


Terraform isn’t the right place to make that change in the OS/AMI.

If it’s your image, then you should be changing that before you generate the AMI using whatever you used to build the image (packer?)

If it’s not your image, then you can use user-data script in the launch of the AMI to manipulate the OS after it starts up.