Refactor ec2 into class.