Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KMS support for the google_bigquery_connection resource #10561

Merged
merged 7 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mmv1/products/bigqueryconnection/Connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ examples:
primary_resource_id: "connection"
vars:
connection_id: "my-connection"
- !ruby/object:Provider::Terraform::Examples
name: 'bigquery_connection_kms'
primary_resource_id:
'bq-connection-cmek'
vars:
database_instance_name: 'my-database-instance'
username: 'user'
deletion_protection: 'true'
kms_key_name: 'projects/project/locations/us-central1/keyRings/us-central1/cryptoKeys/bq-key'
test_vars_overrides:
deletion_protection: 'false'
kms_key_name: 'acctest.BootstrapKMSKey(t).CryptoKey.Name'
policyChanged:
"acctest.BootstrapPSARole(t, \"bq-\", \"bigquery-encryption\",
\"roles/cloudkms.cryptoKeyEncrypterDecrypter\"\
)"
oics_vars_overrides:
deletion_protection: 'false'
ignore_read_extra:
- 'cloud_sql.0.credential' # password removed
properties:
- !ruby/object:Api::Type::String
name: name
Expand Down Expand Up @@ -164,6 +184,12 @@ properties:
output: true
description: |
True if the connection has credential assigned.
- !ruby/object:Api::Type::String
name: 'kmsKeyName'
description: |
Optional. The Cloud KMS key that is used for encryption.

Example: projects/[kms_project_id]/locations/[region]/keyRings/[key_region]/cryptoKeys/[key]
- !ruby/object:Api::Type::NestedObject
name: 'cloudSql'
description: Connection properties specific to the Cloud SQL.
Expand Down
38 changes: 38 additions & 0 deletions mmv1/templates/terraform/examples/bigquery_connection_kms.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
resource "google_sql_database_instance" "instance" {
name = "<%= ctx[:vars]['database_instance_name'] %>"
database_version = "POSTGRES_11"
region = "us-central1"
settings {
tier = "db-f1-micro"
}

deletion_protection = "<%= ctx[:vars]['deletion_protection'] %>"
}

resource "google_sql_database" "db" {
instance = google_sql_database_instance.instance.name
name = "db"
}

resource "google_sql_user" "user" {
name = "<%= ctx[:vars]['username'] %>"
instance = google_sql_database_instance.instance.name
password = "tf-test-my-password%{random_suffix}"
}

resource "google_bigquery_connection" "<%= ctx[:primary_resource_id] %>" {
friendly_name = "👋"
description = "a riveting description"
location = "US"
kms_key_name = "<%= ctx[:vars]['kms_key_name'] %>"
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
}
}
}