---
title: "Deploy Cloud Run instance connected to Cloud SQL"
description: "Basic example of a Google Cloud Run and Google Cloud SQL deployment"
url: "https://www.pulumi.com/dev/examples/gcp-py-cloudrun-cloudsql/"
image: "https://www.pulumi.com/assets/og/dev/examples/gcp-py-cloudrun-cloudsql.png"
---

# Deploy Cloud Run instance connected to Cloud SQL

Basic example of a Google Cloud Run and Google Cloud SQL deployment

- Source on GitHub: https://github.com/pulumi/examples/tree/master/gcp-py-cloudrun-cloudsql
- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Fexamples%2Ftree%2Fmaster%2Fgcp-py-cloudrun-cloudsql

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/gcp-py-cloudrun-cloudsql) repo. Pull down just this directory to follow along:

```bash
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set gcp-py-cloudrun-cloudsql
cd pulumi-examples/gcp-py-cloudrun-cloudsql
```

Example of starting a Cloud Run deployment with Cloud SQL instance

## Running the App

1.  Create a new stack:

    ```
    $ pulumi stack init dev
    ```

1.  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!
    ```

1.  Preview and deploy changes:
    ```
    $ pulumi up
    ```

1.  Curl the Cloud Run:

    ```
    $ curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" $(pulumi stack output cloud_run_url)
    ```

1.  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)
    ```

1. Cleanup

    ```
    $ pulumi destroy
    $ pulumi stack rm
    ```
