Skip to content

Commit

Permalink
Add bigquery connection of type CLOUD_RESOURCE & make other examples …
Browse files Browse the repository at this point in the history
…GA. (#6020)
  • Loading branch information
gutschenritter authored May 13, 2022
1 parent bef9f1a commit 39ac35c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
22 changes: 18 additions & 4 deletions mmv1/products/bigqueryconnection/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ name: BigqueryConnection
display_name: BigQuery Connection
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://bigqueryconnection.googleapis.com/v1beta1/
name: ga
base_url: https://bigqueryconnection.googleapis.com/v1/
scopes:
- https://www.googleapis.com/auth/bigquery
apis_required:
Expand Down Expand Up @@ -74,9 +74,11 @@ objects:
description: |
True if the connection has credential assigned.
- !ruby/object:Api::Type::NestedObject
name: cloudSql
name: 'cloudSql'
exactly_one_of:
- cloud_sql
- cloud_resource
description: Cloud SQL properties.
required: true
properties:
- !ruby/object:Api::Type::String
name: 'instanceId'
Expand Down Expand Up @@ -107,3 +109,15 @@ objects:
- :DATABASE_TYPE_UNSPECIFIED
- :POSTGRES
- :MYSQL
- !ruby/object:Api::Type::NestedObject
name: 'cloudResource'
exactly_one_of:
- cloud_sql
- cloud_resource
description: Cloud Resource properties.
send_empty_value: true
properties:
- !ruby/object:Api::Type::String
name: serviceAccountId
description: The account ID of the service created for the purpose of this connection.
output: true
8 changes: 6 additions & 2 deletions mmv1/products/bigqueryconnection/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
encoder: templates/terraform/encoders/bigquery_connection.go.erb
examples:
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "bigquery_connection_basic"
pull_external: true
primary_resource_id: "connection"
Expand All @@ -47,7 +46,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
ignore_read_extra:
- "cloud_sql.0.credential" # password removed
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "bigquery_connection_full"
pull_external: true
primary_resource_id: "connection"
Expand All @@ -64,6 +62,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides
deletion_protection: "false"
ignore_read_extra:
- "cloud_sql.0.credential" # password removed
- !ruby/object:Provider::Terraform::Examples
name: "bigquery_connection_cloud_resource"
pull_external: true
primary_resource_id: "connection"
vars:
connection_id: "my-connection"
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_sql_database_instance" "instance" {
provider = google-beta
name = "<%= ctx[:vars]['database_instance_name'] %>"
database_version = "POSTGRES_11"
region = "us-central1"
Expand All @@ -11,7 +10,6 @@ resource "google_sql_database_instance" "instance" {
}

resource "google_sql_database" "db" {
provider = google-beta
instance = google_sql_database_instance.instance.name
name = "db"
}
Expand All @@ -22,14 +20,12 @@ resource "random_password" "pwd" {
}

resource "google_sql_user" "user" {
provider = google-beta
name = "<%= ctx[:vars]['username'] %>"
instance = google_sql_database_instance.instance.name
password = random_password.pwd.result
}

resource "google_bigquery_connection" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
friendly_name = "👋"
description = "a riveting description"
cloud_sql {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "google_bigquery_connection" "<%= ctx[:primary_resource_id] %>" {
connection_id = "<%= ctx[:vars]['connection_id'] %>"
location = "US"
friendly_name = "👋"
description = "a riveting description"
cloud_resource {}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_sql_database_instance" "instance" {
provider = google-beta
name = "<%= ctx[:vars]['database_instance_name'] %>"
database_version = "POSTGRES_11"
region = "us-central1"
Expand All @@ -11,7 +10,6 @@ resource "google_sql_database_instance" "instance" {
}

resource "google_sql_database" "db" {
provider = google-beta
instance = google_sql_database_instance.instance.name
name = "db"
}
Expand All @@ -22,14 +20,12 @@ resource "random_password" "pwd" {
}

resource "google_sql_user" "user" {
provider = google-beta
name = "<%= ctx[:vars]['username'] %>"
instance = google_sql_database_instance.instance.name
password = random_password.pwd.result
}

resource "google_bigquery_connection" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
connection_id = "<%= ctx[:vars]['connection_id'] %>"
location = "US"
friendly_name = "👋"
Expand Down

0 comments on commit 39ac35c

Please sign in to comment.