I would like to ask if there is a way to re-execute user data on a launched instance. I want to restart a service and to edit ~./ssh/autorized_keys.
I found information at https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/ but the cloud log from the console does not show anything to have changed.
AWS only run the user data at the first launch. You need do the following two things:
write-mime-multipart
incloud-utils
to create the mime-multipart file. Please refer the Cloud-init if you need more details.scripts-user
runalways
. In/etc/cloud/cloud.cfg
, refer Always run cloud-init scripts to see the optionsSo, you need copy all the scripts from the link your provided and replace the shell script part with yours. https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/