Refactoring ec2 scripts