Skip to content

Instantly share code, notes, and snippets.

View aayvazyan's full-sized avatar

Ashot aayvazyan

View GitHub Profile
@geekbass
geekbass / cloud-init.md
Last active April 8, 2024 15:18
Cloud Init Rescue

Rescue ec2 via Cloud-Init

If something takes over your instance and you lose ssh, here is a way that you can recover it via Cloud-init (As long as you are using Cloud-Init). Use boot_cmd to recover or undo anychanges that caused this.

Find the instance ID and stop it.

aws ec2 stop-instances --instance-ids i-instanceID --force

Create your file. Use boot_cmd as this will execute on boot every time. See https://cloudinit.readthedocs.io/en/latest/topics/examples.html?highlight=systemd#run-commands-on-first-boot for the details.

Base64 encode it.