How to connect via SSH to EC2 instance that got unreachable?

For Amazon AWS EC2 you need to use a .yaml like this. SSH will work then.

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      match:
        macaddress: 06:a0:68:ea:54:4e
      set-name: eth0
  bridges:
    br0:
      dhcp4: true
      macaddress: 06:a0:68:ea:54:4e
      interfaces:
        - eth0

Note: You may need to create /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

network: {config: disabled}

sudo netplan --debug generate
sudo netplan apply
reboot # mandatory

Check this link for further information.