> For the complete documentation index, see [llms.txt](https://docs.teleskope.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.teleskope.ai/connectors/gcp/cloud-sql.md).

# Cloud SQL

## Grant Teleskope Access to Cloud SQL

Attach the following roles to the Teleskope service account you created:

* roles/cloudsql.client
* roles/cloudsql.instanceUser
* roles/cloudsql.viewer
* roles/cloudsql.admin (required to generate ssl certificates)

### Terraform

| Variable    | Description                    | Example         |
| ----------- | ------------------------------ | --------------- |
| project\_id | (Required) Your GCP Project ID | "my-project-id" |

```
resource "google_project_iam_member" "teleskope" {
  for_each = toset([
    "roles/cloudsql.client",
    "roles/cloudsql.instanceUser",
    "roles/cloudsql.viewer",
    "roles/cloudsql.admin"
  ])
  project = "project_id"
  role    = each.key
  member = "serviceAccount:${google_service_account.teleskope.email}"
}
```

## Teleskope Database User

For each CloudSQL instance you would like to scan using Teleskope, you will need to create or provide credentials for a database user, and grant that user read permissions.

### Grant Read Access to Teleskope user

#### MySQL or MariaDB

```sql
GRANT SHOW DATABASES, SELECT ON *.* TO teleskope_ro
```

#### Postgres versions 14+

```sql
GRANT pg_read_all_data TO teleskope_ro
```

#### Postgres versions < 14

```sql
SELECT format('GRANT CONNECT ON DATABASE %I TO teleskope_ro;', datname) FROM pg_database \gexec
SELECT format('GRANT USAGE ON SCHEMA %I TO teleskope_ro;', nspname) FROM pg_namespace \gexec
SELECT format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO teleskope_ro;', nspname) FROM pg_namespace \gexec
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.teleskope.ai/connectors/gcp/cloud-sql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
