Added func for env and role upload and refactored