Connector für Cloud SQL-Administrator

Workflow-Connector, der die integrierte Funktion definiert, mit der in einem Workflow auf den Cloud SQL-Administrator zugegriffen wird.

Weitere Informationen

Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:

Codebeispiel

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"

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.