Workflows connector that defines the built-in function used to access Cloud Spanner within a workflow.

## Explore further


For detailed documentation that includes this code sample, see the following:

- [Cloud Spanner API Connector Overview](https://docs.cloud.google.com/workflows/docs/reference/googleapis/spanner/Overview)

## Code sample

### YAML

    # This workflow demonstrates how to use the Spanner connector:
    # Write entries to an existing Spanner database
    # Your database should have the same schema described in the
    # `create_transaction` step
    # Expected output: "SUCCESS"
    - create_table_entry:
        assign:
          - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
          - spanner_inst: "SPANNER_INSTANCE"  # replace SPANNER_INSTANCE placeholder
          - spanner_db: "SPANNER_DATABASE"  # replace SPANNER_DATABASE placeholder
          - entry: ["123"]
    - create_transaction:
        assign:
          - req:
              mutations:
                - insert:
                    columns:
                      - ID
                    table: Contacts
                    values:
                      - ${entry}
              singleUseTransaction:
                readWrite: {}
    - create_spanner_session:
        call: googleapis.spanner.v1.projects.instances.databases.sessions.create
        args:
          database: ${"projects/" + project_id + "/instances/" + spanner_inst + "/databases/" + spanner_db}
        result: session
    - write_entry:
        call: googleapis.spanner.v1.projects.instances.databases.sessions.commit
        args:
          session: ${session.name}
          body: ${req}
    - delete_spanner_session:
        call: googleapis.spanner.v1.projects.instances.databases.sessions.delete
        args:
          name: ${session.name}
    - the_end:
        return: SUCCESS

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=workflows).