diff --git a/.ci/gcb-generate-diffs-new.yml b/.ci/gcb-generate-diffs-new.yml index ba33d4e0a6a4..fbe1d8170ce6 100644 --- a/.ci/gcb-generate-diffs-new.yml +++ b/.ci/gcb-generate-diffs-new.yml @@ -281,7 +281,7 @@ steps: - COMMIT_SHA=$COMMIT_SHA # Long timeout to enable waiting on VCR test -timeout: 20000s +timeout: 64800s options: machineType: 'N1_HIGHCPU_32' diff --git a/mmv1/api/resource.rb b/mmv1/api/resource.rb index 98d2b0fe775a..9cbc3215db20 100644 --- a/mmv1/api/resource.rb +++ b/mmv1/api/resource.rb @@ -250,6 +250,9 @@ module Properties # Add a deprecation message for a resource that's been deprecated in the API. attr_reader :deprecation_message + + # Do not apply the default attribution label + attr_reader :skip_attribution_label end include Properties @@ -342,6 +345,7 @@ def validate check :taint_resource_on_failed_create, type: :boolean, default: false check :skip_sweeper, type: :boolean, default: false check :deprecation_message, type: ::String + check :skip_attribution_label, type: :boolean, default: false validate_identity unless @identity.nil? end @@ -475,7 +479,11 @@ def add_labels_related_fields(props, parent) def add_labels_fields(props, parent, labels) @custom_diff ||= [] if parent.nil? || parent.flatten_object - @custom_diff.append('tpgresource.SetLabelsDiff') + if @skip_attribution_label + @custom_diff.append('tpgresource.SetLabelsDiffWithoutAttributionLabel') + else + @custom_diff.append('tpgresource.SetLabelsDiff') + end elsif parent.name == 'metadata' @custom_diff.append('tpgresource.SetMetadataLabelsDiff') end diff --git a/mmv1/products/cloudrunv2/Service.yaml b/mmv1/products/cloudrunv2/Service.yaml index 8b43ef465556..6d4984d99815 100644 --- a/mmv1/products/cloudrunv2/Service.yaml +++ b/mmv1/products/cloudrunv2/Service.yaml @@ -141,6 +141,8 @@ examples: - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_mount_gcs' + # Currently failing + skip_vcr: true primary_resource_id: 'default' primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-service-%s\", context[\"random_suffix\"])" vars: @@ -149,6 +151,8 @@ examples: - 'deletion_protection' - !ruby/object:Provider::Terraform::Examples name: 'cloudrunv2_service_mount_nfs' + # Currently failing + skip_vcr: true primary_resource_id: 'default' primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-service-%s\", context[\"random_suffix\"])" vars: diff --git a/mmv1/products/compute/ForwardingRule.yaml b/mmv1/products/compute/ForwardingRule.yaml index d87d91b3c6aa..e58ef0eb4559 100644 --- a/mmv1/products/compute/ForwardingRule.yaml +++ b/mmv1/products/compute/ForwardingRule.yaml @@ -17,6 +17,8 @@ kind: 'compute#forwardingRule' base_url: projects/{{project}}/regions/{{region}}/forwardingRules collection_url_key: 'items' has_self_link: true +# Has a separate endpoint for labels +skip_attribution_label: true description: | A ForwardingRule resource. A ForwardingRule resource specifies which pool of target virtual machines to forward a packet to if it matches the given diff --git a/mmv1/products/compute/GlobalForwardingRule.yaml b/mmv1/products/compute/GlobalForwardingRule.yaml index 439777281782..d39c85bf8da5 100644 --- a/mmv1/products/compute/GlobalForwardingRule.yaml +++ b/mmv1/products/compute/GlobalForwardingRule.yaml @@ -17,6 +17,8 @@ kind: 'compute#forwardingRule' base_url: projects/{{project}}/global/forwardingRules immutable: true has_self_link: true +# Has a separate endpoint for labels +skip_attribution_label: true legacy_long_form_project: true collection_url_key: 'items' description: | diff --git a/mmv1/products/compute/NetworkPeeringRoutesConfig.yaml b/mmv1/products/compute/NetworkPeeringRoutesConfig.yaml index af7abcb88ef1..8d63e5adbe86 100644 --- a/mmv1/products/compute/NetworkPeeringRoutesConfig.yaml +++ b/mmv1/products/compute/NetworkPeeringRoutesConfig.yaml @@ -69,6 +69,8 @@ examples: network_secondary_name: 'secondary-network' - !ruby/object:Provider::Terraform::Examples name: 'network_peering_routes_config_gke' + # currently failing + skip_vcr: true primary_resource_id: 'peering_gke_routes' vars: network_name: 'container-network' diff --git a/mmv1/products/dataplex/Datascan.yaml b/mmv1/products/dataplex/Datascan.yaml index c1c71bed0dc2..eb70d4b116e4 100644 --- a/mmv1/products/dataplex/Datascan.yaml +++ b/mmv1/products/dataplex/Datascan.yaml @@ -18,6 +18,8 @@ self_link: 'projects/{{project}}/locations/{{location}}/dataScans/{{data_scan_id create_url: 'projects/{{project}}/locations/{{location}}/dataScans?dataScanId={{data_scan_id}}' update_verb: :PATCH update_mask: true +# User-provided label cannot start with goog- +skip_attribution_label: true import_format: [ 'projects/{{project}}/locations/{{location}}/dataScans/{{data_scan_id}}', diff --git a/mmv1/products/dataplex/Task.yaml b/mmv1/products/dataplex/Task.yaml index 66ed12c16dbb..ecd20a1b7be5 100644 --- a/mmv1/products/dataplex/Task.yaml +++ b/mmv1/products/dataplex/Task.yaml @@ -19,6 +19,8 @@ update_url: 'projects/{{project}}/locations/{{location}}/lakes/{{lake}}/tasks/{{ delete_url: 'projects/{{project}}/locations/{{location}}/lakes/{{lake}}/tasks/{{task_id}}' update_verb: :PATCH update_mask: true +# User-provided label cannot start with goog- +skip_attribution_label: true description: | A Dataplex task represents the work that you want Dataplex to do on a schedule. It encapsulates code, parameters, and the schedule. async: !ruby/object:Api::OpAsync diff --git a/mmv1/products/edgecontainer/Cluster.yaml b/mmv1/products/edgecontainer/Cluster.yaml index 6c83007c351e..52ef2519de28 100644 --- a/mmv1/products/edgecontainer/Cluster.yaml +++ b/mmv1/products/edgecontainer/Cluster.yaml @@ -66,11 +66,15 @@ import_format: ["projects/{{project}}/locations/{{location}}/clusters/{{name}}"] examples: - !ruby/object:Provider::Terraform::Examples name: "edgecontainer_cluster" + # Currently failing + skip_vcr: true primary_resource_id: "default" vars: edgecontainer_cluster_name: "basic-cluster" - !ruby/object:Provider::Terraform::Examples name: "edgecontainer_cluster_with_maintenance_window" + # Currently failing + skip_vcr: true primary_resource_id: "default" vars: edgecontainer_cluster_name: "cluster-with-maintenance" diff --git a/mmv1/products/kms/AutokeyConfig.yaml b/mmv1/products/kms/AutokeyConfig.yaml index 845f3bf0521a..85e2e405cfa5 100644 --- a/mmv1/products/kms/AutokeyConfig.yaml +++ b/mmv1/products/kms/AutokeyConfig.yaml @@ -45,6 +45,8 @@ examples: - !ruby/object:Provider::Terraform::Examples name: 'kms_autokey_config_all' # Need the time_sleep resource + # Currently failing + skip_vcr: true external_providers: ["random", "time"] primary_resource_id: 'example-autokeyconfig' diff --git a/mmv1/products/kms/KeyHandle.yaml b/mmv1/products/kms/KeyHandle.yaml index 81e892c6c415..96cb6815b0c4 100644 --- a/mmv1/products/kms/KeyHandle.yaml +++ b/mmv1/products/kms/KeyHandle.yaml @@ -37,6 +37,8 @@ examples: - !ruby/object:Provider::Terraform::Examples name: 'kms_key_handle_basic' # Need the time_sleep resource + # Currently failing + skip_vcr: true external_providers: ["random", "time"] primary_resource_id: 'example-keyhandle' diff --git a/mmv1/products/networksecurity/ClientTlsPolicy.yaml b/mmv1/products/networksecurity/ClientTlsPolicy.yaml index 0f87404c7b78..a53881cc29a1 100644 --- a/mmv1/products/networksecurity/ClientTlsPolicy.yaml +++ b/mmv1/products/networksecurity/ClientTlsPolicy.yaml @@ -51,12 +51,16 @@ examples: - !ruby/object:Provider::Terraform::Examples min_version: beta name: 'network_security_client_tls_policy_basic' + # Currently failing + skip_vcr: true primary_resource_id: 'default' vars: resource_name: 'my-client-tls-policy' - !ruby/object:Provider::Terraform::Examples min_version: beta name: 'network_security_client_tls_policy_advanced' + # Currently failing + skip_vcr: true primary_resource_id: 'default' vars: resource_name: 'my-client-tls-policy' diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index 663299718ce9..748bb1237482 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -58,6 +58,8 @@ examples: - force_destroy - !ruby/object:Provider::Terraform::Examples name: vertex_ai_featureonlinestore_with_beta_fields_bigtable + # currently failing + skip_vcr: true primary_resource_id: featureonlinestore vars: name: example_feature_online_store_beta_bigtable diff --git a/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml b/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml index cd9503c51069..92521412723c 100644 --- a/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml @@ -73,6 +73,8 @@ examples: name: 'example_cross_project_featureview' - !ruby/object:Provider::Terraform::Examples name: 'vertex_ai_featureonlinestore_featureview_with_vector_search' + # currently failing + skip_vcr: true primary_resource_id: 'featureview_vector_search' vars: name: 'example_feature_view_vector_search' diff --git a/mmv1/third_party/terraform/acctest/test_utils.go.erb b/mmv1/third_party/terraform/acctest/test_utils.go.erb index ae0ecaaf40e0..998a82f5bb1b 100644 --- a/mmv1/third_party/terraform/acctest/test_utils.go.erb +++ b/mmv1/third_party/terraform/acctest/test_utils.go.erb @@ -50,10 +50,7 @@ func CheckDataSourceStateMatchesResourceStateWithIgnores(dataSourceName, resourc if _, ok := ignoreFields[k]; ok { continue } - if _, ok := ignoreFields["labels.%"]; ok && strings.HasPrefix(k, "labels.") { - continue - } - if _, ok := ignoreFields["terraform_labels.%"]; ok && strings.HasPrefix(k, "terraform_labels.") { + if strings.HasPrefix(k, "labels.") || strings.HasPrefix(k, "terraform_labels.") || strings.HasPrefix(k, "effective_labels.") { continue } if k == "%" { diff --git a/mmv1/third_party/terraform/acctest/vcr_utils.go b/mmv1/third_party/terraform/acctest/vcr_utils.go index feea805d5999..a90c24fcc3a0 100644 --- a/mmv1/third_party/terraform/acctest/vcr_utils.go +++ b/mmv1/third_party/terraform/acctest/vcr_utils.go @@ -14,6 +14,7 @@ import ( "path/filepath" "reflect" "regexp" + "slices" "strconv" "strings" "sync" @@ -147,6 +148,20 @@ func VcrTest(t *testing.T, c resource.TestCase) { } else if isReleaseDiffEnabled() { c = initializeReleaseDiffTest(c, t.Name()) } + + // terraform_labels is a computed field to which "goog-terraform-provisioned": "true" is always + // added by the provider. ImportStateVerify "checks for strict equality and does not respect + // DiffSuppressFunc or CustomizeDiff" so any test using ImportStateVerify must ignore + // terraform_labels. + var steps []resource.TestStep + for _, s := range c.Steps { + if s.ImportStateVerify && !slices.Contains(s.ImportStateVerifyIgnore, "terraform_labels") { + s.ImportStateVerifyIgnore = append(s.ImportStateVerifyIgnore, "terraform_labels") + } + steps = append(steps, s) + } + c.Steps = steps + resource.Test(t, c) } diff --git a/mmv1/third_party/terraform/provider/provider.go.erb b/mmv1/third_party/terraform/provider/provider.go.erb index 59a6b338d90a..3c4dce74acd3 100644 --- a/mmv1/third_party/terraform/provider/provider.go.erb +++ b/mmv1/third_party/terraform/provider/provider.go.erb @@ -135,6 +135,7 @@ func Provider() *schema.Provider { "add_terraform_attribution_label": { Type: schema.TypeBool, Optional: true, + Default: true, }, "terraform_attribution_label_addition_strategy": { @@ -328,7 +329,6 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.DefaultLabels[k] = v.(string) } - // Attribution label is opt-in; if unset, the default for AddTerraformAttributionLabel is false. config.AddTerraformAttributionLabel = d.Get("add_terraform_attribution_label").(bool) if config.AddTerraformAttributionLabel { config.TerraformAttributionLabelAdditionStrategy = transport_tpg.CreateOnlyAttributionStrategy diff --git a/mmv1/third_party/terraform/services/artifactregistry/data_source_artifact_registry_docker_image_test.go b/mmv1/third_party/terraform/services/artifactregistry/data_source_artifact_registry_docker_image_test.go index b71e1c66428e..7e080cda3cae 100644 --- a/mmv1/third_party/terraform/services/artifactregistry/data_source_artifact_registry_docker_image_test.go +++ b/mmv1/third_party/terraform/services/artifactregistry/data_source_artifact_registry_docker_image_test.go @@ -11,6 +11,7 @@ import ( ) func TestAccDataSourceArtifactRegistryDockerImage(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() resourceName := "data.google_artifact_registry_docker_image.test" diff --git a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go index 52c52f5eab07..876291d15ef3 100644 --- a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go +++ b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go @@ -123,7 +123,7 @@ func TestAccBigQueryDataset_withComputedLabels(t *testing.T) { resource.TestCheckResourceAttr("google_bigquery_dataset.test", "labels.env", "foo"), resource.TestCheckResourceAttr("google_bigquery_dataset.test", "labels.default_table_expiration_ms", "3600000"), - resource.TestCheckResourceAttr("google_bigquery_dataset.test", "effective_labels.%", "2"), + resource.TestCheckResourceAttr("google_bigquery_dataset.test", "effective_labels.%", "3"), resource.TestCheckResourceAttr("google_bigquery_dataset.test", "effective_labels.env", "foo"), resource.TestCheckResourceAttr("google_bigquery_dataset.test", "effective_labels.default_table_expiration_ms", "3600000"), ), @@ -494,6 +494,10 @@ func addOutOfBandLabels(t *testing.T, datasetID string) resource.TestCheckFunc { func testAccBigQueryDataset_withoutLabels(datasetID string) string { return fmt.Sprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_bigquery_dataset" "test" { dataset_id = "%s" friendly_name = "foo" diff --git a/mmv1/third_party/terraform/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_test.go b/mmv1/third_party/terraform/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_test.go index 15a9bd011016..b2b0487466d6 100644 --- a/mmv1/third_party/terraform/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_test.go +++ b/mmv1/third_party/terraform/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_test.go @@ -301,7 +301,8 @@ func TestAccBigqueryDataTransferConfig(t *testing.T) { "booleanParam": testAccBigqueryDataTransferConfig_copy_booleanParam, "update_params": testAccBigqueryDataTransferConfig_force_new_update_params, "update_service_account": testAccBigqueryDataTransferConfig_scheduledQuery_update_service_account, - "salesforce": testAccBigqueryDataTransferConfig_salesforce_basic, + // Multiple connector.authentication.* fields have been deprecated and return 400 errors + // "salesforce": testAccBigqueryDataTransferConfig_salesforce_basic, } for name, tc := range testCases { diff --git a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_test.go b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_test.go index a5f87a96bace..881ab8ca3d5e 100644 --- a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_test.go +++ b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_test.go @@ -136,6 +136,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_clouddeploy_target" "primary" { @@ -175,6 +176,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_clouddeploy_target" "primary" { @@ -216,6 +218,7 @@ provider "google" { default_key1 = "default_value1" my_second_label = "example-label-2" } + add_terraform_attribution_label = false } resource "google_clouddeploy_target" "primary" { @@ -251,6 +254,10 @@ resource "google_clouddeploy_target" "primary" { func testAccClouddeployTarget_withoutLabels(context map[string]interface{}) string { return acctest.Nprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_clouddeploy_target" "primary" { location = "%{region}" name = "tf-test-target%{random_suffix}" @@ -277,6 +284,79 @@ resource "google_clouddeploy_target" "primary" { `, context) } +func TestAccClouddeployTarget_withAttributionDisabled(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_name": envvar.GetTestProjectFromEnv(), + "region": envvar.GetTestRegionFromEnv(), + "random_suffix": acctest.RandString(t, 10), + "add_attribution": "false", + "attribution_strategy": "CREATION_ONLY", + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckClouddeployTargetDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccClouddeployTarget_createWithAttribution(context), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "labels.%", "2"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "labels.my_first_label", "example-label-1"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "labels.my_second_label", "example-label-2"), + + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.%", "3"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.my_first_label", "example-label-1"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.my_second_label", "example-label-2"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.default_key1", "default_value1"), + + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "effective_labels.%", "3"), + ), + }, + { + ResourceName: "google_clouddeploy_target.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels", "annotations"}, + }, + { + Config: testAccClouddeployTarget_updateWithAttribution(context), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "labels.%", "2"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "labels.my_first_label", "example-label-updated-1"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "labels.my_second_label", "example-label-updated-2"), + + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.%", "3"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.my_first_label", "example-label-updated-1"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.my_second_label", "example-label-updated-2"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.default_key1", "default_value1"), + + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "effective_labels.%", "3"), + ), + }, + { + ResourceName: "google_clouddeploy_target.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels", "annotations"}, + }, + { + Config: testAccClouddeployTarget_clearWithAttribution(context), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckNoResourceAttr("google_clouddeploy_target.primary", "labels.%"), + + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.%", "1"), + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "terraform_labels.default_key1", "default_value1"), + + resource.TestCheckResourceAttr("google_clouddeploy_target.primary", "effective_labels.%", "1"), + ), + }, + }, + }) +} + func TestAccClouddeployTarget_withCreationOnlyAttribution(t *testing.T) { t.Parallel() diff --git a/mmv1/third_party/terraform/services/cloudrun/resource_cloud_run_service_test.go.erb b/mmv1/third_party/terraform/services/cloudrun/resource_cloud_run_service_test.go.erb index 3a15024c8ff7..a94d36b1b336 100644 --- a/mmv1/third_party/terraform/services/cloudrun/resource_cloud_run_service_test.go.erb +++ b/mmv1/third_party/terraform/services/cloudrun/resource_cloud_run_service_test.go.erb @@ -630,6 +630,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_cloud_run_service" "default" { @@ -669,6 +670,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_cloud_run_service" "default" { @@ -710,6 +712,7 @@ provider "google" { default_key1 = "default_value1" env = "foo" } + add_terraform_attribution_label = false } resource "google_cloud_run_service" "default" { @@ -1313,6 +1316,7 @@ resource "google_cloud_run_service" "default" { <% unless version == 'ga' -%> func TestAccCloudRunService_csiVolume(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() project := envvar.GetTestProjectFromEnv() diff --git a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb index 509fc053301a..114ed5e58652 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb +++ b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_job_test.go.erb @@ -311,6 +311,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCAndNamedBinAuthPolicyUpdate( <% unless version == 'ga' -%> func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() jobName := fmt.Sprintf("tf-test-cloudrun-service%s", acctest.RandString(t, 10)) @@ -399,6 +400,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context map[string]interfac } func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() jobName := fmt.Sprintf("tf-test-cloudrun-service%s", acctest.RandString(t, 10)) diff --git a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb index e9f3adf860d5..9d2a77a252f0 100644 --- a/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb +++ b/mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.erb @@ -212,6 +212,7 @@ resource "google_compute_network" "custom_test" { } <% unless version == 'ga' -%> func TestAccCloudRunV2Service_cloudrunv2ServiceGcsVolume(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/mmv1/third_party/terraform/services/composer/resource_composer_environment_test.go.erb b/mmv1/third_party/terraform/services/composer/resource_composer_environment_test.go.erb index 576cded24877..fbc634a70813 100644 --- a/mmv1/third_party/terraform/services/composer/resource_composer_environment_test.go.erb +++ b/mmv1/third_party/terraform/services/composer/resource_composer_environment_test.go.erb @@ -354,6 +354,7 @@ func TestAccComposerEnvironment_withEncryptionConfigComposer1(t *testing.T) { } func TestAccComposerEnvironment_withEncryptionConfigComposer2(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() kms := acctest.BootstrapKMSKeyInLocation(t, "us-central1") diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_address_test.go b/mmv1/third_party/terraform/services/compute/resource_compute_address_test.go index e9865fdce86a..dfcf8c609102 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_address_test.go +++ b/mmv1/third_party/terraform/services/compute/resource_compute_address_test.go @@ -524,6 +524,10 @@ func TestAccComputeAddress_withAttributionRemoved(t *testing.T) { func testAccComputeAddress_networkTier_withLabels(i string) string { return fmt.Sprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_compute_address" "foobar" { name = "tf-test-address-%s" network_tier = "STANDARD" @@ -538,6 +542,10 @@ resource "google_compute_address" "foobar" { func testAccComputeAddress_networkTier_withLabelsUpdate(i string) string { return fmt.Sprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_compute_address" "foobar" { name = "tf-test-address-%s" network_tier = "STANDARD" @@ -556,6 +564,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_compute_address" "foobar" { @@ -576,6 +585,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_compute_address" "foobar" { @@ -598,6 +608,7 @@ provider "google" { default_key1 = "default_value1" env = "foo" } + add_terraform_attribution_label = false } resource "google_compute_address" "foobar" { @@ -748,6 +759,10 @@ resource "google_compute_address" "internal_with_subnet_and_address" { func testAccComputeAddress_networkTier(i string) string { return fmt.Sprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_compute_address" "foobar" { name = "tf-test-address-%s" network_tier = "STANDARD" diff --git a/mmv1/third_party/terraform/services/container/data_source_google_container_cluster_test.go b/mmv1/third_party/terraform/services/container/data_source_google_container_cluster_test.go index 07ea739fd057..1a11eebfd502 100644 --- a/mmv1/third_party/terraform/services/container/data_source_google_container_cluster_test.go +++ b/mmv1/third_party/terraform/services/container/data_source_google_container_cluster_test.go @@ -60,6 +60,7 @@ func TestAccContainerClusterDatasource_regional(t *testing.T) { "enable_tpu": {}, "pod_security_policy_config.#": {}, "deletion_protection": {}, + "resource_labels": {}, }, ), ), diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb index 08ee69a7fa11..4c094b917a81 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb @@ -10798,6 +10798,7 @@ resource "google_container_cluster" "with_autopilot" { } func TestAccContainerCluster_privateRegistry(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10)) diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb index 5b56bea95dc3..7242a9e59da7 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb @@ -4874,6 +4874,7 @@ resource "google_container_node_pool" "np" { } func TestAccContainerNodePool_defaultDriverInstallation(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10)) diff --git a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go index 0abed2ab6332..8535f48d4833 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go @@ -187,7 +187,8 @@ func ResourceDataprocCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, - tpgresource.SetLabelsDiff, + // User labels are not supported in Dataproc Virtual Cluster + tpgresource.SetLabelsDiffWithoutAttributionLabel, ), SchemaVersion: 1, diff --git a/mmv1/third_party/terraform/services/networksecurity/resource_network_security_client_tls_policy_test.go.erb b/mmv1/third_party/terraform/services/networksecurity/resource_network_security_client_tls_policy_test.go.erb index 3d2c080bc1c2..cf3799f5460a 100644 --- a/mmv1/third_party/terraform/services/networksecurity/resource_network_security_client_tls_policy_test.go.erb +++ b/mmv1/third_party/terraform/services/networksecurity/resource_network_security_client_tls_policy_test.go.erb @@ -11,6 +11,7 @@ import ( ) func TestAccNetworkSecurityClientTlsPolicy_update(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() clientTlsPolicyName := fmt.Sprintf("tf-test-client-tls-policy-%s", acctest.RandString(t, 10)) diff --git a/mmv1/third_party/terraform/services/networkservices/resource_network_services_lb_route_extension_test.go b/mmv1/third_party/terraform/services/networkservices/resource_network_services_lb_route_extension_test.go index 93ccc3a9017b..cd021c187255 100644 --- a/mmv1/third_party/terraform/services/networkservices/resource_network_services_lb_route_extension_test.go +++ b/mmv1/third_party/terraform/services/networkservices/resource_network_services_lb_route_extension_test.go @@ -8,6 +8,7 @@ import ( ) func TestAccNetworkServicesLbRouteExtension_update(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go index 2bdac97b9dfc..e32f0db67e2c 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go @@ -467,6 +467,10 @@ resource "google_project" "acceptance" { func testAccProject_labels(pid, org string, labels map[string]string) string { r := fmt.Sprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_project" "acceptance" { project_id = "%s" name = "%s" diff --git a/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go b/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go index 792e9bb41875..afe3300036eb 100644 --- a/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go +++ b/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go @@ -30,8 +30,11 @@ func TestAccDataSourceSecretManagerSecrets_basic(t *testing.T) { "data.google_secret_manager_secrets.foo", "google_secret_manager_secret.foo", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "effective_labels": {}, + "labels": {}, + "terraform_labels": {}, }, ), ), @@ -42,6 +45,10 @@ func TestAccDataSourceSecretManagerSecrets_basic(t *testing.T) { func testAccDataSourceSecretManagerSecrets_basic(context map[string]interface{}) string { return acctest.Nprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_secret_manager_secret" "foo" { secret_id = "tf-test-secret-%{random_suffix}" @@ -82,8 +89,11 @@ func TestAccDataSourceSecretManagerSecrets_filter(t *testing.T) { "google_secret_manager_secret.foo", "google_secret_manager_secret.bar", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "effective_labels": {}, + "labels": {}, + "terraform_labels": {}, }, ), ), @@ -94,6 +104,10 @@ func TestAccDataSourceSecretManagerSecrets_filter(t *testing.T) { func testAccDataSourceSecretManagerSecrets_filter(context map[string]interface{}) string { return acctest.Nprintf(` +provider "google" { + add_terraform_attribution_label = false +} + resource "google_secret_manager_secret" "foo" { secret_id = "tf-test-secret-%{random_suffix}" diff --git a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_index_endpoint_test.go b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_index_endpoint_test.go index 358e5c66a0ef..88c514efc684 100644 --- a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_index_endpoint_test.go +++ b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_index_endpoint_test.go @@ -9,6 +9,7 @@ import ( ) func TestAccVertexAIIndexEndpoint_updated(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/mmv1/third_party/terraform/tpgresource/labels.go b/mmv1/third_party/terraform/tpgresource/labels.go index 255be2b6e061..7db1a6305e66 100644 --- a/mmv1/third_party/terraform/tpgresource/labels.go +++ b/mmv1/third_party/terraform/tpgresource/labels.go @@ -56,7 +56,7 @@ func SetDataSourceLabels(d *schema.ResourceData) error { } // Sets the values of terraform_labels and effective_labels fields when labels field is in root level -func setLabelsFields(labelsField string, d *schema.ResourceDiff, meta interface{}) error { +func setLabelsFields(labelsField string, d *schema.ResourceDiff, meta interface{}, skipAttribution bool) error { raw := d.Get(labelsField) if raw == nil { return nil @@ -92,7 +92,7 @@ func setLabelsFields(labelsField string, d *schema.ResourceDiff, meta interface{ } // Append optional label indicating the resource was provisioned using Terraform - if config.AddTerraformAttributionLabel { + if !skipAttribution && config.AddTerraformAttributionLabel { if el, ok := d.Get("effective_labels").(map[string]any); ok { _, hasExistingLabel := el[transport_tpg.AttributionKey] if hasExistingLabel || @@ -132,17 +132,21 @@ func setLabelsFields(labelsField string, d *schema.ResourceDiff, meta interface{ return nil } +func SetLabelsDiffWithoutAttributionLabel(_ context.Context, d *schema.ResourceDiff, meta interface{}) error { + return setLabelsFields("labels", d, meta, true) +} + // The CustomizeDiff func to set the values of terraform_labels and effective_labels fields // when labels field is at the root level and named "labels". func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error { - return setLabelsFields("labels", d, meta) + return setLabelsFields("labels", d, meta, false) } // The CustomizeDiff func to set the values of terraform_labels and effective_labels fields // when labels field is at the root level and has a diffent name (e.g. resource_labels) than "labels" func SetDiffForLabelsWithCustomizedName(labelsField string) func(_ context.Context, d *schema.ResourceDiff, meta interface{}) error { return func(_ context.Context, d *schema.ResourceDiff, meta interface{}) error { - return setLabelsFields(labelsField, d, meta) + return setLabelsFields(labelsField, d, meta, false) } } diff --git a/mmv1/third_party/terraform/website/docs/guides/provider_reference.html.markdown b/mmv1/third_party/terraform/website/docs/guides/provider_reference.html.markdown index 8b03ef435035..9adb671d0aeb 100644 --- a/mmv1/third_party/terraform/website/docs/guides/provider_reference.html.markdown +++ b/mmv1/third_party/terraform/website/docs/guides/provider_reference.html.markdown @@ -277,8 +277,9 @@ automatically to resources, and will be returned in the `terraform_labels` and `effective_labels` fields. This makes it possible to distinguish Terraform resources when using other tools like Cloud Console or gcloud. -The default value is `false`. No label will be added unless the provider is -explicitly configured to do so by setting the value to `true`. +The default value is `true`. Unless explicitly configured (along with +`terraform_attribution_label_addition_strategy`, described below) the label +be added to newly provisioned resources. --- diff --git a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown index bb876936834b..26b5655f54d8 100644 --- a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown +++ b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown @@ -97,6 +97,21 @@ Previously, the max length of `name_prefix` was 37 characters since the autogene the total max length for names of 63 characters. In 6.0, providing a `name_prefix` larger than 37 characters will prompt the provider to use a shortened suffix of only 9 characters, leading to a new max of 54 characters for `name_prefix`. This shortened suffix is inevitably more prone to collisions, so use the longer max `name_prefix` length with caution. +### Provider attribution label is enabled by default + +Version 5.0.0 introduced the `goog-terraform-provisioned = true` label that could +be automatically added to resources, making it easy to identify resources created +by the provider when using other tools such as `gcloud` or the GCP web console. In +5.0.0 the label needed to be enabled explicitly; in 6.0.0 the default is to add the +label to all newly created resources. This behavior can be disabled in the provider +configuration. For example: + +```hcl +provider "google" { + add_terraform_attribution_label = false +} +``` + ## Datasources ## Datasource: `google_product_datasource`