Refactoring some common functionality into CloudResource.