# GCP

## Create Teleskope Service Account

Create a Teleskope service account in your GCP project. For **BigQuery**, we have downloadable Terraform scripts [here](https://docs.teleskope.ai/connectors/gcp/bigquery/terraform-scripts) that create everything below.

### Terraform

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

```
resource "google_service_account" "teleskope" {
  account_id   = "teleskope"
  display_name = "Teleskope Read Only User"
  project      = "{project_id}"
}
```

## Grant Resource Manager Read Access to Teleskope Service Account

Grant the following resource manager permissions to the Teleskope service account you created above:

* resourcemanager.projects.list
* resourcemanager.projects.get
* resourcemanager.folders.get
* resourcemanager.folders.list
* resourcemanager.organizations.get
* compute.regions.list

### Terraform

| Variable | Description                | Example        |
| -------- | -------------------------- | -------------- |
| org\_id  | (Required) Your GCP Org ID | "130342390179" |

```
resource "google_organization_iam_custom_role" "teleskope" {
  role_id     = "teleskope_resource_manager_ro"
  org_id      = "{org_id}"
  title       = "Teleskope"
  description = "teleskope resource manager read only role"
  permissions = ["resourcemanager.projects.list", "resourcemanager.projects.get", "resourcemanager.folders.get", "resourcemanager.folders.list", "resourcemanager.organizations.get", "compute.regions.list", "storage.buckets.list", "storage.buckets.getIamPolicy"]
}

resource "google_organization_iam_member" "teleskope-resource-manager-ro-role" {
  org_id  = "{org_id}"
  role    = google_organization_iam_custom_role.teleskope.name
  member = "serviceAccount:${google_service_account.teleskope.email}"
}
```

## Configure Workload Identity Federation (Saas Only)

Teleskope Saas is run in an isolated AWS account. In order to grant Teleskope the ability to connect to GCP, you will need to configure workload identity federation.

### Create Workload Identity Federation Pool

Go to <https://console.cloud.google.com/> > Workload Identity Federation > Create Pool

* Name: teleskope-pool
* Pool id : teleskope-pool
* Provider:
  * Select Provider: AWS
  * Provider Name: teleskope-provider
  * AWS Account: {origin\_aws\_account\_id}

### Grant Access to Teleskope Service Account

Once pool is created, click Grant Access, and select the Teleskope service account you created above.

### Terraform

| Variable                 | Description                                            | Example         |
| ------------------------ | ------------------------------------------------------ | --------------- |
| origin\_aws\_account\_id | (Required) AWS Account ID where Teleskope is deployed. | "012345678912"  |
| project\_id              | (Required) Your GCP Project ID                         | "my-project-id" |

```
resource "google_iam_workload_identity_pool" "teleskope-pool" {
	provider                  = google-beta
	project                   = "{project_id}"
	display_name              = "Teleskope AWS Pool"
	workload_identity_pool_id = "teleskope-pool"
  }
  
resource "google_iam_workload_identity_pool_provider" "teleskope-prov" {
	provider                           = google-beta
	project                            = "{project_id}"
	workload_identity_pool_id          = google_iam_workload_identity_pool.teleskope-pool.workload_identity_pool_id
	workload_identity_pool_provider_id = "teleskope-provider"
	display_name                       = "Teleskope AWS Provider"
	description                        = "AWS identity pool provider for teleskope"
	disabled                           = false
	aws {
	  account_id = "{origin_aws_account_id}"
	}
	depends_on = [google_iam_workload_identity_pool.teleskope-pool]
  }

resource "google_service_account_iam_binding" "wi_bindings" {
  for_each           = toset([
    "roles/iam.workloadIdentityUser",
    "roles/iam.serviceAccountTokenCreator",
  ])
  provider           = google-beta
  service_account_id = google_service_account.teleskope.name
  role               = each.key
  members = [
    "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.teleskope-pool.name}/*",
  ]
}
```


---

# Agent Instructions: 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:

```
GET https://docs.teleskope.ai/connectors/gcp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
