FYI: AWS t2.micro instance is too small. Use t2.small at least

Also, how big was the swapfile you created?