» google_bigquery_connection

A connection allows BigQuery connections to external data sources..

To get more information about Connection, see:

» Example Usage - Bigquery Connection Basic

resource "google_sql_database_instance" "instance" {
    provider         = google-beta
    name             = "my-database-instance"
    database_version = "POSTGRES_11"
    region           = "us-central1"
    settings {
        tier = "db-f1-micro"
    }
}

resource "google_sql_database" "db" {
    provider = google-beta
    instance = google_sql_database_instance.instance.name
    name     = "db"
}

resource "random_password" "pwd" {
    length = 16
    special = false
}

resource "google_sql_user" "user" {
    provider = google-beta
    name = "user"
    instance = google_sql_database_instance.instance.name
    password = random_password.pwd.result
}

resource "google_bigquery_connection" "connection" {
    provider      = google-beta
    friendly_name = "๐Ÿ‘‹"
    description   = "a riveting description"
    cloud_sql {
        instance_id = google_sql_database_instance.instance.connection_name
        database    = google_sql_database.db.name
        type        = "POSTGRES"
        credential {
          username = google_sql_user.user.name
          password = google_sql_user.user.password
        }
    }
}

» Example Usage - Bigquery Connection Full

resource "google_sql_database_instance" "instance" {
    provider         = google-beta
    name             = "my-database-instance"
    database_version = "POSTGRES_11"
    region           = "us-central1"
    settings {
        tier = "db-f1-micro"
    }
}

resource "google_sql_database" "db" {
    provider = google-beta
    instance = google_sql_database_instance.instance.name
    name     = "db"
}

resource "random_password" "pwd" {
    length = 16
    special = false
}

resource "google_sql_user" "user" {
    provider = google-beta
    name = "user"
    instance = google_sql_database_instance.instance.name
    password = random_password.pwd.result
}

resource "google_bigquery_connection" "connection" {
    provider      = google-beta
    connection_id = "my-connection"
    location      = "US"
    friendly_name = "๐Ÿ‘‹"
    description   = "a riveting description"
    cloud_sql {
        instance_id = google_sql_database_instance.instance.connection_name
        database    = google_sql_database.db.name
        type        = "POSTGRES"
        credential {
          username = google_sql_user.user.name
          password = google_sql_user.user.password
        }
    }
}

» Argument Reference

The following arguments are supported:

  • cloud_sql - (Required) Cloud SQL properties. Structure is documented below.

The cloud_sql block supports:

  • instance_id - (Required) Cloud SQL instance ID in the form project:location:instance.

  • database - (Required) Database name.

  • credential - (Required) Cloud SQL properties. Structure is documented below.

  • type - (Required) Type of the Cloud SQL database. Possible values are DATABASE_TYPE_UNSPECIFIED, POSTGRES, and MYSQL.

The credential block supports:

  • username - (Required) Username for database.

  • password - (Required) Password for database. Note: This property is sensitive and will not be displayed in the plan.


  • connection_id - (Optional) Optional connection id that should be assigned to the created connection.

  • location - (Optional) The geographic location where the connection should reside. Cloud SQL instance must be in the same location as the connection with following exceptions: Cloud SQL us-central1 maps to BigQuery US, Cloud SQL europe-west1 maps to BigQuery EU. Examples: US, EU, asia-northeast1, us-central1, europe-west1. The default value is US.

  • friendly_name - (Optional) A descriptive name for the connection

  • description - (Optional) A descriptive description for the connection

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format {{name}}

  • name - The resource name of the connection in the form of: "projects/{project_id}/locations/{location_id}/connections/{connectionId}"

  • has_credential - True if the connection has credential assigned.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

Connection can be imported using any of these accepted formats:

$ terraform import google_bigquery_connection.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.