> 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.md).

# GCP

## Create Teleskope Service Account

Create a Teleskope service account in your GCP project. For **BigQuery**, we have downloadable Terraform scripts [here](/connectors/gcp/bigquery/terraform-scripts.md) 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}"
}
```

## Grant Teleskope Access to the Service Account

How Teleskope authenticates as the service account depends on your deployment model. Follow **one** of the two sections below.

### Teleskope-Managed (GCP) Deployments

If Teleskope runs inside your own GCP project (Teleskope-Managed), the platform authenticates with native GCP service-account impersonation. **Do not configure workload identity federation or any AWS trust**: that applies to SaaS only, and the workload-federation fields are left blank when the project is enrolled.

Grant Teleskope's application service account permission to impersonate the Teleskope connector service account (your Teleskope account team will confirm the application service account's email, of the form `teleskope-<name>-app@<deployment-project>.iam.gserviceaccount.com`):

```
gcloud iam service-accounts add-iam-policy-binding \
  teleskope@{project_id}.iam.gserviceaccount.com \
  --member="serviceAccount:teleskope-<name>-app@<deployment-project>.iam.gserviceaccount.com" \
  --role="roles/iam.serviceAccountTokenCreator"
```

If you created the connector service account inside the Teleskope deployment project itself, this permission is already in place and no grant is needed.

### Configure Workload Identity Federation (SaaS Only)

Teleskope SaaS is run in an isolated AWS account. In order to grant Teleskope SaaS the ability to connect to GCP, you will need to configure workload identity federation. **Skip this entire section for Teleskope-Managed deployments.**

#### 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}/*",
  ]
}
```
