diff --git a/.changelog/6988.txt b/.changelog/6988.txt new file mode 100644 index 00000000000..2b05e907147 --- /dev/null +++ b/.changelog/6988.txt @@ -0,0 +1,6 @@ +```release-note:enhancement +bigquery: added `cloud_sql.service_account_id` and `azure.identity` output fields +``` +```release-note:enhancement +bigquery: added `cloud_spanner.use_serverless_analytics` field +``` diff --git a/google/resource_bigquery_connection.go b/google/resource_bigquery_connection.go index 96978bfadf2..2e36e83b647 100644 --- a/google/resource_bigquery_connection.go +++ b/google/resource_bigquery_connection.go @@ -95,6 +95,11 @@ func resourceBigqueryConnectionConnection() *schema.Resource { Computed: true, Description: `The client id of the Azure Active Directory Application.`, }, + "identity": { + Type: schema.TypeString, + Computed: true, + Description: `A unique Google-owned and Google-generated identity for the Connection. This identity will be used to access the user's Azure Active Directory Application.`, + }, "object_id": { Type: schema.TypeString, Computed: true, @@ -142,6 +147,11 @@ func resourceBigqueryConnectionConnection() *schema.Resource { Optional: true, Description: `If parallelism should be used when reading from Cloud Spanner`, }, + "use_serverless_analytics": { + Type: schema.TypeBool, + Optional: true, + Description: `If the serverless analytics service should be used to read data from Cloud Spanner. useParallelism must be set when using serverless analytics`, + }, }, }, ExactlyOneOf: []string{"cloud_sql", "aws", "azure", "cloud_spanner", "cloud_resource"}, @@ -149,7 +159,7 @@ func resourceBigqueryConnectionConnection() *schema.Resource { "cloud_sql": { Type: schema.TypeList, Optional: true, - Description: `A nested object resource`, + Description: `Connection properties specific to the Cloud SQL.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -190,6 +200,11 @@ func resourceBigqueryConnectionConnection() *schema.Resource { ValidateFunc: validateEnum([]string{"DATABASE_TYPE_UNSPECIFIED", "POSTGRES", "MYSQL"}), Description: `Type of the Cloud SQL database. Possible values: ["DATABASE_TYPE_UNSPECIFIED", "POSTGRES", "MYSQL"]`, }, + "service_account_id": { + Type: schema.TypeString, + Computed: true, + Description: `When the connection is used in the context of an operation in BigQuery, this service account will serve as the identity being used for connecting to the CloudSQL instance specified in this connection.`, + }, }, }, ExactlyOneOf: []string{"cloud_sql", "aws", "azure", "cloud_spanner", "cloud_resource"}, @@ -646,6 +661,8 @@ func flattenBigqueryConnectionConnectionCloudSql(v interface{}, d *schema.Resour flattenBigqueryConnectionConnectionCloudSqlCredential(original["credential"], d, config) transformed["type"] = flattenBigqueryConnectionConnectionCloudSqlType(original["type"], d, config) + transformed["service_account_id"] = + flattenBigqueryConnectionConnectionCloudSqlServiceAccountId(original["serviceAccountId"], d, config) return []interface{}{transformed} } func flattenBigqueryConnectionConnectionCloudSqlInstanceId(v interface{}, d *schema.ResourceData, config *Config) interface{} { @@ -669,6 +686,10 @@ func flattenBigqueryConnectionConnectionCloudSqlType(v interface{}, d *schema.Re return v } +func flattenBigqueryConnectionConnectionCloudSqlServiceAccountId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + func flattenBigqueryConnectionConnectionAws(v interface{}, d *schema.ResourceData, config *Config) interface{} { if v == nil { return nil @@ -724,6 +745,8 @@ func flattenBigqueryConnectionConnectionAzure(v interface{}, d *schema.ResourceD flattenBigqueryConnectionConnectionAzureCustomerTenantId(original["customerTenantId"], d, config) transformed["redirect_uri"] = flattenBigqueryConnectionConnectionAzureRedirectUri(original["redirectUri"], d, config) + transformed["identity"] = + flattenBigqueryConnectionConnectionAzureIdentity(original["identity"], d, config) return []interface{}{transformed} } func flattenBigqueryConnectionConnectionAzureApplication(v interface{}, d *schema.ResourceData, config *Config) interface{} { @@ -746,6 +769,10 @@ func flattenBigqueryConnectionConnectionAzureRedirectUri(v interface{}, d *schem return v } +func flattenBigqueryConnectionConnectionAzureIdentity(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + func flattenBigqueryConnectionConnectionCloudSpanner(v interface{}, d *schema.ResourceData, config *Config) interface{} { if v == nil { return nil @@ -759,6 +786,8 @@ func flattenBigqueryConnectionConnectionCloudSpanner(v interface{}, d *schema.Re flattenBigqueryConnectionConnectionCloudSpannerDatabase(original["database"], d, config) transformed["use_parallelism"] = flattenBigqueryConnectionConnectionCloudSpannerUseParallelism(original["useParallelism"], d, config) + transformed["use_serverless_analytics"] = + flattenBigqueryConnectionConnectionCloudSpannerUseServerlessAnalytics(original["useServerlessAnalytics"], d, config) return []interface{}{transformed} } func flattenBigqueryConnectionConnectionCloudSpannerDatabase(v interface{}, d *schema.ResourceData, config *Config) interface{} { @@ -769,6 +798,10 @@ func flattenBigqueryConnectionConnectionCloudSpannerUseParallelism(v interface{} return v } +func flattenBigqueryConnectionConnectionCloudSpannerUseServerlessAnalytics(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + func flattenBigqueryConnectionConnectionCloudResource(v interface{}, d *schema.ResourceData, config *Config) interface{} { if v == nil { return nil @@ -835,6 +868,13 @@ func expandBigqueryConnectionConnectionCloudSql(v interface{}, d TerraformResour transformed["type"] = transformedType } + transformedServiceAccountId, err := expandBigqueryConnectionConnectionCloudSqlServiceAccountId(original["service_account_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedServiceAccountId); val.IsValid() && !isEmptyValue(val) { + transformed["serviceAccountId"] = transformedServiceAccountId + } + return transformed, nil } @@ -884,6 +924,10 @@ func expandBigqueryConnectionConnectionCloudSqlType(v interface{}, d TerraformRe return v, nil } +func expandBigqueryConnectionConnectionCloudSqlServiceAccountId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandBigqueryConnectionConnectionAws(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -981,6 +1025,13 @@ func expandBigqueryConnectionConnectionAzure(v interface{}, d TerraformResourceD transformed["redirectUri"] = transformedRedirectUri } + transformedIdentity, err := expandBigqueryConnectionConnectionAzureIdentity(original["identity"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedIdentity); val.IsValid() && !isEmptyValue(val) { + transformed["identity"] = transformedIdentity + } + return transformed, nil } @@ -1004,6 +1055,10 @@ func expandBigqueryConnectionConnectionAzureRedirectUri(v interface{}, d Terrafo return v, nil } +func expandBigqueryConnectionConnectionAzureIdentity(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandBigqueryConnectionConnectionCloudSpanner(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -1027,6 +1082,13 @@ func expandBigqueryConnectionConnectionCloudSpanner(v interface{}, d TerraformRe transformed["useParallelism"] = transformedUseParallelism } + transformedUseServerlessAnalytics, err := expandBigqueryConnectionConnectionCloudSpannerUseServerlessAnalytics(original["use_serverless_analytics"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedUseServerlessAnalytics); val.IsValid() && !isEmptyValue(val) { + transformed["useServerlessAnalytics"] = transformedUseServerlessAnalytics + } + return transformed, nil } @@ -1038,6 +1100,10 @@ func expandBigqueryConnectionConnectionCloudSpannerUseParallelism(v interface{}, return v, nil } +func expandBigqueryConnectionConnectionCloudSpannerUseServerlessAnalytics(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandBigqueryConnectionConnectionCloudResource(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/google/resource_bigquery_connection_generated_test.go b/google/resource_bigquery_connection_generated_test.go index 28574f5a671..5bdd5ab2abc 100644 --- a/google/resource_bigquery_connection_generated_test.go +++ b/google/resource_bigquery_connection_generated_test.go @@ -350,6 +350,51 @@ resource "google_bigquery_connection" "connection" { `, context) } +func TestAccBigqueryConnectionConnection_bigqueryConnectionCloudspannerAnalyticsExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + ExternalProviders: map[string]resource.ExternalProvider{ + "random": {}, + "time": {}, + }, + CheckDestroy: testAccCheckBigqueryConnectionConnectionDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBigqueryConnectionConnection_bigqueryConnectionCloudspannerAnalyticsExample(context), + }, + { + ResourceName: "google_bigquery_connection.connection", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location"}, + }, + }, + }) +} + +func testAccBigqueryConnectionConnection_bigqueryConnectionCloudspannerAnalyticsExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_bigquery_connection" "connection" { + connection_id = "tf-test-my-connection%{random_suffix}" + location = "US" + friendly_name = "👋" + description = "a riveting description" + cloud_spanner { + database = "projects/project/instances/instance/databases/database%{random_suffix}" + use_serverless_analytics = true + use_parallelism = true + } +} +`, context) +} + func testAccCheckBigqueryConnectionConnectionDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { for name, rs := range s.RootModule().Resources { diff --git a/website/docs/r/bigquery_connection.html.markdown b/website/docs/r/bigquery_connection.html.markdown index 8b9e40869d8..b3984fe2ec0 100644 --- a/website/docs/r/bigquery_connection.html.markdown +++ b/website/docs/r/bigquery_connection.html.markdown @@ -244,7 +244,7 @@ The following arguments are supported: * `cloud_sql` - (Optional) - A nested object resource + Connection properties specific to the Cloud SQL. Structure is [documented below](#nested_cloud_sql). * `aws` - @@ -291,6 +291,9 @@ The following arguments are supported: Type of the Cloud SQL database. Possible values are `DATABASE_TYPE_UNSPECIFIED`, `POSTGRES`, and `MYSQL`. +* `service_account_id` - + When the connection is used in the context of an operation in BigQuery, this service account will serve as the identity being used for connecting to the CloudSQL instance specified in this connection. + The `credential` block supports: @@ -338,6 +341,9 @@ The following arguments are supported: * `redirect_uri` - The URL user will be redirected to after granting consent during connection setup. +* `identity` - + A unique Google-owned and Google-generated identity for the Connection. This identity will be used to access the user's Azure Active Directory Application. + The `cloud_spanner` block supports: * `database` - @@ -348,6 +354,10 @@ The following arguments are supported: (Optional) If parallelism should be used when reading from Cloud Spanner +* `use_serverless_analytics` - + (Optional) + If the serverless analytics service should be used to read data from Cloud Spanner. useParallelism must be set when using serverless analytics + The `cloud_resource` block supports: * `service_account_id` -