def METHOD_NAME(res_name, project_id, properties):
    """ Creates a Cloud SQL instance. """
    name = res_name
    instance_properties = {
        'region': properties['region'],
        'project': project_id,
        'name': name
    }
    optional_properties = [
        'databaseVersion',
        'failoverReplica',
        'instanceType',
        'masterInstanceName',
        'maxDiskSize',
        'onPremisesConfiguration',
        'replicaConfiguration',
        'serverCaCert',
        'serviceAccountEmailAddress',
        'settings',
        'rootPassword',
    ]
    for prop in optional_properties:
        set_optional_property(instance_properties, properties, prop)
    instance = {
        'name': name,
        # https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances
        'type': 'gcp-types/sqladmin-v1beta4:instances',
        'properties': instance_properties
    }
    if 'dependsOn' in properties:
        instance['metadata'] = {'dependsOn': properties['dependsOn']}
    output_fields = [
        'name',
        'selfLink',
        'backendType',
    ]
    if 'onPremisesConfiguration' not in properties:
        output_fields.extend(['gceZone','connectionName','serviceAccountEmailAddress'])
    outputs = [{
        'name': i,
        'value': '$(ref.{}.{})'.format(name, i)
    } for i in output_fields]
    # Regrettably, 'ipAddress' is a special snowflake. 'ipAddresses' is a list
    # of objects, and DM doesn't seem to let you extract child properties from
    # outputs of imported templates. If we want to use the actual IP address of
    # the instantiated database in a template that uses this template, we need
    # to navigate to the relevant child value here.
    if 'onPremisesConfiguration' not in properties:
        outputs += [{
            'name': 'ipAddress',
            'value': '$(ref.{}.ipAddresses[0].ipAddress)'.format(name),
        }]
    return DMBundle(instance, outputs)