Updated terminateEc2Machines to be used as module