def remove_resource(stack_definition, resource_name):
    """Remove the named resource from the stack definition.

    Remove the resource from the template and eliminate references to it.
    """
    stack_definition.t.remove_resource(resource_name)
    if stack_definition._resource_defns is not None:
        stack_definition._resource_defns.pop(resource_name, None)
    stack_definition._resource_data.pop(resource_name, None)
    stack_definition._resources.pop(resource_name, None)
