1. Packages
  2. Google Cloud (GCP) Classic
  3. How-to Guides
  4. Deploy Cloud Run instance connected to Cloud SQL
Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi

Deploy Cloud Run instance connected to Cloud SQL

gcp logo
Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi

    View Code Deploy this example with Pulumi

    Example of starting a Cloud Run deployment with Cloud SQL instance

    Running the App

    1. Create a new stack:

      $ pulumi stack init dev
      
    2. Configure the project:

      $ pulumi config set gcp:project YOURGOOGLECLOUDPROJECT
      $ pulumi config set gcp:region europe-west1
      $ pulumi config set db-name project-db
      $ pulumi config set --secret db-password SuuperSecret12345!
      
    3. Preview and deploy changes:

      $ pulumi up
      
    4. Curl the Cloud Run:

      $ curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" $(pulumi stack output cloud_run_url)
      
    5. Access the database:

      $ gcloud sql connect $(pulumi stack output cloud_sql_instance_name) -u $(pulumi config get db-name) --project $(pulumi config get gcp:project)
      
    6. Cleanup

      $ pulumi destroy
      $ pulumi stack rm
      
    gcp logo
    Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi