factor out ec2 into separate file