def get_backend_service(properties, backend_spec, res_name, project_id):
    ' Creates the backend service. '
    name = backend_spec.get('resourceName', res_name)
    backend_name = backend_spec.get('name', name)
    backend_properties = {'name': backend_name, 'project': project_id, 'loadBalancingScheme': 'EXTERNAL', 'protocol': get_protocol(properties)}
    backend_resource = {'name': name, 'type': 'backend_service.py', 'properties': backend_properties}
    optional_properties = ['description', 'backends', 'timeoutSec', 'sessionAffinity', 'connectionDraining', 'backends', 'healthCheck', 'healthChecks', 'portName', 'enableCDN', 'affinityCookieTtlSec']
    for prop in optional_properties:
        set_optional_property(backend_properties, backend_spec, prop)
    return ([backend_resource], [{'name': 'backendServiceName', 'value': backend_name}, {'name': 'backendServiceSelfLink', 'value': '$(ref.{}.selfLink)'.format(name)}])
Creates the backend service.
def get_backend_service(properties, backend_spec, res_name, project_id):
    '  '
    name = backend_spec.get('resourceName', res_name)
    backend_name = backend_spec.get('name', name)
    backend_properties = {'name': backend_name, 'project': project_id, 'loadBalancingScheme': 'EXTERNAL', 'protocol': get_protocol(properties)}
    backend_resource = {'name': name, 'type': 'backend_service.py', 'properties': backend_properties}
    optional_properties = ['description', 'backends', 'timeoutSec', 'sessionAffinity', 'connectionDraining', 'backends', 'healthCheck', 'healthChecks', 'portName', 'enableCDN', 'affinityCookieTtlSec']
    for prop in optional_properties:
        set_optional_property(backend_properties, backend_spec, prop)
    return ([backend_resource], [{'name': 'backendServiceName', 'value': backend_name}, {'name': 'backendServiceSelfLink', 'value': '$(ref.{}.selfLink)'.format(name)}])