Connector for Cloud SQL Admin

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

Explore further

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

Code sample

YAML

# This workflow demonstrates how to use the Cloud SQL connector.
# The workflow creates an SQL instance and an SQL database in the SQL instance.
# Then it deletes the database and the instance. Each of these steps waits
# until the long-running operation of creating or deleting the SQL database completes.
# Expected successful output: "SUCCESS"

- init:
    assign:
      - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - instance: "[fill in an instance name]"
      - tier: "db-n1-standard-1"
      - database_name: "[fill in an instance name]"
- create_instance:
    call: googleapis.sqladmin.v1beta4.instances.insert
    args:
      project: ${project}
      body:
        kind: "sql#database"
        settings:
          tier: ${tier}
        project: ${project}
        backendType: "SECOND_GEN"
        name: ${instance}
- create_database:
    call: googleapis.sqladmin.v1beta4.databases.insert
    args:
      project: ${project}
      instance: ${instance}
      body:
        kind: "sql#database"
        charset: "utf8"
        collation: "utf8_general_ci"
        name: ${database_name}
        instance: ${instance}
        project: ${project}
        sqlserverDatabaseDetails:
          compatibilityLevel: 5
          recoveryModel: "Simple"
- get_database:
    call: googleapis.sqladmin.v1beta4.databases.get
    args:
      project: ${project}
      instance: ${instance}
      database: ${database_name}
- delete_database:
    call: googleapis.sqladmin.v1beta4.databases.delete
    args:
      project: ${project}
      instance: ${instance}
      database: ${database_name}
- delete_instance:
    call: googleapis.sqladmin.v1beta4.instances.delete
    args:
      project: ${project}
      instance: ${instance}
- the_end:
    return: "SUCCESS"

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.