'Implements the DescribeStackResource API action.
Return the details of the given resource belonging to the given stack.'

def describe_stack_resource(self, req):

    self._enforce(req, 'DescribeStackResource')
    def format_resource_detail(r):
        keymap = {rpc_api.RES_DESCRIPTION: 'Description', rpc_api.RES_UPDATED_TIME: 'LastUpdatedTimestamp', rpc_api.RES_NAME: 'LogicalResourceId', rpc_api.RES_METADATA: 'Metadata', rpc_api.RES_PHYSICAL_ID: 'PhysicalResourceId', rpc_api.RES_STATUS_DATA: 'ResourceStatusReason', rpc_api.RES_TYPE: 'ResourceType', rpc_api.RES_STACK_ID: 'StackId', rpc_api.RES_STACK_NAME: 'StackName'}
        result = api_utils.reformat_dict_keys(keymap, r)
        result['ResourceStatus'] = self._resource_status(r)
        return self._id_format(result)
    con = req.context
    try:
        identity = self._get_identity(con, req.params['StackName'])
        resource_details = self.rpc_client.describe_stack_resource(con, stack_identity=identity, resource_name=req.params.get('LogicalResourceId'))
    except Exception as ex:
        return exception.map_remote_error(ex)
    result = format_resource_detail(resource_details)
    return api_utils.format_response('DescribeStackResource', {'StackResourceDetail': result})
