'Create a new Resource of the appropriate class for its type.'

def __new__(cls, name, definition, stack):

    assert isinstance(definition, rsrc_defn.ResourceDefinition)
    if (cls != Resource):
        ResourceClass = cls
    else:
        registry = stack.env.registry
        ResourceClass = registry.get_class_to_instantiate(definition.resource_type, resource_name=name)
        assert issubclass(ResourceClass, Resource)
    return super(Resource, cls).__new__(ResourceClass)
