# Buggy code
def deploy_resource(resource):
    client = get_client(resource)
    resource_type = get_resource_type(resource)
    func_details = RESOURCE_TO_FUNCTION.get(resource_type)
    if not func_details:
        LOGGER.warning("Resource type not yet implemented: %s" % resource["Type"])
        return
    func_details = func_details[ACTION_CREATE]
    function = getattr(client, func_details["function"])
    params = dict(func_details["parameters"])
    if "Properties" not in resource:
        resource["Properties"] = {}
    for param_key, prop_key in iteritems(params):
        params[param_key] = resource["Properties"].get(prop_key)
    # invoke function
    return function(**params)


# Traceback (ResponseParserError)
ERROR:localstack.mock.generic_proxy:Error forwarding request: Traceback (most recent call last):
File "/opt/code/localstack/localstack/mock/generic_proxy.py", line 88, in forward
data=data, headers=self.headers, return_forward_info=True)
File "/opt/code/localstack/localstack/mock/proxy/sns_listener.py", line 37, in update_sns
queue_url = aws_stack.get_sqs_queue_url(queue_name)
File "/opt/code/localstack/localstack/utils/aws/aws_stack.py", line 285, in get_sqs_queue_url
response = client.get_queue_url(QueueName=queue_name)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/client.py", line 253, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/client.py", line 531, in _make_api_call
operation_model, request_dict)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/endpoint.py", line 141, in make_request
return self._send_request(request_dict, operation_model)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/endpoint.py", line 168, in _send_request
request, operation_model, attempts)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/endpoint.py", line 233, in _get_response
response_dict, operation_model.output_shape)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/parsers.py", line 210, in parse
parsed = self._do_error_parse(response, shape)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/parsers.py", line 438, in _do_error_parse
root = self._parse_xml_string_to_dom(xml_contents)
File "/opt/code/localstack/.venv/lib/python2.7/site-packages/botocore/parsers.py", line 390, in _parse_xml_string_to_dom
"invalid XML received:\n%s" % (e, xml_string))
ResponseParserError: Unable to parse response (syntax error: line 1, column 54), invalid XML received:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

# Fixed code
def deploy_resource(resource_id, resources, stack_name):
    resource = resources[resource_id]
    client = get_client(resource)
    if not client:
        return False
    resource_type = get_resource_type(resource)
    func_details = RESOURCE_TO_FUNCTION.get(resource_type)
    if not func_details:
        LOGGER.warning("Resource type not yet implemented: %s" % resource["Type"])
        return
    func_details = func_details[ACTION_CREATE]
    function = getattr(client, func_details["function"])
    params = dict(func_details["parameters"])
    defaults = func_details.get("defaults", {})
    if "Properties" not in resource:
        resource["Properties"] = {}
    # print('deploying', resource_id, resource_type)
    for param_key, prop_keys in iteritems(dict(params)):
        params.pop(param_key, None)
        if not isinstance(prop_keys, list):
            prop_keys = [prop_keys]
        for prop_key in prop_keys:
            if prop_key == PLACEHOLDER_RESOURCE_NAME:
                # obtain physical resource name from stack resources
                params[param_key] = resolve_ref(
                    stack_name, resource_id, resources, attribute="PhysicalResourceId"
                )
            else:
                prop_value = resource["Properties"].get(prop_key)
                if prop_value is not None:
                    params[param_key] = prop_value
            tmp_value = params.get(param_key)
            if tmp_value is not None:
                params[param_key] = resolve_refs_recursively(
                    stack_name, tmp_value, resources
                )
                break
        # hack: convert to boolean
        if params.get(param_key) in ["True", "False"]:
            params[param_key] = params.get(param_key) == "True"
    # assign default value if empty
    params = common.merge_recursive(defaults, params)
    # invoke function
    try:
        result = function(**params)
    except Exception as e:
        LOGGER.warning(
            "Error calling %s with params: %s for resource: %s"
            % (function, params, resource)
        )
        raise e
    # update status
    set_status_deployed(resource_id, resource, stack_name)
    return result