Try the following steps:
1. Launch a new instance
2. Stop the original instance(Don't terminate)
3. Detach the volume from the original instance
4. Attach it to the new instance
5. SSH into the new instance
6. Use sudo lsblk command to display the attached volumes.
7. use the following command to mount your volume
mkdir mnt
sudo mount /dev/xvdf ./mnt
cd mnt/etc/ufw
Note replace /dev/xvdf with the name o your volume as displayed when you ran lsblk command.
8. Open ufw configuration file
sudo vim ufw.conf
9. press i to edit the file
10. Change ENABLED from YES to NO.
11. Type Ctrl-C and type :wq to save the file.
12. Unmount the volume using the following command:
cd
sudo umount /mnt
13: Detach this volume and attach it back to the original instance
now you should be able to SSH into it.