diff --git a/.changelog/10274.txt b/.changelog/10274.txt new file mode 100644 index 00000000000..8b6a55cf918 --- /dev/null +++ b/.changelog/10274.txt @@ -0,0 +1,6 @@ +```release-note:breaking-change +container: removed deprecated field `advanced_datapath_observability_config.relay_mode` from `google_container_cluster` resource. Users are expected to use `enable_relay` field instead. +``` +```release-note:breaking-change +container: made field `advanced_datapath_observability_config.enable_relay` required in `google_container_cluster` resource +``` \ No newline at end of file diff --git a/.changelog/10313.txt b/.changelog/10313.txt new file mode 100644 index 00000000000..4b9fd58567d --- /dev/null +++ b/.changelog/10313.txt @@ -0,0 +1,9 @@ +```release-note:breaking-change +vpcaccess: removed default values for `min_throughput` and `min_instances` fields on `google_vpc_access_connector` and made them default to values returned from the API when not provided by users +``` +```release-note:breaking-change +vpcaccess: added a conflicting fields restriction between `min_throughput` and `min_instances` fields on `google_vpc_access_connector` +``` +```release-note:breaking-change +vpcaccess: added a conflicting fields restriction between `max_throughput` and `max_instances` fields on `google_vpc_access_connector` +``` \ No newline at end of file diff --git a/.changelog/10367.txt b/.changelog/10367.txt new file mode 100644 index 00000000000..dda2bce5372 --- /dev/null +++ b/.changelog/10367.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +redis: added a `deletion_protection_enabled` field with a default value of `true` to the `google_redis_cluster` resource +``` \ No newline at end of file diff --git a/.changelog/10897.txt b/.changelog/10897.txt new file mode 100644 index 00000000000..334b2db708a --- /dev/null +++ b/.changelog/10897.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: added fields `reserved_internal_range` and `secondary_ip_ranges[].reserved_internal_range` to `google_compute_subnetwork` resource +``` \ No newline at end of file diff --git a/.changelog/11023.txt b/.changelog/11023.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11023.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11038.txt b/.changelog/11038.txt new file mode 100644 index 00000000000..94e66dcafef --- /dev/null +++ b/.changelog/11038.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +pubsub: Allow `schema_settings` of `google_pubsub_topic` to be removed +``` \ No newline at end of file diff --git a/.changelog/11088.txt b/.changelog/11088.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11088.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11101.txt b/.changelog/11101.txt new file mode 100644 index 00000000000..33b6ad1f911 --- /dev/null +++ b/.changelog/11101.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +bigquery: added validation to prevent table view creation if schema contains required fields for `google_bigquery_table` resource +``` \ No newline at end of file diff --git a/.changelog/11117.txt b/.changelog/11117.txt new file mode 100644 index 00000000000..d0a342eba01 --- /dev/null +++ b/.changelog/11117.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +compute: Updated default values of `connection_draining_timeout_sec`, `balancing_mode` and `outlier_detection` in `google_compute_region_backend_service` and `google_compute_backend_service`. +``` \ No newline at end of file diff --git a/.changelog/11126.txt b/.changelog/11126.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11126.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11135.txt b/.changelog/11135.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11135.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11154.txt b/.changelog/11154.txt new file mode 100644 index 00000000000..343341c2e0e --- /dev/null +++ b/.changelog/11154.txt @@ -0,0 +1,3 @@ +```release-note:deprecation +sql: `settings.ip_configuration.require_ssl` is now deprecated within `google_sql_database_instance`. Please use `settings.ip_configuration.ssl_mode` instead. +``` \ No newline at end of file diff --git a/.changelog/11179.txt b/.changelog/11179.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11179.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11190.txt b/.changelog/11190.txt new file mode 100644 index 00000000000..5aba433b925 --- /dev/null +++ b/.changelog/11190.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +cloudrunv2: `liveness_probe` field in `google_cloud_run_v2_service` resource no longer has a default value from API side. Removing this field and applying the change will remove liveness probe from the Cloud Run service. +``` \ No newline at end of file diff --git a/.changelog/11199.txt b/.changelog/11199.txt new file mode 100644 index 00000000000..ba9fb5dacc7 --- /dev/null +++ b/.changelog/11199.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +cloudrunv2: retyped `containers.env` to SET from ARRAY for `google_cloud_run_v2_service` and `google_cloud_run_v2_job`. +``` \ No newline at end of file diff --git a/.changelog/11209.txt b/.changelog/11209.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11209.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11225.txt b/.changelog/11225.txt new file mode 100644 index 00000000000..d0f203bed99 --- /dev/null +++ b/.changelog/11225.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +workstation: `host.gce_instance.disable_ssh` now defaults to true for `google_workstations_workstation_config` +``` \ No newline at end of file diff --git a/.changelog/11226.txt b/.changelog/11226.txt new file mode 100644 index 00000000000..b67c7d6f5dc --- /dev/null +++ b/.changelog/11226.txt @@ -0,0 +1,3 @@ +```release-note:note +billing: updated resource id for `google_billing_project_info` +``` \ No newline at end of file diff --git a/.changelog/11237.txt b/.changelog/11237.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11237.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11240.txt b/.changelog/11240.txt new file mode 100644 index 00000000000..85f764cbe8a --- /dev/null +++ b/.changelog/11240.txt @@ -0,0 +1,3 @@ +```release-note:note +compute: updated resource id for `compute_network_endpoints` +``` \ No newline at end of file diff --git a/.changelog/11255.txt b/.changelog/11255.txt new file mode 100644 index 00000000000..10fc5c94f3d --- /dev/null +++ b/.changelog/11255.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +resourcemanager: Make `deletion-policy` in `google_project` 'PREVENT' by default. This makes deleting them require an explicit intent. `google_project` resources cannot be destroyed unless `deletion_policy` is set to 'ABANDON' or 'NONE' for the resource. +``` \ No newline at end of file diff --git a/.changelog/11256.txt b/.changelog/11256.txt new file mode 100644 index 00000000000..989faa63fd5 --- /dev/null +++ b/.changelog/11256.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +activeDirectory: added `deletion_protection` field to `google_active_directory_domain` to make deleting them require an explicit intent. `google_active_directory_domain` resources now cannot be destroyed unless `deletion_protection = false` is set for the resource. +``` \ No newline at end of file diff --git a/.changelog/11293.txt b/.changelog/11293.txt new file mode 100644 index 00000000000..abaa16417f3 --- /dev/null +++ b/.changelog/11293.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +google_folders: added `deletion_protection` field to `folders` to make deleting them require an explicit intent. `folder` resources now cannot be destroyed unless `deletion_protection = false` is set for the resource. +``` \ No newline at end of file diff --git a/.changelog/11304.txt b/.changelog/11304.txt new file mode 100644 index 00000000000..60f9fff9817 --- /dev/null +++ b/.changelog/11304.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +bigqueryreservation: remove `multi_region_auxiliary` from `google_bigquery_reservation` +``` \ No newline at end of file diff --git a/.changelog/11318.txt b/.changelog/11318.txt new file mode 100644 index 00000000000..d174bd61223 --- /dev/null +++ b/.changelog/11318.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +cloudrunv2: added `deletion_protection` field to `google_cloudrunv2_service` to make deleting them require an explicit intent. `google_cloudrunv2_service` resources now cannot be destroyed unless `deletion_protection = false` is set for the resource. +``` \ No newline at end of file diff --git a/.changelog/11320.txt b/.changelog/11320.txt new file mode 100644 index 00000000000..4d74b7beb5f --- /dev/null +++ b/.changelog/11320.txt @@ -0,0 +1,9 @@ +```release-note:breaking-change +container: three label-related fields are now in `google_container_cluster` resource. `resource_labels` field is non-authoritative and only manages the labels defined by the users on the resource through Terraform. The new output-only `terraform_labels` field merges the labels defined by the users on the resource through Terraform and the default labels configured on the provider. The new output-only `effective_labels` field lists all of labels present on the resource in GCP, including the labels configured through Terraform, the system, and other clients. +``` +```release-note:breaking-change +container: made three fields `resource_labels`, `terraform_labels`, and `effective_labels` be present in `google_container_cluster` datasources. All three fields will have all of labels present on the resource in GCP including the labels configured through Terraform, the system, and other clients, equivalent to `effective_labels` on the resource. +``` +```release-note:breaking-change +edgenetwork: three label-related fields are now in `google_edgenetwork_network ` and `google_edgenetwork_subnet` resources. `labels` field is non-authoritative and only manages the labels defined by the users on the resource through Terraform. The new output-only `terraform_labels` field merges the labels defined by the users on the resource through Terraform and the default labels configured on the provider. The new output-only `effective_labels` field lists all of labels present on the resource in GCP, including the labels configured through Terraform, the system, and other clients. +``` \ No newline at end of file diff --git a/.changelog/11329.txt b/.changelog/11329.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11329.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11354.txt b/.changelog/11354.txt new file mode 100644 index 00000000000..42954b529d2 --- /dev/null +++ b/.changelog/11354.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +identityplatform: removed resource `google_identity_platform_project_default_config` in favor of `google_identity_platform_project_config` +``` \ No newline at end of file diff --git a/.changelog/11356.txt b/.changelog/11356.txt new file mode 100644 index 00000000000..8e02876c06d --- /dev/null +++ b/.changelog/11356.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +storage: removed `no_age` field from `lifecycle_rule.condition` in the `google_storage_bucket` resource +``` \ No newline at end of file diff --git a/.changelog/11393.txt b/.changelog/11393.txt new file mode 100644 index 00000000000..8db532fce0c --- /dev/null +++ b/.changelog/11393.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +bigquery: removed `allow_resource_tags_on_deletion` from `google_bigquery_table`. Resource tags are now always allowed on table deletion. +``` \ No newline at end of file diff --git a/.changelog/11400.txt b/.changelog/11400.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11400.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11409.txt b/.changelog/11409.txt new file mode 100644 index 00000000000..485b1818ccb --- /dev/null +++ b/.changelog/11409.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +compute: stopped the `certifcate_id` field in `google_compute_managed_ssl_certificate` resource being incorrectly marked as a user-configurable value when it should just be an output. +``` \ No newline at end of file diff --git a/.changelog/11434.txt b/.changelog/11434.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11434.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11439.txt b/.changelog/11439.txt new file mode 100644 index 00000000000..af86b3811bf --- /dev/null +++ b/.changelog/11439.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +changed provider labels to add the `goog-terraform-provisioned: true` label by default. +``` \ No newline at end of file diff --git a/.changelog/11448.txt b/.changelog/11448.txt new file mode 100644 index 00000000000..1b0a49a3e82 --- /dev/null +++ b/.changelog/11448.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: changed the behavior of `name_prefix` in multiple Compute resources to allow for a longer max length of 54 characters. See the upgrade guide and resource documentation for more details. +``` \ No newline at end of file diff --git a/.changelog/11450.txt b/.changelog/11450.txt new file mode 100644 index 00000000000..ac2097348a4 --- /dev/null +++ b/.changelog/11450.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +integrations: `create_sample_workflows` and `provision_gmek` are removed from `google_integrations_client` +``` \ No newline at end of file diff --git a/.changelog/11457.txt b/.changelog/11457.txt new file mode 100644 index 00000000000..d1fb1178aee --- /dev/null +++ b/.changelog/11457.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +datastore: `google_datastore_index` has been removed in favor of `google_firestore_index` +``` \ No newline at end of file diff --git a/.changelog/11460.txt b/.changelog/11460.txt new file mode 100644 index 00000000000..beee0a118a4 --- /dev/null +++ b/.changelog/11460.txt @@ -0,0 +1,3 @@ +```release-note:deprecation +alloydb: `network` removed in `google_alloy_db_cluster`. Use `network_config.network` instead. +``` \ No newline at end of file diff --git a/.changelog/11462.txt b/.changelog/11462.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11462.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11471.txt b/.changelog/11471.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11471.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11489.txt b/.changelog/11489.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11489.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11499.txt b/.changelog/11499.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11499.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/11506.txt b/.changelog/11506.txt new file mode 100644 index 00000000000..f00608c337f --- /dev/null +++ b/.changelog/11506.txt @@ -0,0 +1,18 @@ +```release-note:breaking-change +composer: `ip_allocation_policy = []` in `google_composer_environment` is no longer valid configuration. Removing the field from configuration should not produce a diff. +``` +```release-note:breaking-change +compute: `secondary_ip_ranges = []` in `google_compute_subnetwork` is no longer valid configuration. To set an explicitly empty list, use `send_secondary_ip_range_if_empty` and completely remove `secondary_ip_range` from config. +``` +```release-note:breaking-change +compute: `guest_accelerator = []` is no longer valid configuration in `google_compute_instance`. To explicitly set an empty list of objects, set guest_accelerator.count = 0. +``` +```release-note:breaking-change +compute: `google_compute_instance_from_template` and `google_compute_instance_from_machine_image` `network_interface.alias_ip_range, network_interface.access_config, attached_disk, guest_accelerator, service_account, scratch_disk` can no longer be set to an empty block `[]`. Removing the fields from configuration should not produce a diff. +``` +```release-note:breaking-change +container: `guest_accelerator = []` is no longer valid configuration in `google_container_cluster` and `google_container_node_pool`. To explicitly set an empty list of objects, set guest_accelerator.count = 0. +``` +```release-note:breaking-change +container: `guest_accelerator.gpu_driver_installation_config = []` and `guest_accelerator.gpu_sharing_config = []` are no longer valid configuration in `google_container_cluster` and `google_container_node_pool`. Removing the fields from configuration should not produce a diff. +``` \ No newline at end of file diff --git a/.changelog/11513.txt b/.changelog/11513.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/11513.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.changelog/9581.txt b/.changelog/9581.txt new file mode 100644 index 00000000000..13321089f76 --- /dev/null +++ b/.changelog/9581.txt @@ -0,0 +1,6 @@ +```release-note:bug +compute: fixed an issue regarding sending `enabled` field by default for null `iap` message in `google_compute_backend_service` and `google_compute_region_backend_service` +``` +```release-note:breaking-change +compute: Add new required field `enabled` in `google_compute_backend_service` and `google_compute_region_backend_service` +``` \ No newline at end of file diff --git a/.teamcity/components/inputs/services_beta.kt b/.teamcity/components/inputs/services_beta.kt index f34fbacc057..a6c8565d178 100644 --- a/.teamcity/components/inputs/services_beta.kt +++ b/.teamcity/components/inputs/services_beta.kt @@ -301,11 +301,6 @@ var ServicesListBeta = mapOf( "displayName" to "Dataprocmetastore", "path" to "./google-beta/services/dataprocmetastore" ), - "datastore" to mapOf( - "name" to "datastore", - "displayName" to "Datastore", - "path" to "./google-beta/services/datastore" - ), "datastream" to mapOf( "name" to "datastream", "displayName" to "Datastream", diff --git a/.teamcity/components/inputs/services_ga.kt b/.teamcity/components/inputs/services_ga.kt index f8a3bd76e6d..bc928ad729c 100644 --- a/.teamcity/components/inputs/services_ga.kt +++ b/.teamcity/components/inputs/services_ga.kt @@ -301,11 +301,6 @@ var ServicesListGa = mapOf( "displayName" to "Dataprocmetastore", "path" to "./google/services/dataprocmetastore" ), - "datastore" to mapOf( - "name" to "datastore", - "displayName" to "Datastore", - "path" to "./google/services/datastore" - ), "datastream" to mapOf( "name" to "datastream", "displayName" to "Datastream", diff --git a/google/acctest/test_utils.go b/google/acctest/test_utils.go index 09390312d25..8e75b64f2e1 100644 --- a/google/acctest/test_utils.go +++ b/google/acctest/test_utils.go @@ -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/google/acctest/vcr_utils.go b/google/acctest/vcr_utils.go index 8624e6be90f..dfd7f00d414 100644 --- a/google/acctest/vcr_utils.go +++ b/google/acctest/vcr_utils.go @@ -16,6 +16,7 @@ import ( "path/filepath" "reflect" "regexp" + "slices" "strconv" "strings" "sync" @@ -149,6 +150,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/google/fwmodels/provider_model.go b/google/fwmodels/provider_model.go index 79a4905c161..96eeec4cb49 100644 --- a/google/fwmodels/provider_model.go +++ b/google/fwmodels/provider_model.go @@ -76,7 +76,6 @@ type ProviderModel struct { DataplexCustomEndpoint types.String `tfsdk:"dataplex_custom_endpoint"` DataprocCustomEndpoint types.String `tfsdk:"dataproc_custom_endpoint"` DataprocMetastoreCustomEndpoint types.String `tfsdk:"dataproc_metastore_custom_endpoint"` - DatastoreCustomEndpoint types.String `tfsdk:"datastore_custom_endpoint"` DatastreamCustomEndpoint types.String `tfsdk:"datastream_custom_endpoint"` DeploymentManagerCustomEndpoint types.String `tfsdk:"deployment_manager_custom_endpoint"` DialogflowCustomEndpoint types.String `tfsdk:"dialogflow_custom_endpoint"` diff --git a/google/fwprovider/framework_provider.go b/google/fwprovider/framework_provider.go index 9dccf7ad5d0..aa0168fd66d 100644 --- a/google/fwprovider/framework_provider.go +++ b/google/fwprovider/framework_provider.go @@ -432,12 +432,6 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, - "datastore_custom_endpoint": &schema.StringAttribute{ - Optional: true, - Validators: []validator.String{ - transport_tpg.CustomEndpointValidator(), - }, - }, "datastream_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ diff --git a/google/fwtransport/framework_config.go b/google/fwtransport/framework_config.go index 5b777d386a8..d0d4ea0a77f 100644 --- a/google/fwtransport/framework_config.go +++ b/google/fwtransport/framework_config.go @@ -100,7 +100,6 @@ type FrameworkProviderConfig struct { DataplexBasePath string DataprocBasePath string DataprocMetastoreBasePath string - DatastoreBasePath string DatastreamBasePath string DeploymentManagerBasePath string DialogflowBasePath string @@ -260,7 +259,6 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, p.DataplexBasePath = data.DataplexCustomEndpoint.ValueString() p.DataprocBasePath = data.DataprocCustomEndpoint.ValueString() p.DataprocMetastoreBasePath = data.DataprocMetastoreCustomEndpoint.ValueString() - p.DatastoreBasePath = data.DatastoreCustomEndpoint.ValueString() p.DatastreamBasePath = data.DatastreamCustomEndpoint.ValueString() p.DeploymentManagerBasePath = data.DeploymentManagerCustomEndpoint.ValueString() p.DialogflowBasePath = data.DialogflowCustomEndpoint.ValueString() @@ -844,14 +842,6 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo data.DataprocMetastoreCustomEndpoint = types.StringValue(customEndpoint.(string)) } } - if data.DatastoreCustomEndpoint.IsNull() { - customEndpoint := transport_tpg.MultiEnvDefault([]string{ - "GOOGLE_DATASTORE_CUSTOM_ENDPOINT", - }, transport_tpg.DefaultBasePaths[transport_tpg.DatastoreBasePathKey]) - if customEndpoint != nil { - data.DatastoreCustomEndpoint = types.StringValue(customEndpoint.(string)) - } - } if data.DatastreamCustomEndpoint.IsNull() { customEndpoint := transport_tpg.MultiEnvDefault([]string{ "GOOGLE_DATASTREAM_CUSTOM_ENDPOINT", diff --git a/google/provider/provider.go b/google/provider/provider.go index e9934f589b7..a48e17d9f92 100644 --- a/google/provider/provider.go +++ b/google/provider/provider.go @@ -136,6 +136,7 @@ func Provider() *schema.Provider { "add_terraform_attribution_label": { Type: schema.TypeBool, Optional: true, + Default: true, }, "terraform_attribution_label_addition_strategy": { @@ -384,11 +385,6 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: transport_tpg.ValidateCustomEndpoint, }, - "datastore_custom_endpoint": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: transport_tpg.ValidateCustomEndpoint, - }, "datastream_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -920,7 +916,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 @@ -989,7 +984,6 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.DataplexBasePath = d.Get("dataplex_custom_endpoint").(string) config.DataprocBasePath = d.Get("dataproc_custom_endpoint").(string) config.DataprocMetastoreBasePath = d.Get("dataproc_metastore_custom_endpoint").(string) - config.DatastoreBasePath = d.Get("datastore_custom_endpoint").(string) config.DatastreamBasePath = d.Get("datastream_custom_endpoint").(string) config.DeploymentManagerBasePath = d.Get("deployment_manager_custom_endpoint").(string) config.DialogflowBasePath = d.Get("dialogflow_custom_endpoint").(string) diff --git a/google/provider/provider_mmv1_resources.go b/google/provider/provider_mmv1_resources.go index 4212b48dcf7..3405acfa819 100644 --- a/google/provider/provider_mmv1_resources.go +++ b/google/provider/provider_mmv1_resources.go @@ -52,7 +52,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/services/dataplex" "github.com/hashicorp/terraform-provider-google/google/services/dataproc" "github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore" - "github.com/hashicorp/terraform-provider-google/google/services/datastore" "github.com/hashicorp/terraform-provider-google/google/services/datastream" "github.com/hashicorp/terraform-provider-google/google/services/deploymentmanager" "github.com/hashicorp/terraform-provider-google/google/services/dialogflow" @@ -428,9 +427,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ } // Resources -// Generated resources: 451 +// Generated resources: 449 // Generated IAM resources: 258 -// Total generated resources: 709 +// Total generated resources: 707 var generatedResources = map[string]*schema.Resource{ "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), @@ -766,7 +765,6 @@ var generatedResources = map[string]*schema.Resource{ "google_dataproc_metastore_service_iam_binding": tpgiamresource.ResourceIamBinding(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), "google_dataproc_metastore_service_iam_member": tpgiamresource.ResourceIamMember(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), "google_dataproc_metastore_service_iam_policy": tpgiamresource.ResourceIamPolicy(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), - "google_datastore_index": datastore.ResourceDatastoreIndex(), "google_datastream_connection_profile": datastream.ResourceDatastreamConnectionProfile(), "google_datastream_private_connection": datastream.ResourceDatastreamPrivateConnection(), "google_datastream_stream": datastream.ResourceDatastreamStream(), @@ -901,7 +899,6 @@ var generatedResources = map[string]*schema.Resource{ "google_identity_platform_default_supported_idp_config": identityplatform.ResourceIdentityPlatformDefaultSupportedIdpConfig(), "google_identity_platform_inbound_saml_config": identityplatform.ResourceIdentityPlatformInboundSamlConfig(), "google_identity_platform_oauth_idp_config": identityplatform.ResourceIdentityPlatformOauthIdpConfig(), - "google_identity_platform_project_default_config": identityplatform.ResourceIdentityPlatformProjectDefaultConfig(), "google_identity_platform_tenant": identityplatform.ResourceIdentityPlatformTenant(), "google_identity_platform_tenant_default_supported_idp_config": identityplatform.ResourceIdentityPlatformTenantDefaultSupportedIdpConfig(), "google_identity_platform_tenant_inbound_saml_config": identityplatform.ResourceIdentityPlatformTenantInboundSamlConfig(), diff --git a/google/services/accessapproval/data_source_access_approval_folder_service_account_test.go b/google/services/accessapproval/data_source_access_approval_folder_service_account_test.go index 8b4f5dcc6b9..f954e651ed7 100644 --- a/google/services/accessapproval/data_source_access_approval_folder_service_account_test.go +++ b/google/services/accessapproval/data_source_access_approval_folder_service_account_test.go @@ -42,6 +42,7 @@ func testAccDataSourceAccessApprovalFolderServiceAccount_basic(context map[strin resource "google_folder" "my_folder" { display_name = "tf-test-my-folder%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } # Wait after folder creation to limit eventual consistency errors. diff --git a/google/services/accessapproval/resource_access_approval_folder_settings_test.go b/google/services/accessapproval/resource_access_approval_folder_settings_test.go index f27a977b787..90c0df0e116 100644 --- a/google/services/accessapproval/resource_access_approval_folder_settings_test.go +++ b/google/services/accessapproval/resource_access_approval_folder_settings_test.go @@ -69,6 +69,7 @@ func testAccAccessApprovalFolderSettings_full(context map[string]interface{}) st resource "google_folder" "my_folder" { display_name = "tf-test-my-folder%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } # Wait after folder creation to limit eventual consistency errors. @@ -96,6 +97,7 @@ func testAccAccessApprovalFolderSettings_update(context map[string]interface{}) resource "google_folder" "my_folder" { display_name = "tf-test-my-folder%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } # Wait after folder creation to limit eventual consistency errors. @@ -123,6 +125,7 @@ func testAccAccessApprovalFolderSettings_activeKeyVersion(context map[string]int resource "google_folder" "my_folder" { display_name = "tf-test-my-folder%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } # Wait after folder creation to limit eventual consistency errors. diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go b/google/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go index 93e01074593..a7d01d28ba3 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go @@ -140,6 +140,7 @@ func createScopedPolicy(t *testing.T, org string) string { project_id = "acm-tf-test-%s" name = "acm-tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_access_context_manager_access_policy" "access-policy" { diff --git a/google/services/activedirectory/resource_active_directory_domain.go b/google/services/activedirectory/resource_active_directory_domain.go index 744621beaa7..ca840bfd211 100644 --- a/google/services/activedirectory/resource_active_directory_domain.go +++ b/google/services/activedirectory/resource_active_directory_domain.go @@ -131,6 +131,17 @@ Similar to what would be chosen for an Active Directory set up on an internal ne and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + "deletion_protection": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: `Whether Terraform will be prevented from destroying the domain. Defaults to true. +When a'terraform destroy' or 'terraform apply' would delete the domain, +the command will fail if this field is not set to false in Terraform state. +When the field is set to true or unset in Terraform state, a 'terraform apply' +or 'terraform destroy' that would delete the domain will fail. +When the field is set to false, deleting the domain is allowed.`, + }, "project": { Type: schema.TypeString, Optional: true, @@ -291,6 +302,12 @@ func resourceActiveDirectoryDomainRead(d *schema.ResourceData, meta interface{}) return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ActiveDirectoryDomain %q", d.Id())) } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_protection"); !ok { + if err := d.Set("deletion_protection", true); err != nil { + return fmt.Errorf("Error setting deletion_protection: %s", err) + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Domain: %s", err) } @@ -453,6 +470,9 @@ func resourceActiveDirectoryDomainDelete(d *schema.ResourceData, meta interface{ } headers := make(http.Header) + if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy domain without setting deletion_protection=false and running `terraform apply`") + } log.Printf("[DEBUG] Deleting Domain %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ diff --git a/google/services/activedirectory/resource_active_directory_domain_sweeper.go b/google/services/activedirectory/resource_active_directory_domain_sweeper.go deleted file mode 100644 index 8189a43e189..00000000000 --- a/google/services/activedirectory/resource_active_directory_domain_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package activedirectory - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("ActiveDirectoryDomain", testSweepActiveDirectoryDomain) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepActiveDirectoryDomain(region string) error { - resourceName := "ActiveDirectoryDomain" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://managedidentities.googleapis.com/v1/projects/{{project}}/locations/global/domains", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["domains"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://managedidentities.googleapis.com/v1/projects/{{project}}/locations/global/domains/{{domain_name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/google/services/activedirectory/resource_active_directory_domain_trust_test.go b/google/services/activedirectory/resource_active_directory_domain_trust_test.go index 23b5fe1588b..6bc29f5bfd2 100644 --- a/google/services/activedirectory/resource_active_directory_domain_trust_test.go +++ b/google/services/activedirectory/resource_active_directory_domain_trust_test.go @@ -40,7 +40,7 @@ func TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample(t ResourceName: "google_active_directory_domain_trust.ad-domain-trust", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"trust_handshake_secret", "domain"}, + ImportStateVerifyIgnore: []string{"trust_handshake_secret", "domain", "deletion_protection"}, }, { Config: testAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustUpdate(context), @@ -49,7 +49,7 @@ func TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample(t ResourceName: "google_active_directory_domain_trust.ad-domain-trust", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"trust_handshake_secret", "domain"}, + ImportStateVerifyIgnore: []string{"trust_handshake_secret", "domain", "deletion_protection"}, }, }, }) @@ -58,12 +58,13 @@ func TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample(t func testAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_active_directory_domain_trust" "ad-domain-trust" { - domain = "ci-managed-ad.com" +domain = "ci-managed-ad.com" target_domain_name = "example-gcp.com" target_dns_ip_addresses = ["10.1.0.100"] trust_direction = "OUTBOUND" trust_type = "FOREST" trust_handshake_secret = "Testing1!" + deletion_protection = false } `, context) } @@ -77,6 +78,7 @@ resource "google_active_directory_domain_trust" "ad-domain-trust" { trust_direction = "OUTBOUND" trust_type = "FOREST" trust_handshake_secret = "Testing1!" + deletion_protection = false } `, context) } diff --git a/google/services/activedirectory/resource_active_directory_domain_update_test.go b/google/services/activedirectory/resource_active_directory_domain_update_test.go index ec636d3d1e9..326f6683385 100644 --- a/google/services/activedirectory/resource_active_directory_domain_update_test.go +++ b/google/services/activedirectory/resource_active_directory_domain_update_test.go @@ -41,7 +41,7 @@ func TestAccActiveDirectoryDomain_update(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels", "deletion_protection"}, }, { Config: testAccADDomainUpdate(context), @@ -50,7 +50,7 @@ func TestAccActiveDirectoryDomain_update(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels", "deletion_protection"}, }, { Config: testAccADDomainBasic(context), @@ -59,7 +59,7 @@ func TestAccActiveDirectoryDomain_update(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"domain_name", "labels", "terraform_labels", "deletion_protection"}, }, }, }) @@ -72,6 +72,7 @@ func testAccADDomainBasic(context map[string]interface{}) string { domain_name = "%{domain}" locations = ["us-central1"] reserved_ip_range = "192.168.255.0/24" + deletion_protection = false } `, context) } @@ -82,6 +83,7 @@ func testAccADDomainUpdate(context map[string]interface{}) string { domain_name = "%{domain}" locations = ["us-central1", "us-west1"] reserved_ip_range = "192.168.255.0/24" + deletion_protection = false labels = { env = "test" } diff --git a/google/services/alloydb/resource_alloydb_backup_generated_test.go b/google/services/alloydb/resource_alloydb_backup_generated_test.go index db4bc9e02f2..af490a2ed01 100644 --- a/google/services/alloydb/resource_alloydb_backup_generated_test.go +++ b/google/services/alloydb/resource_alloydb_backup_generated_test.go @@ -69,7 +69,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "default" { @@ -129,7 +131,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "default" { diff --git a/google/services/alloydb/resource_alloydb_backup_test.go b/google/services/alloydb/resource_alloydb_backup_test.go index 01c82520002..8900d393241 100644 --- a/google/services/alloydb/resource_alloydb_backup_test.go +++ b/google/services/alloydb/resource_alloydb_backup_test.go @@ -62,7 +62,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "default" { @@ -96,7 +98,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "default" { @@ -144,7 +148,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "default" { location = "us-central1" cluster_id = "tf-test-alloydb-cluster%{random_suffix}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" { } @@ -211,7 +217,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "default" { diff --git a/google/services/alloydb/resource_alloydb_cluster.go b/google/services/alloydb/resource_alloydb_cluster.go index a8218fdb348..2260e90499a 100644 --- a/google/services/alloydb/resource_alloydb_cluster.go +++ b/google/services/alloydb/resource_alloydb_cluster.go @@ -383,17 +383,6 @@ Please refer to the field 'effective_labels' for all of the labels present on th }, }, }, - "network": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Deprecated: "`network` is deprecated and will be removed in a future major release. Instead, use `network_config` to define the network configuration.", - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form: - -"projects/{projectNumber}/global/networks/{network_id}".`, - ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"}, - }, "network_config": { Type: schema.TypeList, Computed: true, @@ -414,7 +403,7 @@ If set, the instance IPs for this cluster will be created in the allocated range DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, Description: `The resource link for the VPC network in which cluster resources are created and from which they are accessible via Private IP. The network must belong to the same project as the cluster. It is specified in the form: "projects/{projectNumber}/global/networks/{network_id}".`, - ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"}, + ExactlyOneOf: []string{"network_config.0.network", "psc_config.0.psc_enabled"}, }, }, }, @@ -675,12 +664,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro } else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(encryptionConfigProp)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) { obj["encryptionConfig"] = encryptionConfigProp } - networkProp, err := expandAlloydbClusterNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } networkConfigProp, err := expandAlloydbClusterNetworkConfig(d.Get("network_config"), d, config) if err != nil { return err @@ -958,9 +941,6 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("continuous_backup_info", flattenAlloydbClusterContinuousBackupInfo(res["continuousBackupInfo"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } - if err := d.Set("network", flattenAlloydbClusterNetwork(res["network"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } if err := d.Set("network_config", flattenAlloydbClusterNetworkConfig(res["networkConfig"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -1041,12 +1021,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro } else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) { obj["encryptionConfig"] = encryptionConfigProp } - networkProp, err := expandAlloydbClusterNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } networkConfigProp, err := expandAlloydbClusterNetworkConfig(d.Get("network_config"), d, config) if err != nil { return err @@ -1139,10 +1113,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro updateMask = append(updateMask, "encryptionConfig") } - if d.HasChange("network") { - updateMask = append(updateMask, "network") - } - if d.HasChange("network_config") { updateMask = append(updateMask, "networkConfig") } @@ -1507,10 +1477,6 @@ func flattenAlloydbClusterContinuousBackupInfoEncryptionInfoKmsKeyVersions(v int return v } -func flattenAlloydbClusterNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenAlloydbClusterNetworkConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -2093,10 +2059,6 @@ func expandAlloydbClusterEncryptionConfigKmsKeyName(v interface{}, d tpgresource return v, nil } -func expandAlloydbClusterNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandAlloydbClusterNetworkConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/google/services/alloydb/resource_alloydb_cluster_generated_test.go b/google/services/alloydb/resource_alloydb_cluster_generated_test.go index 70c91dee2d6..e942fb80975 100644 --- a/google/services/alloydb/resource_alloydb_cluster_generated_test.go +++ b/google/services/alloydb/resource_alloydb_cluster_generated_test.go @@ -187,7 +187,9 @@ func testAccAlloydbCluster_alloydbSecondaryClusterBasicTestExample(context map[s resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -203,7 +205,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { diff --git a/google/services/alloydb/resource_alloydb_cluster_restore_test.go b/google/services/alloydb/resource_alloydb_cluster_restore_test.go index a0d6c3b565f..f834b875856 100644 --- a/google/services/alloydb/resource_alloydb_cluster_restore_test.go +++ b/google/services/alloydb/resource_alloydb_cluster_restore_test.go @@ -88,7 +88,9 @@ func testAccAlloydbClusterAndInstanceAndBackup(context map[string]interface{}) s resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -119,7 +121,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_OnlyOneSourceAllowed(context map[ resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -139,7 +143,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "restored" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_backup_source { backup_name = google_alloydb_backup.default.name } @@ -167,7 +173,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_SourceClusterAndPointInTimeRequir resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -187,7 +195,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "restored" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_continuous_backup_source { cluster = google_alloydb_cluster.source.name @@ -211,7 +221,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackup(context map[st resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -231,7 +243,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "restored_from_backup" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_backup_source { backup_name = google_alloydb_backup.default.name } @@ -256,7 +270,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -276,7 +292,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "restored_from_backup" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_backup_source { backup_name = google_alloydb_backup.default.name } @@ -289,7 +307,9 @@ resource "google_alloydb_cluster" "restored_from_backup" { resource "google_alloydb_cluster" "restored_from_point_in_time" { cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_continuous_backup_source { cluster = google_alloydb_cluster.source.name point_in_time = google_alloydb_backup.default.update_time @@ -315,7 +335,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -335,7 +357,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "restored_from_backup" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_backup_source { backup_name = google_alloydb_backup.default.name } @@ -353,7 +377,9 @@ resource "google_alloydb_cluster" "restored_from_backup" { resource "google_alloydb_cluster" "restored_from_point_in_time" { cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_continuous_backup_source { cluster = google_alloydb_cluster.source.name point_in_time = google_alloydb_backup.default.update_time @@ -384,7 +410,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -412,7 +440,9 @@ resource "google_alloydb_backup" "default2" { resource "google_alloydb_cluster" "restored_from_backup" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_backup_source { backup_name = google_alloydb_backup.default2.name } @@ -432,7 +462,9 @@ resource "google_alloydb_cluster" "restored_from_backup" { resource "google_alloydb_cluster" "restored_from_point_in_time" { cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_continuous_backup_source { cluster = google_alloydb_cluster.restored_from_backup.name point_in_time = google_alloydb_backup.default.update_time @@ -463,7 +495,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom resource "google_alloydb_cluster" "source" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "source" { @@ -483,7 +517,9 @@ resource "google_alloydb_backup" "default" { resource "google_alloydb_cluster" "restored_from_backup" { cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_backup_source { backup_name = google_alloydb_backup.default.name } @@ -492,7 +528,9 @@ resource "google_alloydb_cluster" "restored_from_backup" { resource "google_alloydb_cluster" "restored_from_point_in_time" { cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } restore_continuous_backup_source { cluster = google_alloydb_cluster.source.name point_in_time = google_alloydb_backup.default.update_time diff --git a/google/services/alloydb/resource_alloydb_cluster_test.go b/google/services/alloydb/resource_alloydb_cluster_test.go index 24ace23c093..2e27a4530b0 100644 --- a/google/services/alloydb/resource_alloydb_cluster_test.go +++ b/google/services/alloydb/resource_alloydb_cluster_test.go @@ -52,7 +52,9 @@ func testAccAlloydbCluster_update(context map[string]interface{}) string { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } labels = { foo = "bar" @@ -190,7 +192,9 @@ func testAccAlloydbCluster_withInitialUserAndAutomatedBackupPolicy(context map[s resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } initial_user { user = "tf-test-alloydb-cluster%{random_suffix}" @@ -240,7 +244,9 @@ func testAccAlloydbCluster_withoutInitialUserAndAutomatedBackupPolicy(context ma resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } lifecycle { prevent_destroy = true } @@ -285,7 +291,9 @@ func testAccAlloydbCluster_missingWeeklySchedule(context map[string]interface{}) resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } automated_backup_policy { location = "us-central1" backup_window = "1800s" @@ -386,7 +394,9 @@ func testAccAlloydbCluster_withTimeBasedRetentionPolicy(context map[string]inter resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } automated_backup_policy { location = "us-central1" backup_window = "1800s" @@ -427,7 +437,9 @@ func testAccAlloydbCluster_withoutTimeBasedRetentionPolicy(context map[string]in resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } automated_backup_policy { location = "us-central1" backup_window = "1800s" @@ -490,7 +502,9 @@ func testAccAlloydbCluster_usingCMEK(context map[string]interface{}) string { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } encryption_config { kms_key_name = google_kms_crypto_key.key.id } @@ -565,7 +579,9 @@ func testAccAlloydbCluster_usingCMEKInClusterAndAutomatedBackup(context map[stri resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } encryption_config { kms_key_name = google_kms_crypto_key.key.id } @@ -615,7 +631,9 @@ func testAccAlloydbCluster_updateCMEKInAutomatedBackup(context map[string]interf resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } encryption_config { kms_key_name = google_kms_crypto_key.key.id } @@ -676,7 +694,9 @@ func testAccAlloydbCluster_usingCMEKallowDeletion(context map[string]interface{} resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } encryption_config { kms_key_name = google_kms_crypto_key.key.id } @@ -923,7 +943,9 @@ func testAccAlloydbCluster_withoutContinuousBackupConfig(context map[string]inte resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } lifecycle { prevent_destroy = true } @@ -943,7 +965,9 @@ func testAccAlloydbCluster_continuousBackupConfig(context map[string]interface{} resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } continuous_backup_config { enabled = %{enabled} @@ -1022,7 +1046,9 @@ func testAccAlloydbCluster_usingCMEKInClusterAndContinuousBackup(context map[str resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } continuous_backup_config { enabled = true recovery_window_days = 20 @@ -1055,7 +1081,9 @@ func testAccAlloydbCluster_continuousBackupUsingCMEKAllowDeletion(context map[st resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } continuous_backup_config { enabled = true recovery_window_days = 20 @@ -1111,7 +1139,7 @@ resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" } } data "google_project" "project" {} @@ -1152,8 +1180,8 @@ resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" - allocated_ip_range = google_compute_global_address.private_ip_alloc.name + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + allocated_ip_range = google_compute_global_address.private_ip_alloc.name } } data "google_project" "project" {} @@ -1202,7 +1230,7 @@ resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" } maintenance_update_policy { maintenance_windows { @@ -1254,7 +1282,9 @@ func testAccAlloydbCluster_withMaintenanceWindowMissingStartTime(context map[str resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } maintenance_update_policy { maintenance_windows { @@ -1276,7 +1306,9 @@ func testAccAlloydbCluster_withMaintenanceWindowMissingDay(context map[string]in resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + network_config { + network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + } maintenance_update_policy { maintenance_windows { diff --git a/google/services/alloydb/resource_alloydb_instance_generated_test.go b/google/services/alloydb/resource_alloydb_instance_generated_test.go index fac4df46a6c..01dfe7c0e7c 100644 --- a/google/services/alloydb/resource_alloydb_instance_generated_test.go +++ b/google/services/alloydb/resource_alloydb_instance_generated_test.go @@ -71,8 +71,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id - + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf-test-alloydb-cluster%{random_suffix}" } @@ -117,7 +118,9 @@ func testAccAlloydbInstance_alloydbSecondaryInstanceBasicTestExample(context map resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -133,7 +136,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { diff --git a/google/services/alloydb/resource_alloydb_instance_test.go b/google/services/alloydb/resource_alloydb_instance_test.go index 0f7ba2952d4..6bbac4886ad 100644 --- a/google/services/alloydb/resource_alloydb_instance_test.go +++ b/google/services/alloydb/resource_alloydb_instance_test.go @@ -60,8 +60,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id - + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf-test-alloydb-cluster%{random_suffix}" } @@ -92,7 +93,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf-test-alloydb-cluster%{random_suffix}" @@ -137,7 +140,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -207,7 +212,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -260,7 +267,9 @@ resource "google_alloydb_instance" "read_pool" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -314,7 +323,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -339,7 +350,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -527,7 +540,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -556,7 +571,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } data "google_project" "project" {} @@ -670,7 +687,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf-test-alloydb-cluster%{random_suffix}" } @@ -705,7 +724,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf-test-alloydb-cluster%{random_suffix}" } diff --git a/google/services/alloydb/resource_alloydb_secondary_cluster_test.go b/google/services/alloydb/resource_alloydb_secondary_cluster_test.go index 4c7e5ebd144..dca9db3bf09 100644 --- a/google/services/alloydb/resource_alloydb_secondary_cluster_test.go +++ b/google/services/alloydb/resource_alloydb_secondary_cluster_test.go @@ -43,7 +43,9 @@ func testAccAlloydbCluster_secondaryClusterMandatoryFields(context map[string]in resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -59,7 +61,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -108,7 +112,9 @@ func testAccAlloydbCluster_secondaryClusterMissingSecondaryConfig(context map[st resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -124,7 +130,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -172,7 +180,9 @@ func testAccAlloydbCluster_secondaryClusterDefinedSecondaryConfigButMissingClust resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -188,7 +198,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } continuous_backup_config { enabled = false @@ -236,7 +248,9 @@ func testAccAlloydbCluster_secondaryClusterDefinedSecondaryConfigButClusterTypeI resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -252,7 +266,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -315,7 +331,9 @@ func testAccAlloydbCluster_secondaryClusterUpdate(context map[string]interface{} resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -331,7 +349,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -389,7 +409,9 @@ func testAccAlloydbCluster_secondaryClusterUsingCMEK(context map[string]interfac resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -405,7 +427,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -483,7 +507,7 @@ resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" + network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" } } @@ -501,7 +525,7 @@ resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" + network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" } cluster_type = "SECONDARY" @@ -558,8 +582,8 @@ resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" - allocated_ip_range = data.google_compute_global_address.private_ip_alloc.name + network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" + allocated_ip_range = data.google_compute_global_address.private_ip_alloc.name } } @@ -577,8 +601,8 @@ resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" network_config { - network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" - allocated_ip_range = data.google_compute_global_address.private_ip_alloc.name + network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.default.name}" + allocated_ip_range = data.google_compute_global_address.private_ip_alloc.name } cluster_type = "SECONDARY" @@ -647,7 +671,9 @@ func testAccAlloydbInstance_secondaryClusterWithInstance(context map[string]inte resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -663,7 +689,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -706,7 +734,9 @@ func testAccAlloydbCluster_secondaryClusterPromote(context map[string]interface{ resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -722,7 +752,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -794,7 +826,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteAndSimultaneousUpdate(context resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -810,7 +844,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -895,7 +931,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteAndDeleteOriginalPrimary(conte resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -976,7 +1014,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteAndUpdate(context map[string]i resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -992,7 +1032,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -1255,7 +1297,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteAndAddAutomatedBackupPolicyAnd resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -1271,7 +1315,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -1391,7 +1437,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteWithTimeBasedRetentionPolicy(c resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -1407,7 +1455,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -1472,7 +1522,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteWithoutTimeBasedRetentionPolic resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -1488,7 +1540,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { @@ -1596,7 +1650,9 @@ func testAccAlloydbCluster_secondaryClusterPromoteAndAddContinuousBackupConfig(c resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -1612,7 +1668,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "%{secondary_cluster_location}" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "PRIMARY" continuous_backup_config { diff --git a/google/services/alloydb/resource_alloydb_secondary_instance_test.go b/google/services/alloydb/resource_alloydb_secondary_instance_test.go index b8e24b36144..7585a213a66 100644 --- a/google/services/alloydb/resource_alloydb_secondary_instance_test.go +++ b/google/services/alloydb/resource_alloydb_secondary_instance_test.go @@ -50,7 +50,9 @@ func testAccAlloydbInstance_secondaryInstanceInitial(context map[string]interfac resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -66,7 +68,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -105,7 +109,9 @@ func testAccAlloydbInstance_secondaryInstanceUpdateMachineConfig(context map[str resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -121,7 +127,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -187,7 +195,9 @@ func testAccAlloydbInstance_secondaryInstanceWithReadPoolInstance(context map[st resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -203,7 +213,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-west1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -381,7 +393,9 @@ func testAccAlloydbInstance_secondaryInstanceUpdateDatabaseFlag(context map[stri resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -397,7 +411,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -476,7 +492,9 @@ func testAccAlloydbInstance_secondaryInstanceUpdateQueryInsightConfig(context ma resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -492,7 +510,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-east1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -565,7 +585,9 @@ func testAccAlloydbInstance_secondaryInstanceMaximumFields(context map[string]in resource "google_alloydb_cluster" "primary" { cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -581,7 +603,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}" location = "us-west1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { diff --git a/google/services/alloydb/resource_alloydb_user_generated_test.go b/google/services/alloydb/resource_alloydb_user_generated_test.go index c88b37546c8..8e79b465e8a 100644 --- a/google/services/alloydb/resource_alloydb_user_generated_test.go +++ b/google/services/alloydb/resource_alloydb_user_generated_test.go @@ -67,8 +67,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id - + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf_test_cluster_secret%{random_suffix}" } @@ -130,8 +131,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id - + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf_test_cluster_secret%{random_suffix}" } diff --git a/google/services/alloydb/resource_alloydb_user_test.go b/google/services/alloydb/resource_alloydb_user_test.go index ba3b59fe043..88f93b121fa 100644 --- a/google/services/alloydb/resource_alloydb_user_test.go +++ b/google/services/alloydb/resource_alloydb_user_test.go @@ -55,7 +55,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf_test_cluster_secret%{random_suffix}" @@ -125,7 +127,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf_test_cluster_secret%{random_suffix}" @@ -194,7 +198,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "tf-test-alloydb-cluster%{random_suffix}" location = "us-central1" - network = data.google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "tf_test_cluster_secret%{random_suffix}" } diff --git a/google/services/apigee/iam_apigee_environment_generated_test.go b/google/services/apigee/iam_apigee_environment_generated_test.go index 2a0229200fc..443e93ea18e 100644 --- a/google/services/apigee/iam_apigee_environment_generated_test.go +++ b/google/services/apigee/iam_apigee_environment_generated_test.go @@ -136,6 +136,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -210,6 +211,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -298,6 +300,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -374,6 +377,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -448,6 +452,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_addons_config_generated_test.go b/google/services/apigee/resource_apigee_addons_config_generated_test.go index 373653f0c69..a9d9ad69583 100644 --- a/google/services/apigee/resource_apigee_addons_config_generated_test.go +++ b/google/services/apigee/resource_apigee_addons_config_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_endpoint_attachment_generated_test.go b/google/services/apigee/resource_apigee_endpoint_attachment_generated_test.go index 9d8ad9b3ae9..12f44a5ce27 100644 --- a/google/services/apigee/resource_apigee_endpoint_attachment_generated_test.go +++ b/google/services/apigee/resource_apigee_endpoint_attachment_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go b/google/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go index bbcece70afb..22fd021dbcd 100644 --- a/google/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go +++ b/google/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go @@ -52,6 +52,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_env_keystore_generated_test.go b/google/services/apigee/resource_apigee_env_keystore_generated_test.go index 0333f565ca7..b62b04b2ddb 100644 --- a/google/services/apigee/resource_apigee_env_keystore_generated_test.go +++ b/google/services/apigee/resource_apigee_env_keystore_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_env_references_generated_test.go b/google/services/apigee/resource_apigee_env_references_generated_test.go index cde9ae7b372..500dfd5cd1b 100644 --- a/google/services/apigee/resource_apigee_env_references_generated_test.go +++ b/google/services/apigee/resource_apigee_env_references_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_envgroup_attachment_generated_test.go b/google/services/apigee/resource_apigee_envgroup_attachment_generated_test.go index 2d4d3dbd57c..cdd9b42df79 100644 --- a/google/services/apigee/resource_apigee_envgroup_attachment_generated_test.go +++ b/google/services/apigee/resource_apigee_envgroup_attachment_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_envgroup_generated_test.go b/google/services/apigee/resource_apigee_envgroup_generated_test.go index bde55bcef96..7252db24ccd 100644 --- a/google/services/apigee/resource_apigee_envgroup_generated_test.go +++ b/google/services/apigee/resource_apigee_envgroup_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_environment_generated_test.go b/google/services/apigee/resource_apigee_environment_generated_test.go index 331e6971df2..5ac8dedf693 100644 --- a/google/services/apigee/resource_apigee_environment_generated_test.go +++ b/google/services/apigee/resource_apigee_environment_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -161,6 +162,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go b/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go index c3d73e31024..14724cf0044 100644 --- a/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go +++ b/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go b/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go index cd5fbdae2ed..886851ba2eb 100644 --- a/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go +++ b/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_flowhook_test.go b/google/services/apigee/resource_apigee_flowhook_test.go index 1842a6d37f4..b764d72c487 100644 --- a/google/services/apigee/resource_apigee_flowhook_test.go +++ b/google/services/apigee/resource_apigee_flowhook_test.go @@ -51,6 +51,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_instance_attachment_generated_test.go b/google/services/apigee/resource_apigee_instance_attachment_generated_test.go index 00f07d8913d..775f0232f18 100644 --- a/google/services/apigee/resource_apigee_instance_attachment_generated_test.go +++ b/google/services/apigee/resource_apigee_instance_attachment_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_instance_generated_test.go b/google/services/apigee/resource_apigee_instance_generated_test.go index f1dc75696cf..774caa46212 100644 --- a/google/services/apigee/resource_apigee_instance_generated_test.go +++ b/google/services/apigee/resource_apigee_instance_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -158,6 +159,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -251,6 +253,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -344,6 +347,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go b/google/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go index d3fef8908e1..54338ef5ba9 100644 --- a/google/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go +++ b/google/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go @@ -61,6 +61,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -182,6 +183,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go b/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go index 817746f7a93..fc78a44d650 100644 --- a/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go +++ b/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_nat_address_generated_test.go b/google/services/apigee/resource_apigee_nat_address_generated_test.go index 137ba206815..e62083f2066 100644 --- a/google/services/apigee/resource_apigee_nat_address_generated_test.go +++ b/google/services/apigee/resource_apigee_nat_address_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_organization_generated_test.go b/google/services/apigee/resource_apigee_organization_generated_test.go index 658f39948b9..8a3dc7dfcb4 100644 --- a/google/services/apigee/resource_apigee_organization_generated_test.go +++ b/google/services/apigee/resource_apigee_organization_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -152,6 +153,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_sharedflow_deployment_test.go b/google/services/apigee/resource_apigee_sharedflow_deployment_test.go index 254d71aebab..7a30549c06d 100644 --- a/google/services/apigee/resource_apigee_sharedflow_deployment_test.go +++ b/google/services/apigee/resource_apigee_sharedflow_deployment_test.go @@ -62,6 +62,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_sharedflow_test.go b/google/services/apigee/resource_apigee_sharedflow_test.go index a0ea563d6d6..62e57e47885 100644 --- a/google/services/apigee/resource_apigee_sharedflow_test.go +++ b/google/services/apigee/resource_apigee_sharedflow_test.go @@ -62,6 +62,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -168,6 +169,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_sync_authorization_generated_test.go b/google/services/apigee/resource_apigee_sync_authorization_generated_test.go index b2357d00301..0d3a6a730aa 100644 --- a/google/services/apigee/resource_apigee_sync_authorization_generated_test.go +++ b/google/services/apigee/resource_apigee_sync_authorization_generated_test.go @@ -59,6 +59,7 @@ resource "google_project" "project" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_sync_authorization_test.go b/google/services/apigee/resource_apigee_sync_authorization_test.go index a10a142d9c1..e0c4522f795 100644 --- a/google/services/apigee/resource_apigee_sync_authorization_test.go +++ b/google/services/apigee/resource_apigee_sync_authorization_test.go @@ -61,6 +61,7 @@ resource "google_project" "project" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -104,6 +105,7 @@ resource "google_project" "project" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -163,6 +165,7 @@ resource "google_project" "project" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_target_server_generated_test.go b/google/services/apigee/resource_apigee_target_server_generated_test.go index eb4f08dbf60..d38c809fce8 100644 --- a/google/services/apigee/resource_apigee_target_server_generated_test.go +++ b/google/services/apigee/resource_apigee_target_server_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apigee/resource_apigee_target_server_test.go b/google/services/apigee/resource_apigee_target_server_test.go index fbe41db3dc3..15ffd539952 100644 --- a/google/services/apigee/resource_apigee_target_server_test.go +++ b/google/services/apigee/resource_apigee_target_server_test.go @@ -54,6 +54,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -130,6 +131,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -242,6 +244,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { @@ -351,6 +354,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/google/services/apikeys/resource_apikeys_key_generated_test.go b/google/services/apikeys/resource_apikeys_key_generated_test.go index d8398944272..9f83b0fce27 100644 --- a/google/services/apikeys/resource_apikeys_key_generated_test.go +++ b/google/services/apikeys/resource_apikeys_key_generated_test.go @@ -196,7 +196,6 @@ func testAccApikeysKey_AndroidKey(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { android_key_restrictions { @@ -213,12 +212,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -228,7 +221,6 @@ func testAccApikeysKey_AndroidKeyUpdate0(context map[string]interface{}) string resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { android_key_restrictions { @@ -245,12 +237,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -260,7 +246,6 @@ func testAccApikeysKey_BasicKey(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -274,12 +259,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -289,7 +268,6 @@ func testAccApikeysKey_BasicKeyUpdate0(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key-update" - project = google_project.basic.name restrictions { api_targets { @@ -303,12 +281,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -318,7 +290,6 @@ func testAccApikeysKey_IosKey(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -332,12 +303,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -347,7 +312,6 @@ func testAccApikeysKey_IosKeyUpdate0(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -361,12 +325,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -376,13 +334,6 @@ func testAccApikeysKey_MinimalKey(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name -} - -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" } @@ -394,7 +345,6 @@ func testAccApikeysKey_ServerKey(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -408,12 +358,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } @@ -423,7 +367,6 @@ func testAccApikeysKey_ServerKeyUpdate0(context map[string]interface{}) string { resource "google_apikeys_key" "primary" { name = "tf-test-key%{random_suffix}" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -437,12 +380,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "tf-test-app%{random_suffix}" - name = "tf-test-app%{random_suffix}" - org_id = "%{org_id}" -} - `, context) } diff --git a/google/services/appengine/resource_app_engine_application_test.go b/google/services/appengine/resource_app_engine_application_test.go index 12847eae3e3..3aff97e359d 100644 --- a/google/services/appengine/resource_app_engine_application_test.go +++ b/google/services/appengine/resource_app_engine_application_test.go @@ -80,6 +80,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_app_engine_application" "acceptance" { @@ -104,6 +105,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_app_engine_application" "acceptance" { @@ -123,6 +125,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_app_engine_application" "acceptance" { diff --git a/google/services/appengine/resource_app_engine_firewall_rule_generated_test.go b/google/services/appengine/resource_app_engine_firewall_rule_generated_test.go index 09cfdf7097d..e9650d8c291 100644 --- a/google/services/appengine/resource_app_engine_firewall_rule_generated_test.go +++ b/google/services/appengine/resource_app_engine_firewall_rule_generated_test.go @@ -64,6 +64,7 @@ resource "google_project" "my_project" { project_id = "tf-test-ae-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_app_engine_application" "app" { diff --git a/google/services/appengine/resource_app_engine_standard_app_version_test.go b/google/services/appengine/resource_app_engine_standard_app_version_test.go index 559edda302c..23b99bd57a8 100644 --- a/google/services/appengine/resource_app_engine_standard_app_version_test.go +++ b/google/services/appengine/resource_app_engine_standard_app_version_test.go @@ -66,6 +66,7 @@ resource "google_project" "my_project" { project_id = "tf-test-appeng-std%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_app_engine_application" "app" { @@ -153,6 +154,7 @@ resource "google_project" "my_project" { project_id = "tf-test-appeng-std%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_app_engine_application" "app" { @@ -192,6 +194,8 @@ resource "google_vpc_access_connector" "bar" { region = "us-central1" ip_cidr_range = "10.8.0.16/28" network = "default" + min_throughput = 200 + max_throughput = 300 } resource "google_app_engine_standard_app_version" "foo" { @@ -272,6 +276,7 @@ resource "google_project" "my_project" { project_id = "tf-test-appeng-std%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_app_engine_application" "app" { diff --git a/google/services/apphub/data_source_apphub_discovered_service_test.go b/google/services/apphub/data_source_apphub_discovered_service_test.go index a7fe6b32ae0..e82b6c96abd 100644 --- a/google/services/apphub/data_source_apphub_discovered_service_test.go +++ b/google/services/apphub/data_source_apphub_discovered_service_test.go @@ -44,6 +44,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/google/services/apphub/data_source_apphub_discovered_workload_test.go b/google/services/apphub/data_source_apphub_discovered_workload_test.go index 3a051f899ac..e33d5a58c1f 100644 --- a/google/services/apphub/data_source_apphub_discovered_workload_test.go +++ b/google/services/apphub/data_source_apphub_discovered_workload_test.go @@ -43,6 +43,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/google/services/apphub/resource_apphub_service_generated_test.go b/google/services/apphub/resource_apphub_service_generated_test.go index 329de48b15f..1353c654fdd 100644 --- a/google/services/apphub/resource_apphub_service_generated_test.go +++ b/google/services/apphub/resource_apphub_service_generated_test.go @@ -77,6 +77,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API @@ -221,6 +222,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/google/services/apphub/resource_apphub_service_project_attachment_generated_test.go b/google/services/apphub/resource_apphub_service_project_attachment_generated_test.go index 09175483b42..94320e444c5 100644 --- a/google/services/apphub/resource_apphub_service_project_attachment_generated_test.go +++ b/google/services/apphub/resource_apphub_service_project_attachment_generated_test.go @@ -73,6 +73,7 @@ resource "google_project" "service_project" { project_id ="tf-test-project-1%{random_suffix}" name = "Service Project" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_120s" { @@ -126,6 +127,7 @@ resource "google_project" "service_project_full" { project_id ="tf-test-project-1%{random_suffix}" name = "Service Project Full" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_120s" { diff --git a/google/services/apphub/resource_apphub_service_test.go b/google/services/apphub/resource_apphub_service_test.go index 9032cfcb1ab..559f898e0d9 100644 --- a/google/services/apphub/resource_apphub_service_test.go +++ b/google/services/apphub/resource_apphub_service_test.go @@ -66,6 +66,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/google/services/apphub/resource_apphub_workload_generated_test.go b/google/services/apphub/resource_apphub_workload_generated_test.go index 7b831af84d2..8f2234c9717 100644 --- a/google/services/apphub/resource_apphub_workload_generated_test.go +++ b/google/services/apphub/resource_apphub_workload_generated_test.go @@ -77,6 +77,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API @@ -239,6 +240,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/google/services/apphub/resource_apphub_workload_test.go b/google/services/apphub/resource_apphub_workload_test.go index e553c925d0d..8c3df69a81c 100644 --- a/google/services/apphub/resource_apphub_workload_test.go +++ b/google/services/apphub/resource_apphub_workload_test.go @@ -66,6 +66,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/google/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go b/google/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go index 4a90d4c14e6..dd38fe3727c 100644 --- a/google/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go +++ b/google/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go @@ -119,6 +119,7 @@ resource "google_assured_workloads_workload" "primary" { resource "google_folder" "folder1" { display_name = "tf-test-name%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } `, context) } @@ -145,6 +146,7 @@ resource "google_assured_workloads_workload" "primary" { resource "google_folder" "folder1" { display_name = "tf-test-name%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } `, context) } @@ -167,6 +169,7 @@ resource "google_assured_workloads_workload" "primary" { resource "google_folder" "folder1" { display_name = "tf-test-name%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } `, context) diff --git a/google/services/bigquery/resource_bigquery_dataset_test.go b/google/services/bigquery/resource_bigquery_dataset_test.go index 4e3a4de0e41..a6ac8211837 100644 --- a/google/services/bigquery/resource_bigquery_dataset_test.go +++ b/google/services/bigquery/resource_bigquery_dataset_test.go @@ -125,7 +125,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"), ), @@ -496,6 +496,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/google/services/bigquery/resource_bigquery_table.go b/google/services/bigquery/resource_bigquery_table.go index 30fcbd52387..b6ebb8f7c08 100644 --- a/google/services/bigquery/resource_bigquery_table.go +++ b/google/services/bigquery/resource_bigquery_table.go @@ -1594,6 +1594,9 @@ func resourceBigQueryTableCreate(d *schema.ResourceData, meta interface{}) error } if table.View != nil && table.Schema != nil { + if schemaHasRequiredFields(table.Schema) { + return errors.New("Schema cannot contain required fields when creating a view") + } log.Printf("[INFO] Removing schema from table definition because BigQuery does not support setting schema on view creation") schemaBack := table.Schema @@ -1929,17 +1932,6 @@ func resourceBigQueryTableDelete(d *schema.ResourceData, meta interface{}) error if d.Get("deletion_protection").(bool) { return fmt.Errorf("cannot destroy table %v without setting deletion_protection=false and running `terraform apply`", d.Id()) } - if v, ok := d.GetOk("resource_tags"); ok { - if !d.Get("allow_resource_tags_on_deletion").(bool) { - var resourceTags []string - - for k, v := range v.(map[string]interface{}) { - resourceTags = append(resourceTags, fmt.Sprintf("%s:%s", k, v.(string))) - } - - return fmt.Errorf("cannot destroy table %v without unsetting the following resource tags or setting allow_resource_tags_on_deletion=true: %v", d.Id(), resourceTags) - } - } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -2552,6 +2544,15 @@ func setEmptyPolicyTagsInSchema(field *bigquery.TableFieldSchema) { } } +func schemaHasRequiredFields(schema *bigquery.TableSchema) bool { + for _, field := range schema.Fields { + if "REQUIRED" == field.Mode { + return true + } + } + return false +} + func expandTimePartitioning(configured interface{}) *bigquery.TimePartitioning { raw := configured.([]interface{})[0].(map[string]interface{}) tp := &bigquery.TimePartitioning{Type: raw["type"].(string)} diff --git a/google/services/bigquery/resource_bigquery_table_test.go b/google/services/bigquery/resource_bigquery_table_test.go index 4b7c5a8187f..2158774a832 100644 --- a/google/services/bigquery/resource_bigquery_table_test.go +++ b/google/services/bigquery/resource_bigquery_table_test.go @@ -1517,6 +1517,23 @@ func TestAccBigQueryTable_invalidSchemas(t *testing.T) { }) } +func TestAccBigQueryTable_schemaWithRequiredFieldAndView(t *testing.T) { + datasetID := fmt.Sprintf("tf_test_%s", acctest.RandString(t, 10)) + tableID := fmt.Sprintf("tf_test_%s", acctest.RandString(t, 10)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckBigQueryTableDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBigQueryTableWithSchemaWithRequiredFieldAndView(datasetID, tableID), + ExpectError: regexp.MustCompile("Schema cannot contain required fields when creating a view"), + }, + }, + }) +} + func TestAccBigQueryTable_TableReplicationInfo_ConflictsWithView(t *testing.T) { t.Parallel() @@ -1630,7 +1647,7 @@ func TestAccBigQueryTable_ResourceTags(t *testing.T) { ResourceName: "google_bigquery_table.test", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"deletion_protection", "allow_resource_tags_on_deletion"}, + ImportStateVerifyIgnore: []string{"deletion_protection"}, }, { Config: testAccBigQueryTableWithResourceTagsUpdate(context), @@ -1639,7 +1656,7 @@ func TestAccBigQueryTable_ResourceTags(t *testing.T) { ResourceName: "google_bigquery_table.test", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"deletion_protection", "allow_resource_tags_on_deletion"}, + ImportStateVerifyIgnore: []string{"deletion_protection"}, }, // testAccBigQueryTableWithResourceTagsDestroy must be called at the end of this test to clear the resource tag bindings of the table before deletion. { @@ -1649,7 +1666,7 @@ func TestAccBigQueryTable_ResourceTags(t *testing.T) { ResourceName: "google_bigquery_table.test", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"deletion_protection", "allow_resource_tags_on_deletion"}, + ImportStateVerifyIgnore: []string{"deletion_protection"}, }, }, }) @@ -4040,6 +4057,42 @@ resource "google_bigquery_table" "test" { `, datasetID, tableID) } +func testAccBigQueryTableWithSchemaWithRequiredFieldAndView(datasetID, tableID string) string { + return fmt.Sprintf(` +resource "google_bigquery_dataset" "test" { + dataset_id = "%s" +} + +resource "google_bigquery_table" "test" { + deletion_protection = false + table_id = "%s" + dataset_id = google_bigquery_dataset.test.dataset_id + schema = < 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_job_test.go b/google/services/cloudrunv2/resource_cloud_run_v2_job_test.go index 658056e3684..b8fe92ceea9 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_job_test.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_job_test.go @@ -39,7 +39,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobFullUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage", "labels", "terraform_labels", "annotations"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "labels", "terraform_labels", "annotations", "deletion_protection"}, }, }, }) @@ -118,6 +118,7 @@ func testAccCloudRunV2Job_cloudrunv2JobFullUpdate(context map[string]interface{} resource "google_cloud_run_v2_job" "default" { name = "tf-test-cloudrun-job%{random_suffix}" location = "us-central1" + deletion_protection = false binary_authorization { use_default = true breakglass_justification = "Some justification" @@ -230,7 +231,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithDirectVPCUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCAndNamedBinAuthPolicyUpdate(context), @@ -239,7 +240,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithDirectVPCUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -250,6 +251,8 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPC(context map[string]interfac resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false + launch_stage = "BETA" template { template { containers { @@ -277,6 +280,8 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCAndNamedBinAuthPolicyUpdate( resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false + launch_stage = "BETA" binary_authorization { policy = "projects/%{project}/platforms/cloudRun/policies/my-policy" breakglass_justification = "Some justification" diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_service.go b/google/services/cloudrunv2/resource_cloud_run_v2_service.go index c08c6db07a1..6b911140b9e 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_service.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_service.go @@ -123,57 +123,14 @@ This field follows Kubernetes annotations' namespacing, limits, and rules.`, }, }, "env": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Description: `List of environment variables to set in the container.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: `Name of the environment variable. Must be a C_IDENTIFIER, and may not exceed 32768 characters.`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - Description: `Literal value of the environment variable. Defaults to "" and the maximum allowed length is 32768 characters. Variable references are not supported in Cloud Run.`, - }, - "value_source": { - Type: schema.TypeList, - Optional: true, - Description: `Source for the environment variable's value.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "secret_key_ref": { - Type: schema.TypeList, - Optional: true, - Description: `Selects a secret and a specific version from Cloud Secret Manager.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "secret": { - Type: schema.TypeString, - Required: true, - Description: `The name of the secret in Cloud Secret Manager. Format: {secretName} if the secret is in the same project. projects/{project}/secrets/{secretName} if the secret is in a different project.`, - }, - "version": { - Type: schema.TypeString, - Optional: true, - Description: `The Cloud Secret Manager secret version. Can be 'latest' for the latest value or an integer for a specific version.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, + Elem: cloudrunv2ServiceTemplateContainersContainersEnvSchema(), + // Default schema.HashSchema is used. }, "liveness_probe": { Type: schema.TypeList, - Computed: true, Optional: true, Description: `Periodic probe of container liveness. Container will be restarted if the probe fails. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes`, MaxItems: 1, @@ -1104,6 +1061,17 @@ If reconciliation failed, trafficStatuses, observedGeneration, and latestReadyRe Computed: true, Description: `The main URI in which this Service is serving traffic.`, }, + "deletion_protection": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: `Whether Terraform will be prevented from destroying the service. Defaults to true. +When a'terraform destroy' or 'terraform apply' would delete the service, +the command will fail if this field is not set to false in Terraform state. +When the field is set to true or unset in Terraform state, a 'terraform apply' +or 'terraform destroy' that would delete the service will fail. +When the field is set to false, deleting the service is allowed.`, + }, "project": { Type: schema.TypeString, Optional: true, @@ -1115,6 +1083,53 @@ If reconciliation failed, trafficStatuses, observedGeneration, and latestReadyRe } } +func cloudrunv2ServiceTemplateContainersContainersEnvSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: `Name of the environment variable. Must be a C_IDENTIFIER, and may not exceed 32768 characters.`, + }, + "value": { + Type: schema.TypeString, + Optional: true, + Description: `Literal value of the environment variable. Defaults to "" and the maximum allowed length is 32768 characters. Variable references are not supported in Cloud Run.`, + }, + "value_source": { + Type: schema.TypeList, + Optional: true, + Description: `Source for the environment variable's value.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "secret_key_ref": { + Type: schema.TypeList, + Optional: true, + Description: `Selects a secret and a specific version from Cloud Secret Manager.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "secret": { + Type: schema.TypeString, + Required: true, + Description: `The name of the secret in Cloud Secret Manager. Format: {secretName} if the secret is in the same project. projects/{project}/secrets/{secretName} if the secret is in a different project.`, + }, + "version": { + Type: schema.TypeString, + Optional: true, + Description: `The Cloud Secret Manager secret version. Can be 'latest' for the latest value or an integer for a specific version.`, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + func resourceCloudRunV2ServiceCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -1291,6 +1306,12 @@ func resourceCloudRunV2ServiceRead(d *schema.ResourceData, meta interface{}) err return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudRunV2Service %q", d.Id())) } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_protection"); !ok { + if err := d.Set("deletion_protection", true); err != nil { + return fmt.Errorf("Error setting deletion_protection: %s", err) + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -1544,6 +1565,9 @@ func resourceCloudRunV2ServiceDelete(d *schema.ResourceData, meta interface{}) e } headers := make(http.Header) + if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy service without setting deletion_protection=false and running `terraform apply`") + } log.Printf("[DEBUG] Deleting Service %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ @@ -1589,6 +1613,11 @@ func resourceCloudRunV2ServiceImport(d *schema.ResourceData, meta interface{}) ( } d.SetId(id) + // Explicitly set virtual fields to default values on import + if err := d.Set("deletion_protection", true); err != nil { + return nil, fmt.Errorf("Error setting deletion_protection: %s", err) + } + return []*schema.ResourceData{d}, nil } @@ -1920,14 +1949,14 @@ func flattenCloudRunV2ServiceTemplateContainersEnv(v interface{}, d *schema.Reso return v } l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) + transformed := schema.NewSet(schema.HashResource(cloudrunv2ServiceTemplateContainersContainersEnvSchema()), []interface{}{}) for _, raw := range l { original := raw.(map[string]interface{}) if len(original) < 1 { // Do not include empty json objects coming back from the api continue } - transformed = append(transformed, map[string]interface{}{ + transformed.Add(map[string]interface{}{ "name": flattenCloudRunV2ServiceTemplateContainersEnvName(original["name"], d, config), "value": flattenCloudRunV2ServiceTemplateContainersEnvValue(original["value"], d, config), "value_source": flattenCloudRunV2ServiceTemplateContainersEnvValueSource(original["valueSource"], d, config), @@ -3439,6 +3468,7 @@ func expandCloudRunV2ServiceTemplateContainersArgs(v interface{}, d tpgresource. } func expandCloudRunV2ServiceTemplateContainersEnv(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + v = v.(*schema.Set).List() l := v.([]interface{}) req := make([]interface{}, 0, len(l)) for _, raw := range l { diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go b/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go index f1d72178937..3c3fa700c93 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go @@ -49,7 +49,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceBasicExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -60,6 +60,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceBasicExample(context map[string]i resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -90,7 +91,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceLimitsExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -101,6 +102,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceLimitsExample(context map[string] resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -138,7 +140,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceSqlExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -149,6 +151,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceSqlExample(context map[string]int resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -247,7 +250,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceVpcaccessExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -258,6 +261,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceVpcaccessExample(context map[stri resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -312,7 +316,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceDirectvpcExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -323,6 +327,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceDirectvpcExample(context map[stri resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { @@ -359,7 +364,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceProbesExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -370,6 +375,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceProbesExample(context map[string] resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -413,7 +419,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceSecretExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -424,6 +430,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceSecretExample(context map[string] resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -474,6 +481,7 @@ resource "google_secret_manager_secret_iam_member" "secret-access" { } func TestAccCloudRunV2Service_cloudrunv2ServiceMountGcsExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -492,7 +500,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceMountGcsExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -504,6 +512,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { @@ -535,6 +544,7 @@ resource "google_storage_bucket" "default" { } func TestAccCloudRunV2Service_cloudrunv2ServiceMountNfsExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -553,7 +563,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceMountNfsExample(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "name", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"annotations", "deletion_protection", "labels", "location", "name", "terraform_labels"}, }, }, }) @@ -565,6 +575,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" launch_stage = "BETA" diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_service_sweeper.go b/google/services/cloudrunv2/resource_cloud_run_v2_service_sweeper.go deleted file mode 100644 index d90dbf6a3ca..00000000000 --- a/google/services/cloudrunv2/resource_cloud_run_v2_service_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package cloudrunv2 - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("CloudRunV2Service", testSweepCloudRunV2Service) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepCloudRunV2Service(region string) error { - resourceName := "CloudRunV2Service" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://run.googleapis.com/v2/projects/{{project}}/locations/{{location}}/services", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["services"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://run.googleapis.com/v2/projects/{{project}}/locations/{{location}}/services/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_service_test.go b/google/services/cloudrunv2/resource_cloud_run_v2_service_test.go index 2bee2cfb22f..bbcfb4d907c 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_service_test.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_service_test.go @@ -42,7 +42,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceFullUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "deletion_protection"}, }, }, }) @@ -117,6 +117,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description updating" location = "us-central1" + deletion_protection = false annotations = { generated-by = "magic-modules-files" } @@ -228,7 +229,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceTCPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithTCPStartupProbeAndHTTPLivenessProbe(context), @@ -237,7 +238,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceTCPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, }, }) @@ -262,7 +263,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceHTTPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithHTTPStartupProbe(context), @@ -271,7 +272,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceHTTPProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, }, }) @@ -297,7 +298,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceGRPCProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessProbe(context), @@ -306,7 +307,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceGRPCProbesUpdate(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "deletion_protection"}, }, // The following test steps of gRPC startup probe are expected to fail with startup probe check failures. // This is because, due to the unavailability of ready-to-use container images of a gRPC service that @@ -359,6 +360,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceWithEmptyTCPStartupProbeAndHTTPLi resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -383,6 +385,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithTCPStartupProbeAndHTTPL resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -427,6 +430,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithEmptyHTTPStartupProbe(c resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -445,6 +449,7 @@ func testAccCloudRunV2Service_cloudrunv2ServiceUpdateWithHTTPStartupProbe(contex resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false template { containers { @@ -477,6 +482,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithEmptyGRPCLivenessProbe(co resource "google_cloud_run_v2_service" "default" { name ="%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -498,6 +504,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessProbe(context resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -522,6 +529,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithEmptyGRPCStartupProbe(con resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -543,6 +551,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCStartupProbe(context resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -567,6 +576,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessAndStartupPro resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -613,7 +623,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithDirectVPCUpdate(t *testing.T) ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location"}, + ImportStateVerifyIgnore: []string{"name", "location", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceWithDirectVPCAndNamedBinAuthPolicyUpdate(context), @@ -622,7 +632,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithDirectVPCUpdate(t *testing.T) ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location"}, + ImportStateVerifyIgnore: []string{"name", "location", "deletion_protection"}, }, }, }) @@ -633,6 +643,7 @@ func testAccCloudRunV2Service_cloudRunServiceWithDirectVPC(context map[string]in resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { @@ -653,6 +664,7 @@ func testAccCloudRunV2Service_cloudRunServiceWithDirectVPCAndNamedBinAuthPolicyU resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false launch_stage = "GA" binary_authorization { policy = "projects/%{project}/platforms/cloudRun/policies/my-policy" @@ -690,7 +702,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceCustomAudienceUpdate(t *testing.T ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceUpdateWithCustomAudience(serviceName, "test_update"), @@ -699,7 +711,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceCustomAudienceUpdate(t *testing.T ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudRunServiceUpdateWithoutCustomAudience(serviceName), @@ -708,7 +720,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceCustomAudienceUpdate(t *testing.T ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "launch_stage", "deletion_protection"}, }, }, }) @@ -719,6 +731,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithoutCustomAudience(service resource "google_cloud_run_v2_service" "default" { name = "%s" location = "us-central1" + deletion_protection = false template { containers { @@ -737,6 +750,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithCustomAudience(serviceNam resource "google_cloud_run_v2_service" "default" { name = "%s" location = "us-central1" + deletion_protection = false custom_audiences = ["%s"] template { @@ -809,6 +823,7 @@ provider "google" { resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false labels = { user_label = "foo" @@ -836,6 +851,7 @@ provider "google" { resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false labels = { user_label = "bar" diff --git a/google/services/composer/resource_composer_environment.go b/google/services/composer/resource_composer_environment.go index c9d47864b66..48b8a2db312 100644 --- a/google/services/composer/resource_composer_environment.go +++ b/google/services/composer/resource_composer_environment.go @@ -290,7 +290,6 @@ func ResourceComposerEnvironment() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ConfigMode: schema.SchemaConfigModeAttr, MaxItems: 1, Description: `Configuration for controlling how IPs are allocated in the GKE cluster. Cannot be updated.`, Elem: &schema.Resource{ diff --git a/google/services/composer/resource_composer_environment_test.go b/google/services/composer/resource_composer_environment_test.go index bf286dca18a..ce898d021a0 100644 --- a/google/services/composer/resource_composer_environment_test.go +++ b/google/services/composer/resource_composer_environment_test.go @@ -82,6 +82,8 @@ func TestAccComposerEnvironment_basic(t *testing.T) { // Checks that all updatable fields can be updated in one apply // (PATCH for Environments only is per-field) func TestAccComposerEnvironment_update(t *testing.T) { + // Currently failing + acctest.SkipIfVcr(t) t.Parallel() envName := fmt.Sprintf("%s-%d", testComposerEnvironmentPrefix, acctest.RandInt(t)) @@ -281,6 +283,8 @@ func TestAccComposerEnvironment_withDatabaseConfig(t *testing.T) { } func TestAccComposerEnvironment_withWebServerConfig(t *testing.T) { + // Currently failing + acctest.SkipIfVcr(t) t.Parallel() envName := fmt.Sprintf("%s-%d", testComposerEnvironmentPrefix, acctest.RandInt(t)) network := fmt.Sprintf("%s-%d", testComposerNetworkPrefix, acctest.RandInt(t)) @@ -354,6 +358,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/google/services/compute/resource_compute_address_test.go b/google/services/compute/resource_compute_address_test.go index 891ee5ff353..129cfce4fc4 100644 --- a/google/services/compute/resource_compute_address_test.go +++ b/google/services/compute/resource_compute_address_test.go @@ -526,6 +526,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" @@ -540,6 +544,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" @@ -558,6 +566,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_compute_address" "foobar" { @@ -578,6 +587,7 @@ provider "google" { default_labels = { default_key1 = "default_value1" } + add_terraform_attribution_label = false } resource "google_compute_address" "foobar" { @@ -600,6 +610,7 @@ provider "google" { default_key1 = "default_value1" env = "foo" } + add_terraform_attribution_label = false } resource "google_compute_address" "foobar" { @@ -750,6 +761,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/google/services/compute/resource_compute_backend_service.go b/google/services/compute/resource_compute_backend_service.go index ca9e9b9670f..f015a5916b8 100644 --- a/google/services/compute/resource_compute_backend_service.go +++ b/google/services/compute/resource_compute_backend_service.go @@ -637,14 +637,19 @@ For internal load balancing, a URL to a HealthCheck resource must be specified i MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + Description: `Whether the serving infrastructure will authenticate and authorize all incoming requests.`, + }, "oauth2_client_id": { Type: schema.TypeString, - Required: true, + Optional: true, Description: `OAuth2 Client ID for IAP`, }, "oauth2_client_secret": { Type: schema.TypeString, - Required: true, + Optional: true, Description: `OAuth2 Client Secret for IAP`, Sensitive: true, }, @@ -859,10 +864,7 @@ The default value is 1.0.`, Optional: true, Description: `Settings controlling eviction of unhealthy hosts from the load balancing pool. Applicable backend service types can be a global backend service with the -loadBalancingScheme set to INTERNAL_SELF_MANAGED or EXTERNAL_MANAGED. - -From version 6.0.0 outlierDetection default terraform values will be removed to match default GCP value. -Default values are enforce by GCP without providing them.`, +loadBalancingScheme set to INTERNAL_SELF_MANAGED or EXTERNAL_MANAGED.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -898,7 +900,6 @@ less than one second are represented with a 0 'seconds' field and a positive Description: `Number of errors before a host is ejected from the connection pool. When the backend host is accessed over HTTP, a 5xx return code qualifies as an error. Defaults to 5.`, - Default: 5, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "consecutive_gateway_failure": { @@ -907,7 +908,6 @@ Defaults to 5.`, Description: `The number of consecutive gateway failures (502, 503, 504 status or connection errors that are mapped to one of those status codes) before a consecutive gateway failure ejection occurs. Defaults to 5.`, - Default: 5, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "enforcing_consecutive_errors": { @@ -916,7 +916,6 @@ gateway failure ejection occurs. Defaults to 5.`, Description: `The percentage chance that a host will be actually ejected when an outlier status is detected through consecutive 5xx. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 100.`, - Default: 100, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "enforcing_consecutive_gateway_failure": { @@ -925,7 +924,6 @@ ejection or to ramp it up slowly. Defaults to 100.`, Description: `The percentage chance that a host will be actually ejected when an outlier status is detected through consecutive gateway failures. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 0.`, - Default: 0, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "enforcing_success_rate": { @@ -934,7 +932,6 @@ used to disable ejection or to ramp it up slowly. Defaults to 0.`, Description: `The percentage chance that a host will be actually ejected when an outlier status is detected through success rate statistics. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 100.`, - Default: 100, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "interval": { @@ -967,7 +964,6 @@ less than one second are represented with a 0 'seconds' field and a positive Optional: true, Description: `Maximum percentage of hosts in the load balancing pool for the backend service that can be ejected. Defaults to 10%.`, - Default: 10, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "success_rate_minimum_hosts": { @@ -977,7 +973,6 @@ that can be ejected. Defaults to 10%.`, success rate outliers. If the number of hosts is less than this setting, outlier detection via success rate statistics is not performed for any host in the cluster. Defaults to 5.`, - Default: 5, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "success_rate_request_volume": { @@ -988,7 +983,6 @@ defined by the interval duration above) to include this host in success rate based outlier detection. If the volume is lower than this setting, outlier detection via success rate statistics is not performed for that host. Defaults to 100.`, - Default: 100, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "success_rate_stdev_factor": { @@ -1000,7 +994,6 @@ rate, and the product of this factor and the standard deviation of the mean success rate: mean - (stdev * success_rate_stdev_factor). This factor is divided by a thousand to get a double. That is, if the desired factor is 1.9, the runtime value should be 1900. Defaults to 1900.`, - Default: 1900, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, }, @@ -1186,9 +1179,7 @@ UTILIZATION. Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). See the [Backend Services Overview](https://cloud.google.com/load-balancing/docs/backend-service#balancing-mode) -for an explanation of load balancing modes. - -From version 6.0.0 default value will be UTILIZATION to match default GCP value. Default value: "UTILIZATION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, +for an explanation of load balancing modes. Default value: "UTILIZATION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, Default: "UTILIZATION", }, "capacity_scaler": { @@ -2786,6 +2777,8 @@ func flattenComputeBackendServiceIap(v interface{}, d *schema.ResourceData, conf return nil } transformed := make(map[string]interface{}) + transformed["enabled"] = + flattenComputeBackendServiceIapEnabled(original["enabled"], d, config) transformed["oauth2_client_id"] = flattenComputeBackendServiceIapOauth2ClientId(original["oauth2ClientId"], d, config) transformed["oauth2_client_secret"] = @@ -2794,6 +2787,10 @@ func flattenComputeBackendServiceIap(v interface{}, d *schema.ResourceData, conf flattenComputeBackendServiceIapOauth2ClientSecretSha256(original["oauth2ClientSecretSha256"], d, config) return []interface{}{transformed} } +func flattenComputeBackendServiceIapEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenComputeBackendServiceIapOauth2ClientId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -3932,6 +3929,13 @@ func expandComputeBackendServiceIap(v interface{}, d tpgresource.TerraformResour original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) + transformedEnabled, err := expandComputeBackendServiceIapEnabled(original["enabled"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["enabled"] = transformedEnabled + } + transformedOauth2ClientId, err := expandComputeBackendServiceIapOauth2ClientId(original["oauth2_client_id"], d, config) if err != nil { return nil, err @@ -3956,6 +3960,10 @@ func expandComputeBackendServiceIap(v interface{}, d tpgresource.TerraformResour return transformed, nil } +func expandComputeBackendServiceIapEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandComputeBackendServiceIapOauth2ClientId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -4419,24 +4427,6 @@ func expandComputeBackendServiceServiceLbPolicy(v interface{}, d tpgresource.Ter } func resourceComputeBackendServiceEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - // The BackendService API's Update / PUT API is badly formed and behaves like - // a PATCH field for at least IAP. When sent a `null` `iap` field, the API - // doesn't disable an existing field. To work around this, we need to emulate - // the old Terraform behaviour of always sending the block (at both update and - // create), and force sending each subfield as empty when the block isn't - // present in config. - - iapVal := obj["iap"] - if iapVal == nil { - data := map[string]interface{}{} - data["enabled"] = false - obj["iap"] = data - } else { - iap := iapVal.(map[string]interface{}) - iap["enabled"] = true - obj["iap"] = iap - } - backendsRaw, ok := obj["backends"] if !ok { return obj, nil @@ -4495,18 +4485,6 @@ func resourceComputeBackendServiceEncoder(d *schema.ResourceData, meta interface } func resourceComputeBackendServiceDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - // We need to pretend IAP isn't there if it's disabled for Terraform to maintain - // BC behaviour with the handwritten resource. - v, ok := res["iap"] - if !ok || v == nil { - delete(res, "iap") - return res, nil - } - m := v.(map[string]interface{}) - if ok && m["enabled"] == false { - delete(res, "iap") - } - // Requests with consistentHash will error for specific values of // localityLbPolicy. However, the API will not remove it if the backend // service is updated to from supporting to non-supporting localityLbPolicy diff --git a/google/services/compute/resource_compute_backend_service_generated_test.go b/google/services/compute/resource_compute_backend_service_generated_test.go index bbeaaabd736..296547e2484 100644 --- a/google/services/compute/resource_compute_backend_service_generated_test.go +++ b/google/services/compute/resource_compute_backend_service_generated_test.go @@ -103,6 +103,7 @@ resource "google_compute_backend_service" "default" { protocol = "HTTP" load_balancing_scheme = "EXTERNAL" iap { + enabled = true oauth2_client_id = "abc" oauth2_client_secret = "xyz" } diff --git a/google/services/compute/resource_compute_backend_service_test.go b/google/services/compute/resource_compute_backend_service_test.go index 79ff846388f..c828f881a55 100644 --- a/google/services/compute/resource_compute_backend_service_test.go +++ b/google/services/compute/resource_compute_backend_service_test.go @@ -126,23 +126,23 @@ func TestAccComputeBackendService_withBackendAndIAP(t *testing.T) { CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccComputeBackendService_withBackendAndIAP( + Config: testAccComputeBackendService_withBackend( serviceName, igName, itName, checkName, 10), }, { - ResourceName: "google_compute_backend_service.lipsum", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"iap.0.oauth2_client_secret"}, + ResourceName: "google_compute_backend_service.lipsum", + ImportState: true, + ImportStateVerify: true, }, { - Config: testAccComputeBackendService_withBackend( + Config: testAccComputeBackendService_withBackendAndIAP( serviceName, igName, itName, checkName, 10), }, { - ResourceName: "google_compute_backend_service.lipsum", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_backend_service.lipsum", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"iap.0.oauth2_client_secret"}, }, }, }) @@ -1178,6 +1178,7 @@ resource "google_compute_backend_service" "lipsum" { } iap { + enabled = true oauth2_client_id = "test" oauth2_client_secret = "test" } diff --git a/google/services/compute/resource_compute_firewall_policy_association_test.go b/google/services/compute/resource_compute_firewall_policy_association_test.go index 2082db539c2..3d68d1a941d 100644 --- a/google/services/compute/resource_compute_firewall_policy_association_test.go +++ b/google/services/compute/resource_compute_firewall_policy_association_test.go @@ -42,11 +42,13 @@ func testAccComputeFirewallPolicyAssociation_basic(context map[string]interface{ resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_folder" "target_folder" { display_name = "tf-test-target-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { diff --git a/google/services/compute/resource_compute_firewall_policy_rule_generated_test.go b/google/services/compute/resource_compute_firewall_policy_rule_generated_test.go index 80a24967136..e510b4ff273 100644 --- a/google/services/compute/resource_compute_firewall_policy_rule_generated_test.go +++ b/google/services/compute/resource_compute_firewall_policy_rule_generated_test.go @@ -83,6 +83,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a resource "google_folder" "folder" { display_name = "tf-test-policy%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { @@ -136,6 +137,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a resource "google_folder" "folder" { display_name = "tf-test-policy%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { diff --git a/google/services/compute/resource_compute_firewall_policy_rule_test.go b/google/services/compute/resource_compute_firewall_policy_rule_test.go index bb136ae626c..3e36b5206b1 100644 --- a/google/services/compute/resource_compute_firewall_policy_rule_test.go +++ b/google/services/compute/resource_compute_firewall_policy_rule_test.go @@ -154,6 +154,7 @@ func testAccComputeFirewallPolicyRule_securityProfileGroup_basic(context map[str resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_network_security_security_profile" "security_profile" { @@ -203,6 +204,7 @@ func testAccComputeFirewallPolicyRule_securityProfileGroup_update(context map[st resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_network_security_security_profile" "security_profile" { @@ -278,6 +280,7 @@ resource "google_compute_network" "network2" { resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "fw_policy" { @@ -343,6 +346,7 @@ resource "google_compute_network" "network2" { resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "fw_policy" { @@ -418,6 +422,7 @@ resource "google_compute_network" "network2" { resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "fw_policy" { @@ -469,6 +474,7 @@ func testAccComputeFirewallPolicyRule_multiple(context map[string]interface{}) s resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "fw_policy" { @@ -541,6 +547,7 @@ func testAccComputeFirewallPolicyRule_multipleAdd(context map[string]interface{} resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "fw_policy" { @@ -634,6 +641,7 @@ func testAccComputeFirewallPolicyRule_multipleRemove(context map[string]interfac resource "google_folder" "folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "%{org_name}" + deletion_protection = false } resource "google_compute_firewall_policy" "fw_policy" { diff --git a/google/services/compute/resource_compute_firewall_policy_test.go b/google/services/compute/resource_compute_firewall_policy_test.go index f2a7f4a8979..5365411c52a 100644 --- a/google/services/compute/resource_compute_firewall_policy_test.go +++ b/google/services/compute/resource_compute_firewall_policy_test.go @@ -56,6 +56,7 @@ func testAccComputeFirewallPolicy_basic(org, policyName, folderName string) stri resource "google_folder" "folder" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { @@ -71,6 +72,7 @@ func testAccComputeFirewallPolicy_update(org, policyName, folderName string) str resource "google_folder" "folder" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { diff --git a/google/services/compute/resource_compute_forwarding_rule.go b/google/services/compute/resource_compute_forwarding_rule.go index 3cb96b6c3d2..3185f1d38f0 100644 --- a/google/services/compute/resource_compute_forwarding_rule.go +++ b/google/services/compute/resource_compute_forwarding_rule.go @@ -123,7 +123,7 @@ func ResourceComputeForwardingRule() *schema.Resource { CustomizeDiff: customdiff.All( forwardingRuleCustomizeDiff, - tpgresource.SetLabelsDiff, + tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, ), diff --git a/google/services/compute/resource_compute_global_forwarding_rule.go b/google/services/compute/resource_compute_global_forwarding_rule.go index dd5213e5a47..83d353eca55 100644 --- a/google/services/compute/resource_compute_global_forwarding_rule.go +++ b/google/services/compute/resource_compute_global_forwarding_rule.go @@ -51,7 +51,7 @@ func ResourceComputeGlobalForwardingRule() *schema.Resource { }, CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, + tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, ), diff --git a/google/services/compute/resource_compute_instance.go b/google/services/compute/resource_compute_instance.go index b812ca9b2ee..4f453fd73c3 100644 --- a/google/services/compute/resource_compute_instance.go +++ b/google/services/compute/resource_compute_instance.go @@ -629,7 +629,6 @@ func ResourceComputeInstance() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ConfigMode: schema.SchemaConfigModeAttr, Description: `List of the type and count of accelerator cards attached to the instance.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/google/services/compute/resource_compute_instance_from_template.go b/google/services/compute/resource_compute_instance_from_template.go index bcf293fa016..16c6339fb75 100644 --- a/google/services/compute/resource_compute_instance_from_template.go +++ b/google/services/compute/resource_compute_instance_from_template.go @@ -48,17 +48,6 @@ func computeInstanceFromTemplateSchema() map[string]*schema.Schema { s[field].Optional = true } - // schema.SchemaConfigModeAttr allows these fields to be removed in Terraform 0.12. - // Passing field_name = [] in this mode differentiates between an intentionally empty - // block vs an ignored computed block. - nic := s["network_interface"].Elem.(*schema.Resource) - nic.Schema["alias_ip_range"].ConfigMode = schema.SchemaConfigModeAttr - nic.Schema["access_config"].ConfigMode = schema.SchemaConfigModeAttr - - for _, field := range []string{"attached_disk", "guest_accelerator", "service_account", "scratch_disk"} { - s[field].ConfigMode = schema.SchemaConfigModeAttr - } - // Remove deprecated/removed fields that are never d.Set. We can't // programmatically remove all of them, because some of them still have d.Set // calls. diff --git a/google/services/compute/resource_compute_instance_from_template_test.go b/google/services/compute/resource_compute_instance_from_template_test.go index 45c0a491b59..3808bc45194 100644 --- a/google/services/compute/resource_compute_instance_from_template_test.go +++ b/google/services/compute/resource_compute_instance_from_template_test.go @@ -243,49 +243,6 @@ func TestAccComputeInstanceFromTemplate_overrideScheduling(t *testing.T) { }) } -func TestAccComputeInstanceFromTemplate_012_removableFields(t *testing.T) { - t.Parallel() - - var instance compute.Instance - instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) - templateName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) - resourceName := "google_compute_instance_from_template.inst" - - // First config is a basic instance from template, second tests the empty list syntax - config1 := testAccComputeInstanceFromTemplate_012_removableFieldsTpl(templateName) + - testAccComputeInstanceFromTemplate_012_removableFields1(instanceName) - config2 := testAccComputeInstanceFromTemplate_012_removableFieldsTpl(templateName) + - testAccComputeInstanceFromTemplate_012_removableFields2(instanceName) - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckComputeInstanceFromTemplateDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: config1, - Check: resource.ComposeTestCheckFunc( - testAccCheckComputeInstanceExists(t, resourceName, &instance), - - resource.TestCheckResourceAttr(resourceName, "service_account.#", "1"), - resource.TestCheckResourceAttr(resourceName, "service_account.0.scopes.#", "3"), - ), - }, - { - Config: config2, - Check: resource.ComposeTestCheckFunc( - testAccCheckComputeInstanceExists(t, resourceName, &instance), - - // Check that fields were able to be removed - resource.TestCheckResourceAttr(resourceName, "scratch_disk.#", "0"), - resource.TestCheckResourceAttr(resourceName, "attached_disk.#", "0"), - resource.TestCheckResourceAttr(resourceName, "network_interface.0.alias_ip_range.#", "0"), - ), - }, - }, - }) -} - func TestAccComputeInstanceFromTemplate_overrideMetadataDotStartupScript(t *testing.T) { var instance compute.Instance instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) @@ -973,84 +930,6 @@ resource "google_compute_instance_from_template" "inst" { `, templateDisk, template, instance) } -func testAccComputeInstanceFromTemplate_012_removableFieldsTpl(template string) string { - - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-11" - project = "debian-cloud" -} - -resource "google_compute_instance_template" "foobar" { - name = "%s" - machine_type = "e2-medium" - - disk { - source_image = data.google_compute_image.my_image.self_link - auto_delete = true - disk_size_gb = 20 - boot = true - } - - network_interface { - network = "default" - } - - metadata = { - foo = "bar" - } - - service_account { - scopes = ["userinfo-email", "compute-ro", "storage-ro"] - } - - can_ip_forward = true -} -`, template) -} - -func testAccComputeInstanceFromTemplate_012_removableFields1(instance string) string { - return fmt.Sprintf(` -resource "google_compute_instance_from_template" "inst" { - name = "%s" - zone = "us-central1-a" - - allow_stopping_for_update = true - - source_instance_template = google_compute_instance_template.foobar.self_link -} -`, instance) -} - -func testAccComputeInstanceFromTemplate_012_removableFields2(instance string) string { - return fmt.Sprintf(` -resource "google_compute_instance_from_template" "inst" { - name = "%s" - zone = "us-central1-a" - - allow_stopping_for_update = true - - source_instance_template = google_compute_instance_template.foobar.self_link - - // Overrides - network_interface { - alias_ip_range = [] - } - - service_account = [] - - scratch_disk = [] - - attached_disk = [] - - timeouts { - create = "10m" - update = "10m" - } -} -`, instance) -} - func testAccComputeInstanceFromTemplate_overrideMetadataDotStartupScript(instance, template string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { diff --git a/google/services/compute/resource_compute_instance_template.go b/google/services/compute/resource_compute_instance_template.go index 113eb55cb0a..d97e805f567 100644 --- a/google/services/compute/resource_compute_instance_template.go +++ b/google/services/compute/resource_compute_instance_template.go @@ -89,14 +89,14 @@ func ResourceComputeInstanceTemplate() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - Description: `Creates a unique name beginning with the specified prefix. Conflicts with name.`, + Description: `Creates a unique name beginning with the specified prefix. Conflicts with name. Max length is 54 characters. Prefixes with lengths longer than 37 characters will use a shortened UUID that will be more prone to collisions.`, ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { // https://cloud.google.com/compute/docs/reference/latest/instanceTemplates#resource - // uuid is 26 characters, limit the prefix to 37. + // shortened uuid is 9 characters, limit the prefix to 55. value := v.(string) - if len(value) > 37 { + if len(value) > 54 { errors = append(errors, fmt.Errorf( - "%q cannot be longer than 37 characters, name is limited to 63", k)) + "%q cannot be longer than 54 characters, name is limited to 63", k)) } return }, @@ -1377,7 +1377,12 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac if v, ok := d.GetOk("name"); ok { itName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - itName = id.PrefixedUniqueId(v.(string)) + prefix := v.(string) + if len(prefix) > 37 { + itName = tpgresource.ReducedPrefixedUniqueId(prefix) + } else { + itName = id.PrefixedUniqueId(prefix) + } } else { itName = id.UniqueId() } diff --git a/google/services/compute/resource_compute_instance_template_test.go b/google/services/compute/resource_compute_instance_template_test.go index 8b47f53c0df..0498fae2774 100644 --- a/google/services/compute/resource_compute_instance_template_test.go +++ b/google/services/compute/resource_compute_instance_template_test.go @@ -795,6 +795,45 @@ func TestAccComputeInstanceTemplate_invalidDiskType(t *testing.T) { }) } +func TestAccComputeInstanceTemplate_withNamePrefix(t *testing.T) { + t.Parallel() + + // 8 + 46 = 54 which is the valid max + normalPrefix := "tf-test-" + fmt.Sprintf("%046s", "") + reducedSuffixPrefix := "tf-test-" + fmt.Sprintf("%029s", "") + invalidPrefix := "tf-test-" + fmt.Sprintf("%047s", "") + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeInstanceTemplate_withNamePrefix(normalPrefix), + }, + { + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"name_prefix"}, + }, + { + Config: testAccComputeInstanceTemplate_withNamePrefix(invalidPrefix), + PlanOnly: true, + ExpectError: regexp.MustCompile("cannot be longer than 54 characters"), + }, + { + Config: testAccComputeInstanceTemplate_withNamePrefix(reducedSuffixPrefix), + }, + { + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"name_prefix"}, + }, + }, + }) +} + func TestAccComputeInstanceTemplate_withScratchDisk(t *testing.T) { t.Parallel() @@ -2341,6 +2380,28 @@ resource "google_compute_instance_template" "foobar" { `, suffix, suffix) } +func testAccComputeInstanceTemplate_withNamePrefix(prefix string) string { + return fmt.Sprintf(` +data "google_compute_image" "my_image" { + family = "debian-12" + project = "debian-cloud" +} +resource "google_compute_instance_template" "foobar" { + name_prefix = "%s" + machine_type = "n1-standard-1" // can't be e2 because of local-ssd + can_ip_forward = false + disk { + source_image = data.google_compute_image.my_image.name + auto_delete = true + boot = true + } + network_interface { + network = "default" + } +} +`, prefix) +} + func testAccComputeInstanceTemplate_with375GbScratchDisk(suffix string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { @@ -2595,6 +2656,7 @@ resource "google_project" "host_project" { project_id = "%s-host" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host_project" { @@ -2611,6 +2673,7 @@ resource "google_project" "service_project" { project_id = "%s-service" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "service_project" { diff --git a/google/services/compute/resource_compute_instance_test.go b/google/services/compute/resource_compute_instance_test.go index 639ab3f52e8..ac3293f79d9 100644 --- a/google/services/compute/resource_compute_instance_test.go +++ b/google/services/compute/resource_compute_instance_test.go @@ -6154,6 +6154,7 @@ resource "google_project" "host_project" { project_id = "%s-host" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host_project" { @@ -6170,6 +6171,7 @@ resource "google_project" "service_project" { project_id = "%s-service" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "service_project" { diff --git a/google/services/compute/resource_compute_managed_ssl_certificate.go b/google/services/compute/resource_compute_managed_ssl_certificate.go index 3978516e18f..57604cbabce 100644 --- a/google/services/compute/resource_compute_managed_ssl_certificate.go +++ b/google/services/compute/resource_compute_managed_ssl_certificate.go @@ -117,7 +117,6 @@ which type this is. Default value: "MANAGED" Possible values: ["MANAGED"]`, "certificate_id": { Type: schema.TypeInt, Computed: true, - Optional: true, Description: `The unique identifier for the resource.`, }, "creation_timestamp": { diff --git a/google/services/compute/resource_compute_network_attachment_generated_test.go b/google/services/compute/resource_compute_network_attachment_generated_test.go index 4fcfd322303..cd09f77fe34 100644 --- a/google/services/compute/resource_compute_network_attachment_generated_test.go +++ b/google/services/compute/resource_compute_network_attachment_generated_test.go @@ -97,6 +97,7 @@ resource "google_project" "rejected_producer_project" { name = "tf-test-prj-rejected%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "accepted_producer_project" { @@ -104,6 +105,7 @@ resource "google_project" "accepted_producer_project" { name = "tf-test-prj-accepted%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } `, context) } diff --git a/google/services/compute/resource_compute_network_endpoints.go b/google/services/compute/resource_compute_network_endpoints.go index fccc29756b5..465dd200647 100644 --- a/google/services/compute/resource_compute_network_endpoints.go +++ b/google/services/compute/resource_compute_network_endpoints.go @@ -285,7 +285,7 @@ func resourceComputeNetworkEndpointsCreate(d *schema.ResourceData, meta interfac } // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{zone}}/{{network_endpoint_group}}/endpoints") + id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{zone}}/{{network_endpoint_group}}") if err != nil { return fmt.Errorf("Error constructing id: %s", err) } @@ -628,7 +628,7 @@ func resourceComputeNetworkEndpointsImport(d *schema.ResourceData, meta interfac } // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{zone}}/{{network_endpoint_group}}/endpoints") + id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{zone}}/{{network_endpoint_group}}") if err != nil { return nil, fmt.Errorf("Error constructing id: %s", err) } diff --git a/google/services/compute/resource_compute_network_peering_routes_config_generated_test.go b/google/services/compute/resource_compute_network_peering_routes_config_generated_test.go index 88745c7dc5b..d73bd7f4c11 100644 --- a/google/services/compute/resource_compute_network_peering_routes_config_generated_test.go +++ b/google/services/compute/resource_compute_network_peering_routes_config_generated_test.go @@ -87,6 +87,7 @@ resource "google_compute_network" "network_secondary" { } func TestAccComputeNetworkPeeringRoutesConfig_networkPeeringRoutesConfigGkeExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/google/services/compute/resource_compute_node_group_generated_test.go b/google/services/compute/resource_compute_node_group_generated_test.go index d6bebdeb318..09e15485fdb 100644 --- a/google/services/compute/resource_compute_node_group_generated_test.go +++ b/google/services/compute/resource_compute_node_group_generated_test.go @@ -159,6 +159,7 @@ resource "google_project" "guest_project" { project_id = "tf-test-project-id%{random_suffix}" name = "tf-test-project-name%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_compute_node_template" "soletenant-tmpl" { diff --git a/google/services/compute/resource_compute_project_cloud_armor_tier_test.go b/google/services/compute/resource_compute_project_cloud_armor_tier_test.go index 54c1b2c40ec..e19024eb7e1 100644 --- a/google/services/compute/resource_compute_project_cloud_armor_tier_test.go +++ b/google/services/compute/resource_compute_project_cloud_armor_tier_test.go @@ -84,6 +84,7 @@ resource "google_project" "project" { name = "%{projectID}" org_id = "%{org}" billing_account = "%{billingId}" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -106,6 +107,7 @@ resource "google_project" "project" { name = "%{projectID}" org_id = "%{org}" billing_account = "%{billingId}" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { diff --git a/google/services/compute/resource_compute_project_default_network_tier_test.go b/google/services/compute/resource_compute_project_default_network_tier_test.go index 34497d4b9ae..e66f6dc0e81 100644 --- a/google/services/compute/resource_compute_project_default_network_tier_test.go +++ b/google/services/compute/resource_compute_project_default_network_tier_test.go @@ -73,6 +73,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -95,6 +96,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { diff --git a/google/services/compute/resource_compute_project_metadata_test.go b/google/services/compute/resource_compute_project_metadata_test.go index b4924306e58..b0e3bb68033 100644 --- a/google/services/compute/resource_compute_project_metadata_test.go +++ b/google/services/compute/resource_compute_project_metadata_test.go @@ -131,6 +131,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -156,6 +157,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -181,6 +183,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -207,6 +210,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { diff --git a/google/services/compute/resource_compute_region_backend_service.go b/google/services/compute/resource_compute_region_backend_service.go index 07dac285864..fe3f1c684ed 100644 --- a/google/services/compute/resource_compute_region_backend_service.go +++ b/google/services/compute/resource_compute_region_backend_service.go @@ -391,10 +391,8 @@ Defaults to 3.`, Type: schema.TypeInt, Optional: true, Description: `Time for which instance will be drained (not accept new -connections, but still work to finish started). - -From version 6.0.0 ConnectionDrainingTimeoutSec default value will be 300 to match default GCP value.`, - Default: 0, +connections, but still work to finish started).`, + Default: 300, }, "consistent_hash": { @@ -566,14 +564,19 @@ or serverless NEG as a backend.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + Description: `Whether the serving infrastructure will authenticate and authorize all incoming requests.`, + }, "oauth2_client_id": { Type: schema.TypeString, - Required: true, + Optional: true, Description: `OAuth2 Client ID for IAP`, }, "oauth2_client_secret": { Type: schema.TypeString, - Required: true, + Optional: true, Description: `OAuth2 Client Secret for IAP`, Sensitive: true, }, @@ -698,10 +701,7 @@ This field can only be specified when the load balancing scheme is set to INTERN Optional: true, Description: `Settings controlling eviction of unhealthy hosts from the load balancing pool. This field is applicable only when the 'load_balancing_scheme' is set -to INTERNAL_MANAGED and the 'protocol' is set to HTTP, HTTPS, or HTTP2. - -From version 6.0.0 outlierDetection default terraform values will be removed to match default GCP value. -Default values are enforce by GCP without providing them.`, +to INTERNAL_MANAGED and the 'protocol' is set to HTTP, HTTPS, or HTTP2.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -737,7 +737,6 @@ less than one second are represented with a 0 'seconds' field and a positive Description: `Number of errors before a host is ejected from the connection pool. When the backend host is accessed over HTTP, a 5xx return code qualifies as an error. Defaults to 5.`, - Default: 5, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "consecutive_gateway_failure": { @@ -746,7 +745,6 @@ Defaults to 5.`, Description: `The number of consecutive gateway failures (502, 503, 504 status or connection errors that are mapped to one of those status codes) before a consecutive gateway failure ejection occurs. Defaults to 5.`, - Default: 5, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "enforcing_consecutive_errors": { @@ -755,7 +753,6 @@ gateway failure ejection occurs. Defaults to 5.`, Description: `The percentage chance that a host will be actually ejected when an outlier status is detected through consecutive 5xx. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 100.`, - Default: 100, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "enforcing_consecutive_gateway_failure": { @@ -764,7 +761,6 @@ ejection or to ramp it up slowly. Defaults to 100.`, Description: `The percentage chance that a host will be actually ejected when an outlier status is detected through consecutive gateway failures. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 0.`, - Default: 0, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "enforcing_success_rate": { @@ -773,7 +769,6 @@ used to disable ejection or to ramp it up slowly. Defaults to 0.`, Description: `The percentage chance that a host will be actually ejected when an outlier status is detected through success rate statistics. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 100.`, - Default: 100, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "interval": { @@ -806,7 +801,6 @@ less than one second are represented with a 0 'seconds' field and a positive Optional: true, Description: `Maximum percentage of hosts in the load balancing pool for the backend service that can be ejected. Defaults to 10%.`, - Default: 10, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "success_rate_minimum_hosts": { @@ -816,7 +810,6 @@ that can be ejected. Defaults to 10%.`, success rate outliers. If the number of hosts is less than this setting, outlier detection via success rate statistics is not performed for any host in the cluster. Defaults to 5.`, - Default: 5, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "success_rate_request_volume": { @@ -827,7 +820,6 @@ defined by the interval duration above) to include this host in success rate based outlier detection. If the volume is lower than this setting, outlier detection via success rate statistics is not performed for that host. Defaults to 100.`, - Default: 100, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, "success_rate_stdev_factor": { @@ -839,7 +831,6 @@ rate, and the product of this factor and the standard deviation of the mean success rate: mean - (stdev * success_rate_stdev_factor). This factor is divided by a thousand to get a double. That is, if the desired factor is 1.9, the runtime value should be 1900. Defaults to 1900.`, - Default: 1900, AtLeastOneOf: []string{"outlier_detection.0.base_ejection_time", "outlier_detection.0.consecutive_errors", "outlier_detection.0.consecutive_gateway_failure", "outlier_detection.0.enforcing_consecutive_errors", "outlier_detection.0.enforcing_consecutive_gateway_failure", "outlier_detection.0.enforcing_success_rate", "outlier_detection.0.interval", "outlier_detection.0.max_ejection_percent", "outlier_detection.0.success_rate_minimum_hosts", "outlier_detection.0.success_rate_request_volume", "outlier_detection.0.success_rate_stdev_factor"}, }, }, @@ -957,10 +948,8 @@ partial URL.`, Description: `Specifies the balancing mode for this backend. See the [Backend Services Overview](https://cloud.google.com/load-balancing/docs/backend-service#balancing-mode) -for an explanation of load balancing modes. - -From version 6.0.0 default value will be UTILIZATION to match default GCP value. Default value: "CONNECTION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, - Default: "CONNECTION", +for an explanation of load balancing modes. Default value: "UTILIZATION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, + Default: "UTILIZATION", }, "capacity_scaler": { Type: schema.TypeFloat, @@ -2383,6 +2372,8 @@ func flattenComputeRegionBackendServiceIap(v interface{}, d *schema.ResourceData return nil } transformed := make(map[string]interface{}) + transformed["enabled"] = + flattenComputeRegionBackendServiceIapEnabled(original["enabled"], d, config) transformed["oauth2_client_id"] = flattenComputeRegionBackendServiceIapOauth2ClientId(original["oauth2ClientId"], d, config) transformed["oauth2_client_secret"] = @@ -2391,6 +2382,10 @@ func flattenComputeRegionBackendServiceIap(v interface{}, d *schema.ResourceData flattenComputeRegionBackendServiceIapOauth2ClientSecretSha256(original["oauth2ClientSecretSha256"], d, config) return []interface{}{transformed} } +func flattenComputeRegionBackendServiceIapEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenComputeRegionBackendServiceIapOauth2ClientId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -3396,6 +3391,13 @@ func expandComputeRegionBackendServiceIap(v interface{}, d tpgresource.Terraform original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) + transformedEnabled, err := expandComputeRegionBackendServiceIapEnabled(original["enabled"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["enabled"] = transformedEnabled + } + transformedOauth2ClientId, err := expandComputeRegionBackendServiceIapOauth2ClientId(original["oauth2_client_id"], d, config) if err != nil { return nil, err @@ -3420,6 +3422,10 @@ func expandComputeRegionBackendServiceIap(v interface{}, d tpgresource.Terraform return transformed, nil } +func expandComputeRegionBackendServiceIapEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandComputeRegionBackendServiceIapOauth2ClientId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -3704,23 +3710,6 @@ func expandComputeRegionBackendServiceRegion(v interface{}, d tpgresource.Terraf } func resourceComputeRegionBackendServiceEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - // The RegionBackendService API's Update / PUT API is badly formed and behaves like - // a PATCH field for at least IAP. When sent a `null` `iap` field, the API - // doesn't disable an existing field. To work around this, we need to emulate - // the old Terraform behaviour of always sending the block (at both update and - // create), and force sending each subfield as empty when the block isn't - // present in config. - - iapVal := obj["iap"] - if iapVal == nil { - data := map[string]interface{}{} - data["enabled"] = false - obj["iap"] = data - } else { - iap := iapVal.(map[string]interface{}) - iap["enabled"] = true - obj["iap"] = iap - } if d.Get("load_balancing_scheme").(string) == "EXTERNAL_MANAGED" || d.Get("load_balancing_scheme").(string) == "INTERNAL_MANAGED" { return obj, nil @@ -3760,17 +3749,6 @@ func resourceComputeRegionBackendServiceEncoder(d *schema.ResourceData, meta int } func resourceComputeRegionBackendServiceDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - // We need to pretend IAP isn't there if it's disabled for Terraform to maintain - // BC behaviour with the handwritten resource. - v, ok := res["iap"] - if !ok || v == nil { - delete(res, "iap") - return res, nil - } - m := v.(map[string]interface{}) - if ok && m["enabled"] == false { - delete(res, "iap") - } // Requests with consistentHash will error for specific values of // localityLbPolicy. However, the API will not remove it if the backend diff --git a/google/services/compute/resource_compute_region_backend_service_generated_test.go b/google/services/compute/resource_compute_region_backend_service_generated_test.go index 7c52e9bd0af..782ca65ea14 100644 --- a/google/services/compute/resource_compute_region_backend_service_generated_test.go +++ b/google/services/compute/resource_compute_region_backend_service_generated_test.go @@ -110,6 +110,7 @@ resource "google_compute_region_backend_service" "default" { protocol = "HTTP" load_balancing_scheme = "EXTERNAL" iap { + enabled = true oauth2_client_id = "abc" oauth2_client_secret = "xyz" } diff --git a/google/services/compute/resource_compute_region_backend_service_test.go b/google/services/compute/resource_compute_region_backend_service_test.go index a1a40e91a95..ba1c26815fd 100644 --- a/google/services/compute/resource_compute_region_backend_service_test.go +++ b/google/services/compute/resource_compute_region_backend_service_test.go @@ -227,6 +227,14 @@ func TestAccComputeRegionBackendService_withBackendAndIAP(t *testing.T) { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), CheckDestroy: testAccCheckComputeRegionBackendServiceDestroyProducer(t), Steps: []resource.TestStep{ + { + Config: testAccComputeRegionBackendService_ilbBasic(backendName, checkName), + }, + { + ResourceName: "google_compute_region_backend_service.foobar", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccComputeRegionBackendService_ilbBasicwithIAP(backendName, checkName), }, @@ -236,14 +244,6 @@ func TestAccComputeRegionBackendService_withBackendAndIAP(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"iap.0.oauth2_client_secret"}, }, - { - Config: testAccComputeRegionBackendService_ilbBasic(backendName, checkName), - }, - { - ResourceName: "google_compute_region_backend_service.foobar", - ImportState: true, - ImportStateVerify: true, - }, }, }) } @@ -374,7 +374,8 @@ resource "google_compute_region_backend_service" "foobar" { health_checks = [google_compute_health_check.zero.self_link] region = "us-central1" - protocol = "%s" + protocol = "%s" + connection_draining_timeout_sec = 0 failover_policy { # Disable connection drain on failover cannot be set when the protocol is UDP drop_traffic_if_unhealthy = "%s" @@ -400,7 +401,8 @@ resource "google_compute_region_backend_service" "foobar" { health_checks = [google_compute_health_check.zero.self_link] region = "us-central1" - protocol = "%s" + protocol = "%s" + connection_draining_timeout_sec = 0 failover_policy { # Disable connection drain on failover cannot be set when the protocol is UDP drop_traffic_if_unhealthy = "%s" @@ -487,6 +489,7 @@ resource "google_compute_region_backend_service" "lipsum" { backend { group = google_compute_instance_group_manager.foobar.instance_group + balancing_mode = "CONNECTION" } health_checks = [google_compute_health_check.default.self_link] @@ -547,6 +550,7 @@ resource "google_compute_region_backend_service" "lipsum" { backend { group = google_compute_instance_group_manager.foobar.instance_group + balancing_mode = "CONNECTION" } network = google_compute_network.network2.self_link @@ -640,6 +644,7 @@ resource "google_compute_region_backend_service" "lipsum" { backend { group = google_compute_instance_group_manager.foobar.instance_group capacity_scaler = 1.0 + balancing_mode = "CONNECTION" } health_checks = [google_compute_health_check.default.self_link] @@ -808,6 +813,7 @@ resource "google_compute_region_backend_service" "foobar" { } iap { + enabled = true oauth2_client_id = "test" oauth2_client_secret = "test" } diff --git a/google/services/compute/resource_compute_region_instance_template.go b/google/services/compute/resource_compute_region_instance_template.go index dc400e7b627..1a46df16ce2 100644 --- a/google/services/compute/resource_compute_region_instance_template.go +++ b/google/services/compute/resource_compute_region_instance_template.go @@ -73,11 +73,11 @@ func ResourceComputeRegionInstanceTemplate() *schema.Resource { Description: `Creates a unique name beginning with the specified prefix. Conflicts with name.`, ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { // https://cloud.google.com/compute/docs/reference/latest/instanceTemplates#resource - // uuid is 26 characters, limit the prefix to 37. + // uuid is 9 characters, limit the prefix to 54. value := v.(string) - if len(value) > 37 { + if len(value) > 54 { errors = append(errors, fmt.Errorf( - "%q cannot be longer than 37 characters, name is limited to 63", k)) + "%q cannot be longer than 54 characters, name is limited to 63", k)) } return }, @@ -1085,7 +1085,12 @@ func resourceComputeRegionInstanceTemplateCreate(d *schema.ResourceData, meta in if v, ok := d.GetOk("name"); ok { itName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - itName = id.PrefixedUniqueId(v.(string)) + prefix := v.(string) + if len(prefix) > 37 { + itName = tpgresource.ReducedPrefixedUniqueId(prefix) + } else { + itName = id.PrefixedUniqueId(prefix) + } } else { itName = id.UniqueId() } diff --git a/google/services/compute/resource_compute_region_instance_template_test.go b/google/services/compute/resource_compute_region_instance_template_test.go index b12cdb198ac..8eda60df5f7 100644 --- a/google/services/compute/resource_compute_region_instance_template_test.go +++ b/google/services/compute/resource_compute_region_instance_template_test.go @@ -2205,6 +2205,7 @@ resource "google_project" "host_project" { project_id = "%s-host" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host_project" { @@ -2221,6 +2222,7 @@ resource "google_project" "service_project" { project_id = "%s-service" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "service_project" { diff --git a/google/services/compute/resource_compute_region_ssl_certificate.go b/google/services/compute/resource_compute_region_ssl_certificate.go index e1cb4b9223b..f330f74798c 100644 --- a/google/services/compute/resource_compute_region_ssl_certificate.go +++ b/google/services/compute/resource_compute_region_ssl_certificate.go @@ -133,11 +133,11 @@ If it is not provided, the provider region is used.`, Description: "Creates a unique name beginning with the specified prefix. Conflicts with name.", ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { // https://cloud.google.com/compute/docs/reference/latest/sslCertificates#resource - // uuid is 26 characters, limit the prefix to 37. + // uuid is 9 characters, limit the prefix to 54. value := v.(string) - if len(value) > 37 { + if len(value) > 54 { errors = append(errors, fmt.Errorf( - "%q cannot be longer than 37 characters, name is limited to 63", k)) + "%q cannot be longer than 54 characters, name is limited to 63", k)) } return }, @@ -456,7 +456,12 @@ func expandComputeRegionSslCertificateName(v interface{}, d tpgresource.Terrafor if v, ok := d.GetOk("name"); ok { certName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - certName = id.PrefixedUniqueId(v.(string)) + prefix := v.(string) + if len(prefix) > 37 { + certName = tpgresource.ReducedPrefixedUniqueId(prefix) + } else { + certName = id.PrefixedUniqueId(prefix) + } } else { certName = id.UniqueId() } diff --git a/google/services/compute/resource_compute_reservation_generated_test.go b/google/services/compute/resource_compute_reservation_generated_test.go index 73c9b9fe0ef..dd24563c009 100644 --- a/google/services/compute/resource_compute_reservation_generated_test.go +++ b/google/services/compute/resource_compute_reservation_generated_test.go @@ -109,6 +109,7 @@ resource "google_project" "owner_project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } @@ -122,6 +123,7 @@ resource "google_project" "guest_project" { project_id = "tf-test-2%{random_suffix}" name = "tf-test-2%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_organization_policy" "shared_reservation_org_policy" { diff --git a/google/services/compute/resource_compute_shared_reservation_update_test.go b/google/services/compute/resource_compute_shared_reservation_update_test.go index ba805ef4a86..455064ef35d 100644 --- a/google/services/compute/resource_compute_shared_reservation_update_test.go +++ b/google/services/compute/resource_compute_shared_reservation_update_test.go @@ -63,6 +63,7 @@ resource "google_project" "owner_project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } @@ -77,6 +78,7 @@ resource "google_project" "guest_project" { name = "tf-test-2%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "guest_project_second" { @@ -84,6 +86,7 @@ resource "google_project" "guest_project_second" { name = "tf-test-3%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "guest_project_third" { @@ -91,6 +94,7 @@ resource "google_project" "guest_project_third" { name = "tf-test-4%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_organization_policy" "shared_reservation_org_policy" { @@ -152,6 +156,7 @@ resource "google_project" "owner_project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -165,6 +170,7 @@ resource "google_project" "guest_project" { name = "tf-test-2%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "guest_project_second" { @@ -172,6 +178,7 @@ resource "google_project" "guest_project_second" { name = "tf-test-3%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "guest_project_third" { @@ -179,6 +186,7 @@ resource "google_project" "guest_project_third" { name = "tf-test-4%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_organization_policy" "shared_reservation_org_policy" { diff --git a/google/services/compute/resource_compute_shared_vpc_test.go b/google/services/compute/resource_compute_shared_vpc_test.go index 9dd954ef114..11489ad089c 100644 --- a/google/services/compute/resource_compute_shared_vpc_test.go +++ b/google/services/compute/resource_compute_shared_vpc_test.go @@ -119,6 +119,7 @@ resource "google_project" "host" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project" "service" { @@ -126,6 +127,7 @@ resource "google_project" "service" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host" { @@ -161,6 +163,7 @@ resource "google_project" "host" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project" "service" { @@ -168,6 +171,7 @@ resource "google_project" "service" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host" { @@ -189,6 +193,7 @@ resource "google_project" "host" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project" "service" { @@ -196,6 +201,7 @@ resource "google_project" "service" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host" { @@ -232,6 +238,7 @@ resource "google_project" "host" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project" "service" { @@ -239,6 +246,7 @@ resource "google_project" "service" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host" { diff --git a/google/services/compute/resource_compute_ssl_certificate.go b/google/services/compute/resource_compute_ssl_certificate.go index a8bde8eb789..24e9b790b94 100644 --- a/google/services/compute/resource_compute_ssl_certificate.go +++ b/google/services/compute/resource_compute_ssl_certificate.go @@ -116,11 +116,11 @@ These are in the same namespace as the managed SSL certificates.`, Description: "Creates a unique name beginning with the specified prefix. Conflicts with name.", ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { // https://cloud.google.com/compute/docs/reference/latest/sslCertificates#resource - // uuid is 26 characters, limit the prefix to 37. + // uuid is 9 characters, limit the prefix to 54. value := v.(string) - if len(value) > 37 { + if len(value) > 54 { errors = append(errors, fmt.Errorf( - "%q cannot be longer than 37 characters, name is limited to 63", k)) + "%q cannot be longer than 54 characters, name is limited to 63", k)) } return }, @@ -422,7 +422,12 @@ func expandComputeSslCertificateName(v interface{}, d tpgresource.TerraformResou if v, ok := d.GetOk("name"); ok { certName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - certName = id.PrefixedUniqueId(v.(string)) + prefix := v.(string) + if len(prefix) > 37 { + certName = tpgresource.ReducedPrefixedUniqueId(prefix) + } else { + certName = id.PrefixedUniqueId(prefix) + } } else { certName = id.UniqueId() } diff --git a/google/services/compute/resource_compute_subnetwork.go b/google/services/compute/resource_compute_subnetwork.go index 7cc61a6e4f7..64e2afcad4a 100644 --- a/google/services/compute/resource_compute_subnetwork.go +++ b/google/services/compute/resource_compute_subnetwork.go @@ -111,15 +111,6 @@ func ResourceComputeSubnetwork() *schema.Resource { ), Schema: map[string]*schema.Schema{ - "ip_cidr_range": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateIpCidrRange, - Description: `The range of internal addresses that are owned by this subnetwork. -Provide this property when you create the subnetwork. For example, -10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and -non-overlapping within a network. Only IPv4 is supported.`, - }, "name": { Type: schema.TypeString, Required: true, @@ -156,6 +147,17 @@ creation time.`, ForceNew: true, Description: `The range of external IPv6 addresses that are owned by this subnetwork.`, }, + "ip_cidr_range": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: verify.ValidateIpCidrRange, + Description: `The range of internal addresses that are owned by this subnetwork. +Provide this property when you create the subnetwork. For example, +10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and +non-overlapping within a network. Only IPv4 is supported. +Field is optional when 'reserved_internal_range' is defined, otherwise required.`, + }, "ipv6_access_type": { Type: schema.TypeString, Optional: true, @@ -262,6 +264,14 @@ If unspecified, the purpose defaults to 'PRIVATE_RFC_1918'.`, DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `The GCP region for this subnetwork.`, }, + "reserved_internal_range": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + Description: `The ID of the reserved internal range. Must be prefixed with 'networkconnectivity.googleapis.com' +E.g. 'networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}'`, + }, "role": { Type: schema.TypeString, Optional: true, @@ -273,10 +283,9 @@ An 'ACTIVE' subnetwork is one that is currently being used for Envoy-based load A 'BACKUP' subnetwork is one that is ready to be promoted to 'ACTIVE' or is currently draining. Possible values: ["ACTIVE", "BACKUP"]`, }, "secondary_ip_range": { - Type: schema.TypeList, - Computed: true, - Optional: true, - ConfigMode: schema.SchemaConfigModeAttr, + Type: schema.TypeList, + Computed: true, + Optional: true, Description: `An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange of the subnetwork. The alias IPs may belong @@ -287,15 +296,6 @@ breaking users during the 0.12 upgrade. To explicitly send a list of zero object set 'send_secondary_ip_range_if_empty = true'`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "ip_cidr_range": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateIpCidrRange, - Description: `The range of IP addresses belonging to this subnetwork secondary -range. Provide this property when you create the subnetwork. -Ranges must be unique and non-overlapping with all primary and -secondary IP ranges within a network. Only IPv4 is supported.`, - }, "range_name": { Type: schema.TypeString, Required: true, @@ -305,6 +305,24 @@ when adding an alias IP range to a VM instance. The name must be 1-63 characters long, and comply with RFC1035. The name must be unique within the subnetwork.`, }, + "ip_cidr_range": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: verify.ValidateIpCidrRange, + Description: `The range of IP addresses belonging to this subnetwork secondary +range. Provide this property when you create the subnetwork. +Ranges must be unique and non-overlapping with all primary and +secondary IP ranges within a network. Only IPv4 is supported. +Field is optional when 'reserved_internal_range' is defined, otherwise required.`, + }, + "reserved_internal_range": { + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + Description: `The ID of the reserved internal range. Must be prefixed with 'networkconnectivity.googleapis.com' +E.g. 'networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}'`, + }, }, }, }, @@ -430,6 +448,12 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e } else if v, ok := d.GetOkExists("ip_cidr_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipCidrRangeProp)) && (ok || !reflect.DeepEqual(v, ipCidrRangeProp)) { obj["ipCidrRange"] = ipCidrRangeProp } + reservedInternalRangeProp, err := expandComputeSubnetworkReservedInternalRange(d.Get("reserved_internal_range"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("reserved_internal_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(reservedInternalRangeProp)) && (ok || !reflect.DeepEqual(v, reservedInternalRangeProp)) { + obj["reservedInternalRange"] = reservedInternalRangeProp + } nameProp, err := expandComputeSubnetworkName(d.Get("name"), d, config) if err != nil { return err @@ -614,6 +638,9 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("ip_cidr_range", flattenComputeSubnetworkIpCidrRange(res["ipCidrRange"], d, config)); err != nil { return fmt.Errorf("Error reading Subnetwork: %s", err) } + if err := d.Set("reserved_internal_range", flattenComputeSubnetworkReservedInternalRange(res["reservedInternalRange"], d, config)); err != nil { + return fmt.Errorf("Error reading Subnetwork: %s", err) + } if err := d.Set("name", flattenComputeSubnetworkName(res["name"], d, config)); err != nil { return fmt.Errorf("Error reading Subnetwork: %s", err) } @@ -1227,6 +1254,13 @@ func flattenComputeSubnetworkIpCidrRange(v interface{}, d *schema.ResourceData, return v } +func flattenComputeSubnetworkReservedInternalRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return v + } + return tpgresource.ConvertSelfLinkToV1(v.(string)) +} + func flattenComputeSubnetworkName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1259,8 +1293,9 @@ func flattenComputeSubnetworkSecondaryIpRange(v interface{}, d *schema.ResourceD continue } transformed = append(transformed, map[string]interface{}{ - "range_name": flattenComputeSubnetworkSecondaryIpRangeRangeName(original["rangeName"], d, config), - "ip_cidr_range": flattenComputeSubnetworkSecondaryIpRangeIpCidrRange(original["ipCidrRange"], d, config), + "range_name": flattenComputeSubnetworkSecondaryIpRangeRangeName(original["rangeName"], d, config), + "ip_cidr_range": flattenComputeSubnetworkSecondaryIpRangeIpCidrRange(original["ipCidrRange"], d, config), + "reserved_internal_range": flattenComputeSubnetworkSecondaryIpRangeReservedInternalRange(original["reservedInternalRange"], d, config), }) } return transformed @@ -1273,6 +1308,13 @@ func flattenComputeSubnetworkSecondaryIpRangeIpCidrRange(v interface{}, d *schem return v } +func flattenComputeSubnetworkSecondaryIpRangeReservedInternalRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return v + } + return tpgresource.ConvertSelfLinkToV1(v.(string)) +} + func flattenComputeSubnetworkPrivateIpGoogleAccess(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1349,6 +1391,10 @@ func expandComputeSubnetworkIpCidrRange(v interface{}, d tpgresource.TerraformRe return v, nil } +func expandComputeSubnetworkReservedInternalRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandComputeSubnetworkName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1393,6 +1439,13 @@ func expandComputeSubnetworkSecondaryIpRange(v interface{}, d tpgresource.Terraf transformed["ipCidrRange"] = transformedIpCidrRange } + transformedReservedInternalRange, err := expandComputeSubnetworkSecondaryIpRangeReservedInternalRange(original["reserved_internal_range"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedReservedInternalRange); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["reservedInternalRange"] = transformedReservedInternalRange + } + req = append(req, transformed) } return req, nil @@ -1406,6 +1459,10 @@ func expandComputeSubnetworkSecondaryIpRangeIpCidrRange(v interface{}, d tpgreso return v, nil } +func expandComputeSubnetworkSecondaryIpRangeReservedInternalRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandComputeSubnetworkPrivateIpGoogleAccess(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/google/services/compute/resource_compute_subnetwork_generated_test.go b/google/services/compute/resource_compute_subnetwork_generated_test.go index fee2209e62a..3cea6927a67 100644 --- a/google/services/compute/resource_compute_subnetwork_generated_test.go +++ b/google/services/compute/resource_compute_subnetwork_generated_test.go @@ -49,7 +49,7 @@ func TestAccComputeSubnetwork_subnetworkBasicExample(t *testing.T) { ResourceName: "google_compute_subnetwork.network-with-private-secondary-ip-ranges", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) @@ -94,7 +94,7 @@ func TestAccComputeSubnetwork_subnetworkLoggingConfigExample(t *testing.T) { ResourceName: "google_compute_subnetwork.subnet-with-logging", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) @@ -141,7 +141,7 @@ func TestAccComputeSubnetwork_subnetworkIpv6Example(t *testing.T) { ResourceName: "google_compute_subnetwork.subnetwork-ipv6", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) @@ -187,7 +187,7 @@ func TestAccComputeSubnetwork_subnetworkInternalIpv6Example(t *testing.T) { ResourceName: "google_compute_subnetwork.subnetwork-internal-ipv6", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) diff --git a/google/services/compute/resource_compute_subnetwork_test.go b/google/services/compute/resource_compute_subnetwork_test.go index 59ad611383b..90ea7cb4825 100644 --- a/google/services/compute/resource_compute_subnetwork_test.go +++ b/google/services/compute/resource_compute_subnetwork_test.go @@ -185,14 +185,6 @@ func TestAccComputeSubnetwork_secondaryIpRanges(t *testing.T) { testAccCheckComputeSubnetworkHasSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update2", "192.168.11.0/24"), ), }, - { - Config: testAccComputeSubnetwork_secondaryIpRanges_update4(cnName, subnetworkName), - Check: resource.ComposeTestCheckFunc( - testAccCheckComputeSubnetworkExists(t, "google_compute_subnetwork.network-with-private-secondary-ip-ranges", &subnetwork), - testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update1", "192.168.10.0/24"), - testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update2", "192.168.11.0/24"), - ), - }, { Config: testAccComputeSubnetwork_secondaryIpRanges_update1(cnName, subnetworkName), Check: resource.ComposeTestCheckFunc( @@ -241,12 +233,6 @@ func TestAccComputeSubnetwork_secondaryIpRanges_sendEmpty(t *testing.T) { testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update1", "192.168.10.0/24"), ), }, - // Check that empty block secondary_ip_range = [] is not different - { - Config: testAccComputeSubnetwork_sendEmpty_emptyBlock(cnName, subnetworkName, "true"), - PlanOnly: true, - ExpectNonEmptyPlan: false, - }, // Apply two secondary_ip_range { Config: testAccComputeSubnetwork_sendEmpty_double(cnName, subnetworkName, "true"), @@ -279,14 +265,6 @@ func TestAccComputeSubnetwork_secondaryIpRanges_sendEmpty(t *testing.T) { PlanOnly: true, ExpectNonEmptyPlan: false, }, - // Remove with empty block [] - { - Config: testAccComputeSubnetwork_sendEmpty_emptyBlock(cnName, subnetworkName, "true"), - Check: resource.ComposeTestCheckFunc( - testAccCheckComputeSubnetworkExists(t, "google_compute_subnetwork.network-with-private-secondary-ip-ranges", &subnetwork), - testAccCheckComputeSubnetworkHasNotSecondaryIpRange(&subnetwork, "tf-test-secondary-range-update1", "192.168.10.0/24"), - ), - }, }, }) } @@ -688,23 +666,6 @@ resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" `, cnName, subnetworkName) } -func testAccComputeSubnetwork_secondaryIpRanges_update4(cnName, subnetworkName string) string { - return fmt.Sprintf(` -resource "google_compute_network" "custom-test" { - name = "%s" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" { - name = "%s" - ip_cidr_range = "10.2.0.0/16" - region = "us-central1" - network = google_compute_network.custom-test.self_link - secondary_ip_range = [] -} -`, cnName, subnetworkName) -} - func testAccComputeSubnetwork_sendEmpty_removed(cnName, subnetworkName, sendEmpty string) string { return fmt.Sprintf(` resource "google_compute_network" "custom-test" { @@ -722,24 +683,6 @@ resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" `, cnName, subnetworkName, sendEmpty) } -func testAccComputeSubnetwork_sendEmpty_emptyBlock(cnName, subnetworkName, sendEmpty string) string { - return fmt.Sprintf(` -resource "google_compute_network" "custom-test" { - name = "%s" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" { - name = "%s" - ip_cidr_range = "10.2.0.0/16" - region = "us-central1" - network = google_compute_network.custom-test.self_link - secondary_ip_range = [] - send_secondary_ip_range_if_empty = "%s" -} -`, cnName, subnetworkName, sendEmpty) -} - func testAccComputeSubnetwork_sendEmpty_single(cnName, subnetworkName, sendEmpty string) string { return fmt.Sprintf(` resource "google_compute_network" "custom-test" { diff --git a/google/services/compute/resource_usage_export_bucket_test.go b/google/services/compute/resource_usage_export_bucket_test.go index 4f32ea73935..1a710de6e29 100644 --- a/google/services/compute/resource_usage_export_bucket_test.go +++ b/google/services/compute/resource_usage_export_bucket_test.go @@ -41,6 +41,7 @@ resource "google_project" "base" { name = "Export Bucket Base" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "service" { diff --git a/google/services/container/data_source_google_container_cluster.go b/google/services/container/data_source_google_container_cluster.go index 93f9758e99b..b46db355e85 100644 --- a/google/services/container/data_source_google_container_cluster.go +++ b/google/services/container/data_source_google_container_cluster.go @@ -49,6 +49,15 @@ func datasourceContainerClusterRead(d *schema.ResourceData, meta interface{}) er return err } + // Sets the "resource_labels" field and "terraform_labels" with the value of the field "effective_labels". + effectiveLabels := d.Get("effective_labels") + if err := d.Set("resource_labels", effectiveLabels); err != nil { + return fmt.Errorf("Error setting labels in data source: %s", err) + } + if err := d.Set("terraform_labels", effectiveLabels); err != nil { + return fmt.Errorf("Error setting terraform_labels in data source: %s", err) + } + if d.Id() == "" { return fmt.Errorf("%s not found", id) } diff --git a/google/services/container/data_source_google_container_cluster_test.go b/google/services/container/data_source_google_container_cluster_test.go index 753a1ee3314..6965c510f87 100644 --- a/google/services/container/data_source_google_container_cluster_test.go +++ b/google/services/container/data_source_google_container_cluster_test.go @@ -62,6 +62,7 @@ func TestAccContainerClusterDatasource_regional(t *testing.T) { "enable_tpu": {}, "pod_security_policy_config.#": {}, "deletion_protection": {}, + "resource_labels": {}, }, ), ), @@ -98,7 +99,9 @@ resource "google_container_cluster" "kubes" { deletion_protection = false network = "%s" subnetwork = "%s" - + resource_labels = { + created-by = "terraform" + } } data "google_container_cluster" "kubes" { diff --git a/google/services/container/node_config.go b/google/services/container/node_config.go index 64729fc2821..46ca6d5a62b 100644 --- a/google/services/container/node_config.go +++ b/google/services/container/node_config.go @@ -128,13 +128,10 @@ func schemaNodeConfig() *schema.Schema { }, "guest_accelerator": { - Type: schema.TypeList, - Optional: true, - Computed: true, - ForceNew: true, - // Legacy config mode allows removing GPU's from an existing resource - // See https://www.terraform.io/docs/configuration/attr-as-blocks.html - ConfigMode: schema.SchemaConfigModeAttr, + Type: schema.TypeList, + Optional: true, + Computed: true, + ForceNew: true, Description: `List of the type and count of accelerator cards attached to the instance.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -157,7 +154,6 @@ func schemaNodeConfig() *schema.Schema { Optional: true, Computed: true, ForceNew: true, - ConfigMode: schema.SchemaConfigModeAttr, Description: `Configuration for auto installation of GPU driver.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -182,7 +178,6 @@ func schemaNodeConfig() *schema.Schema { MaxItems: 1, Optional: true, ForceNew: true, - ConfigMode: schema.SchemaConfigModeAttr, Description: `Configuration for GPU sharing.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/google/services/container/resource_container_cluster.go b/google/services/container/resource_container_cluster.go index 008d57c48e9..22b5b52ee47 100644 --- a/google/services/container/resource_container_cluster.go +++ b/google/services/container/resource_container_cluster.go @@ -205,6 +205,7 @@ func ResourceContainerCluster() *schema.Resource { containerClusterSurgeSettingsCustomizeDiff, containerClusterEnableK8sBetaApisCustomizeDiff, containerClusterNodeVersionCustomizeDiff, + tpgresource.SetDiffForLabelsWithCustomizedName("resource_labels"), ), Timeouts: &schema.ResourceTimeout{ @@ -1146,20 +1147,9 @@ func ResourceContainerCluster() *schema.Resource { Description: `Whether or not the advanced datapath metrics are enabled.`, }, "enable_relay": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether or not Relay is enabled.`, - Default: false, - ConflictsWith: []string{"monitoring_config.0.advanced_datapath_observability_config.0.relay_mode"}, - }, - "relay_mode": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: "Deprecated in favor of enable_relay field. Remove this attribute's configuration as this field will be removed in the next major release and enable_relay will become a required field.", - Description: `Mode used to make Relay available.`, - ValidateFunc: validation.StringInSlice([]string{"DISABLED", "INTERNAL_VPC_LB", "EXTERNAL_LB"}, false), - ConflictsWith: []string{"monitoring_config.0.advanced_datapath_observability_config.0.enable_relay"}, + Type: schema.TypeBool, + Required: true, + Description: `Whether or not Relay is enabled.`, }, }, }, @@ -1635,10 +1625,25 @@ func ResourceContainerCluster() *schema.Resource { }, "resource_labels": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: `The GCE resource labels (a map of key/value pairs) to be applied to the cluster. + + **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. + Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + }, + "terraform_labels": { Type: schema.TypeMap, - Optional: true, + Computed: true, + Description: `The combination of labels configured directly on the resource and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, Elem: &schema.Schema{Type: schema.TypeString}, - Description: `The GCE resource labels (a map of key/value pairs) to be applied to the cluster.`, }, "label_fingerprint": { @@ -2002,12 +2007,6 @@ func ResourceContainerCluster() *schema.Resource { // One quirk with this approach is that configs with mixed count=0 and count>0 accelerator blocks will // show a confusing diff if one of there are config changes that result in a legitimate diff as the count=0 // blocks will not be in state. -// -// This could also be modelled by setting `guest_accelerator = []` in the config. However since the -// previous syntax requires that schema.SchemaConfigModeAttr is set on the field it is advisable that -// we have a work around for removing guest accelerators. Also Terraform 0.11 cannot use dynamic blocks -// so this isn't a solution for module authors who want to dynamically omit guest accelerators -// See https://github.com/hashicorp/terraform-provider-google/issues/3786 func resourceNodeConfigEmptyGuestAccelerator(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error { old, new := diff.GetChange("node_config.0.guest_accelerator") oList := old.([]interface{}) @@ -2139,7 +2138,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er MasterAuth: expandMasterAuth(d.Get("master_auth")), NotificationConfig: expandNotificationConfig(d.Get("notification_config")), ConfidentialNodes: expandConfidentialNodes(d.Get("confidential_nodes")), - ResourceLabels: tpgresource.ExpandStringMap(d, "resource_labels"), + ResourceLabels: tpgresource.ExpandStringMap(d, "effective_labels"), NodePoolAutoConfig: expandNodePoolAutoConfig(d.Get("node_pool_auto_config")), CostManagementConfig: expandCostManagementConfig(d.Get("cost_management_config")), EnableK8sBetaApis: expandEnableK8sBetaApis(d.Get("enable_k8s_beta_apis"), nil), @@ -2723,8 +2722,14 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro return err } - if err := d.Set("resource_labels", cluster.ResourceLabels); err != nil { - return fmt.Errorf("Error setting resource_labels: %s", err) + if err := tpgresource.SetLabels(cluster.ResourceLabels, d, "resource_labels"); err != nil { + return fmt.Errorf("Error setting labels: %s", err) + } + if err := tpgresource.SetLabels(cluster.ResourceLabels, d, "terraform_labels"); err != nil { + return fmt.Errorf("Error setting terraform_labels: %s", err) + } + if err := d.Set("effective_labels", cluster.ResourceLabels); err != nil { + return fmt.Errorf("Error setting effective_labels: %s", err) } if err := d.Set("label_fingerprint", cluster.LabelFingerprint); err != nil { return fmt.Errorf("Error setting label_fingerprint: %s", err) @@ -3728,8 +3733,8 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er log.Printf("[INFO] GKE cluster %s monitoring config has been updated", d.Id()) } - if d.HasChange("resource_labels") { - resourceLabels := d.Get("resource_labels").(map[string]interface{}) + if d.HasChange("effective_labels") { + resourceLabels := d.Get("effective_labels").(map[string]interface{}) labelFingerprint := d.Get("label_fingerprint").(string) req := &container.SetLabelsRequest{ ResourceLabels: tpgresource.ConvertStringMap(resourceLabels), @@ -5012,21 +5017,10 @@ func expandMonitoringConfig(configured interface{}) *container.MonitoringConfig if v, ok := config["advanced_datapath_observability_config"]; ok && len(v.([]interface{})) > 0 { advanced_datapath_observability_config := v.([]interface{})[0].(map[string]interface{}) - mc.AdvancedDatapathObservabilityConfig = &container.AdvancedDatapathObservabilityConfig{ - EnableMetrics: advanced_datapath_observability_config["enable_metrics"].(bool), - } - - enable_relay := advanced_datapath_observability_config["enable_relay"].(bool) - relay_mode := advanced_datapath_observability_config["relay_mode"].(string) - if enable_relay { - mc.AdvancedDatapathObservabilityConfig.EnableRelay = enable_relay - } else if relay_mode == "INTERNAL_VPC_LB" || relay_mode == "EXTERNAL_LB" { - mc.AdvancedDatapathObservabilityConfig.RelayMode = relay_mode - } else { - mc.AdvancedDatapathObservabilityConfig.EnableRelay = enable_relay - mc.AdvancedDatapathObservabilityConfig.RelayMode = "DISABLED" - mc.AdvancedDatapathObservabilityConfig.ForceSendFields = []string{"EnableRelay"} + EnableMetrics: advanced_datapath_observability_config["enable_metrics"].(bool), + EnableRelay: advanced_datapath_observability_config["enable_relay"].(bool), + ForceSendFields: []string{"EnableRelay"}, } } @@ -5819,29 +5813,10 @@ func flattenAdvancedDatapathObservabilityConfig(c *container.AdvancedDatapathObs return nil } - if c.EnableRelay { - return []map[string]interface{}{ - { - "enable_metrics": c.EnableMetrics, - "enable_relay": c.EnableRelay, - }, - } - } - - if c.RelayMode == "INTERNAL_VPC_LB" || c.RelayMode == "EXTERNAL_LB" { - return []map[string]interface{}{ - { - "enable_metrics": c.EnableMetrics, - "relay_mode": c.RelayMode, - }, - } - } - return []map[string]interface{}{ { "enable_metrics": c.EnableMetrics, - "enable_relay": false, - "relay_mode": "DISABLED", + "enable_relay": c.EnableRelay, }, } } diff --git a/google/services/container/resource_container_cluster_test.go b/google/services/container/resource_container_cluster_test.go index c5f20b0be1b..51e640d2e0d 100644 --- a/google/services/container/resource_container_cluster_test.go +++ b/google/services/container/resource_container_cluster_test.go @@ -150,7 +150,7 @@ func TestAccContainerCluster_misc(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection"}, + ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection", "resource_labels", "terraform_labels"}, }, { Config: testAccContainerCluster_misc_update(clusterName, networkName, subnetworkName), @@ -159,7 +159,7 @@ func TestAccContainerCluster_misc(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection"}, + ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection", "resource_labels", "terraform_labels"}, }, }, }) @@ -3032,24 +3032,6 @@ func TestAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityCo ImportStateVerify: true, ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"}, }, - { - Config: testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabledOld(clusterName), - }, - { - ResourceName: "google_container_cluster.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"}, - }, - { - Config: testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigDisabledOld(clusterName), - }, - { - ResourceName: "google_container_cluster.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"}, - }, }, }) } @@ -8594,56 +8576,6 @@ resource "google_container_cluster" "primary" { `, name, name) } -func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabledOld(name string) string { - return fmt.Sprintf(` -resource "google_compute_network" "container_network" { - name = "%s-nw" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "container_subnetwork" { - name = google_compute_network.container_network.name - network = google_compute_network.container_network.name - ip_cidr_range = "10.0.36.0/24" - region = "us-central1" - private_ip_google_access = true - - secondary_ip_range { - range_name = "services-range" - ip_cidr_range = "192.168.1.0/24" - } - - secondary_ip_range { - range_name = "pod-ranges" - ip_cidr_range = "192.168.64.0/22" - } -} - -resource "google_container_cluster" "primary" { - name = "%s" - location = "us-central1-a" - initial_node_count = 1 - datapath_provider = "ADVANCED_DATAPATH" - - network = google_compute_network.container_network.name - subnetwork = google_compute_subnetwork.container_subnetwork.name - ip_allocation_policy { - cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name - services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name - } - - monitoring_config { - enable_components = [] - advanced_datapath_observability_config { - enable_metrics = true - relay_mode = "INTERNAL_VPC_LB" - } - } - deletion_protection = false -} -`, name, name) -} - func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigDisabled(name string) string { return fmt.Sprintf(` resource "google_compute_network" "container_network" { @@ -8694,56 +8626,6 @@ resource "google_container_cluster" "primary" { `, name, name) } -func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigDisabledOld(name string) string { - return fmt.Sprintf(` -resource "google_compute_network" "container_network" { - name = "%s-nw" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "container_subnetwork" { - name = google_compute_network.container_network.name - network = google_compute_network.container_network.name - ip_cidr_range = "10.0.36.0/24" - region = "us-central1" - private_ip_google_access = true - - secondary_ip_range { - range_name = "services-range" - ip_cidr_range = "192.168.1.0/24" - } - - secondary_ip_range { - range_name = "pod-ranges" - ip_cidr_range = "192.168.64.0/22" - } -} - -resource "google_container_cluster" "primary" { - name = "%s" - location = "us-central1-a" - initial_node_count = 1 - datapath_provider = "ADVANCED_DATAPATH" - - network = google_compute_network.container_network.name - subnetwork = google_compute_subnetwork.container_subnetwork.name - ip_allocation_policy { - cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name - services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name - } - - monitoring_config { - enable_components = [] - advanced_datapath_observability_config { - enable_metrics = false - relay_mode = "DISABLED" - } - } - deletion_protection = false -} -`, name, name) -} - func testAccContainerCluster_withSoleTenantGroup(name, networkName, subnetworkName string) string { return fmt.Sprintf(` resource "google_compute_node_template" "soletenant-tmpl" { @@ -9638,6 +9520,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)) @@ -9918,3 +9801,158 @@ resource "google_container_cluster" "primary" { } `, secretID, clusterName, networkName, subnetworkName) } + +func TestAccContainerCluster_withProviderDefaultLabels(t *testing.T) { + // The test failed if VCR testing is enabled, because the cached provider config is used. + // With the cached provider config, any changes in the provider default labels will not be applied. + acctest.SkipIfVcr(t) + t.Parallel() + + clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10)) + networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster") + subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckContainerClusterDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccContainerCluster_withProviderDefaultLabels(clusterName, networkName, subnetworkName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "1"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.created-by", "terraform"), + + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "2"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "default_value1"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.created-by", "terraform"), + + resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "2"), + ), + }, + { + ResourceName: "google_container_cluster.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection", "resource_labels", "terraform_labels"}, + }, + { + Config: testAccContainerCluster_resourceLabelsOverridesProviderDefaultLabels(clusterName, networkName, subnetworkName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "2"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.created-by", "terraform"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "value1"), + + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "2"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "value1"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.created-by", "terraform"), + + resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "2"), + ), + }, + { + ResourceName: "google_container_cluster.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection", "resource_labels", "terraform_labels"}, + }, + { + Config: testAccContainerCluster_moveResourceLabelToProviderDefaultLabels(clusterName, networkName, subnetworkName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "0"), + + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "2"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "default_value1"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.created-by", "terraform"), + + resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "2"), + ), + }, + { + ResourceName: "google_container_cluster.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection", "resource_labels", "terraform_labels"}, + }, + { + Config: testAccContainerCluster_basic(clusterName, networkName, subnetworkName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "0"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "0"), + resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "0"), + ), + }, + { + ResourceName: "google_container_cluster.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"remove_default_node_pool", "deletion_protection", "resource_labels", "terraform_labels"}, + }, + }, + }) +} + +func testAccContainerCluster_withProviderDefaultLabels(name, networkName, subnetworkName string) string { + return fmt.Sprintf(` +provider "google" { + default_labels = { + default_key1 = "default_value1" + } +} + +resource "google_container_cluster" "primary" { + name = "%s" + location = "us-central1-a" + initial_node_count = 1 + deletion_protection = false + network = "%s" + subnetwork = "%s" + resource_labels = { + created-by = "terraform" + } +} +`, name, networkName, subnetworkName) +} + +func testAccContainerCluster_resourceLabelsOverridesProviderDefaultLabels(name, networkName, subnetworkName string) string { + return fmt.Sprintf(` +provider "google" { + default_labels = { + default_key1 = "default_value1" + } +} + +resource "google_container_cluster" "primary" { + name = "%s" + location = "us-central1-a" + initial_node_count = 1 + deletion_protection = false + network = "%s" + subnetwork = "%s" + resource_labels = { + created-by = "terraform" + default_key1 = "value1" + } +} +`, name, networkName, subnetworkName) +} + +func testAccContainerCluster_moveResourceLabelToProviderDefaultLabels(name, networkName, subnetworkName string) string { + return fmt.Sprintf(` +provider "google" { + default_labels = { + default_key1 = "default_value1" + created-by = "terraform" + } +} + +resource "google_container_cluster" "primary" { + name = "%s" + location = "us-central1-a" + initial_node_count = 1 + deletion_protection = false + network = "%s" + subnetwork = "%s" +} +`, name, networkName, subnetworkName) +} diff --git a/google/services/container/resource_container_node_pool_test.go b/google/services/container/resource_container_node_pool_test.go index b83cff10fac..5be46c41df4 100644 --- a/google/services/container/resource_container_node_pool_test.go +++ b/google/services/container/resource_container_node_pool_test.go @@ -1228,45 +1228,6 @@ func TestAccContainerNodePool_regionalClusters(t *testing.T) { }) } -func TestAccContainerNodePool_012_ConfigModeAttr(t *testing.T) { - t.Parallel() - - cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10)) - np := fmt.Sprintf("tf-test-nodepool-%s", acctest.RandString(t, 10)) - networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster") - subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName) - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckContainerNodePoolDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccContainerNodePool_012_ConfigModeAttr1(cluster, np, networkName, subnetworkName), - }, - { - ResourceName: "google_container_node_pool.np", - ImportState: true, - ImportStateVerify: true, - }, - { - Config: testAccContainerNodePool_012_ConfigModeAttr2(cluster, np, networkName, subnetworkName), - }, - { - ResourceName: "google_container_node_pool.np", - ImportState: true, - ImportStateVerify: true, - }, - { - // Test guest_accelerator.count = 0 is the same as guest_accelerator = [] - Config: testAccContainerNodePool_EmptyGuestAccelerator(cluster, np, networkName, subnetworkName), - ExpectNonEmptyPlan: false, - PlanOnly: true, - }, - }, - }) -} - func TestAccContainerNodePool_EmptyGuestAccelerator(t *testing.T) { t.Parallel() @@ -3544,59 +3505,6 @@ resource "google_container_node_pool" "np" { `, cluster, networkName, subnetworkName, np) } -func testAccContainerNodePool_012_ConfigModeAttr1(cluster, np, networkName, subnetworkName string) string { - return fmt.Sprintf(` -resource "google_container_cluster" "cluster" { - name = "%s" - location = "us-central1-f" - initial_node_count = 3 - deletion_protection = false - network = "%s" - subnetwork = "%s" -} - -resource "google_container_node_pool" "np" { - name = "%s" - location = "us-central1-f" - cluster = google_container_cluster.cluster.name - initial_node_count = 1 - - node_config { - guest_accelerator { - count = 1 - type = "nvidia-tesla-t4" - } - machine_type = "n1-highmem-4" - } -} -`, cluster, networkName, subnetworkName, np) -} - -func testAccContainerNodePool_012_ConfigModeAttr2(cluster, np, networkName, subnetworkName string) string { - return fmt.Sprintf(` -resource "google_container_cluster" "cluster" { - name = "%s" - location = "us-central1-f" - initial_node_count = 3 - deletion_protection = false - network = "%s" - subnetwork = "%s" -} - -resource "google_container_node_pool" "np" { - name = "%s" - location = "us-central1-f" - cluster = google_container_cluster.cluster.name - initial_node_count = 1 - - node_config { - guest_accelerator = [] - machine_type = "n1-highmem-4" - } -} -`, cluster, networkName, subnetworkName, np) -} - func testAccContainerNodePool_EmptyGuestAccelerator(cluster, np, networkName, subnetworkName string) string { return fmt.Sprintf(` resource "google_container_cluster" "cluster" { @@ -4611,6 +4519,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/google/services/corebilling/resource_billing_project_info.go b/google/services/corebilling/resource_billing_project_info.go index 18f54ab2854..d7280be0c90 100644 --- a/google/services/corebilling/resource_billing_project_info.go +++ b/google/services/corebilling/resource_billing_project_info.go @@ -127,7 +127,7 @@ func resourceCoreBillingProjectInfoCreate(d *schema.ResourceData, meta interface } // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/billingInfo") + id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") if err != nil { return fmt.Errorf("Error constructing id: %s", err) } @@ -318,7 +318,7 @@ func resourceCoreBillingProjectInfoImport(d *schema.ResourceData, meta interface } // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/billingInfo") + id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") if err != nil { return nil, fmt.Errorf("Error constructing id: %s", err) } diff --git a/google/services/corebilling/resource_billing_project_info_generated_test.go b/google/services/corebilling/resource_billing_project_info_generated_test.go index 577db4ce359..4bd3af370af 100644 --- a/google/services/corebilling/resource_billing_project_info_generated_test.go +++ b/google/services/corebilling/resource_billing_project_info_generated_test.go @@ -58,6 +58,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" lifecycle { ignore_changes = [billing_account] } diff --git a/google/services/corebilling/resource_google_billing_project_info_test.go b/google/services/corebilling/resource_google_billing_project_info_test.go index fbb5ef9c58c..7dc1b4b888c 100644 --- a/google/services/corebilling/resource_google_billing_project_info_test.go +++ b/google/services/corebilling/resource_google_billing_project_info_test.go @@ -61,6 +61,7 @@ resource "google_project" "project" { project_id = "%s" name = "%[1]s" org_id = "%s" + deletion_policy = "DELETE" lifecycle { ignore_changes = [billing_account] } diff --git a/google/services/dataplex/resource_dataplex_datascan.go b/google/services/dataplex/resource_dataplex_datascan.go index 4d830c0954c..9119e5497a2 100644 --- a/google/services/dataplex/resource_dataplex_datascan.go +++ b/google/services/dataplex/resource_dataplex_datascan.go @@ -51,7 +51,7 @@ func ResourceDataplexDatascan() *schema.Resource { }, CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, + tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, ), diff --git a/google/services/dataplex/resource_dataplex_task.go b/google/services/dataplex/resource_dataplex_task.go index 2e1599dbd03..a9a3c3558ac 100644 --- a/google/services/dataplex/resource_dataplex_task.go +++ b/google/services/dataplex/resource_dataplex_task.go @@ -51,7 +51,7 @@ func ResourceDataplexTask() *schema.Resource { }, CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, + tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, ), diff --git a/google/services/dataproc/resource_dataproc_cluster.go b/google/services/dataproc/resource_dataproc_cluster.go index a620bb03332..f9af2f2e318 100644 --- a/google/services/dataproc/resource_dataproc_cluster.go +++ b/google/services/dataproc/resource_dataproc_cluster.go @@ -189,7 +189,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/google/services/datastore/datastore_operation.go b/google/services/datastore/datastore_operation.go deleted file mode 100644 index 81f2507266c..00000000000 --- a/google/services/datastore/datastore_operation.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package datastore - -import ( - "encoding/json" - "errors" - "fmt" - "time" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -type DatastoreOperationWaiter struct { - Config *transport_tpg.Config - UserAgent string - Project string - tpgresource.CommonOperationWaiter -} - -func (w *DatastoreOperationWaiter) QueryOp() (interface{}, error) { - if w == nil { - return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") - } - // Returns the proper get. - url := fmt.Sprintf("%s%s", w.Config.DatastoreBasePath, w.CommonOperationWaiter.Op.Name) - - return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: w.Config, - Method: "GET", - Project: w.Project, - RawURL: url, - UserAgent: w.UserAgent, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, - }) -} - -func createDatastoreWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*DatastoreOperationWaiter, error) { - w := &DatastoreOperationWaiter{ - Config: config, - UserAgent: userAgent, - Project: project, - } - if err := w.CommonOperationWaiter.SetOp(op); err != nil { - return nil, err - } - return w, nil -} - -// nolint: deadcode,unused -func DatastoreOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { - w, err := createDatastoreWaiter(config, op, project, activity, userAgent) - if err != nil { - return err - } - if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil { - return err - } - rawResponse := []byte(w.CommonOperationWaiter.Op.Response) - if len(rawResponse) == 0 { - return errors.New("`resource` not set in operation response") - } - return json.Unmarshal(rawResponse, response) -} - -func DatastoreOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { - if val, ok := op["name"]; !ok || val == "" { - // This was a synchronous call - there is no operation to wait for. - return nil - } - w, err := createDatastoreWaiter(config, op, project, activity, userAgent) - if err != nil { - // If w is nil, the op was synchronous. - return err - } - return tpgresource.OperationWait(w, activity, timeout, config.PollInterval) -} diff --git a/google/services/datastore/resource_datastore_index.go b/google/services/datastore/resource_datastore_index.go deleted file mode 100644 index 7cb76c05ca7..00000000000 --- a/google/services/datastore/resource_datastore_index.go +++ /dev/null @@ -1,427 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package datastore - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceDatastoreIndex() *schema.Resource { - return &schema.Resource{ - Create: resourceDatastoreIndexCreate, - Read: resourceDatastoreIndexRead, - Delete: resourceDatastoreIndexDelete, - - Importer: &schema.ResourceImporter{ - State: resourceDatastoreIndexImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - DeprecationMessage: "`datastore_index` is deprecated and will be removed in a future major release. Use `firestore_index` instead; this resource is deprecated because it only supports the (default) database. `firestore_index` supports both Firestore in Datastore Mode and Firestore Native indexes and supports both named and the (default) database.", - - Schema: map[string]*schema.Schema{ - "kind": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The entity kind which the index applies to.`, - }, - "ancestor": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"NONE", "ALL_ANCESTORS", ""}), - Description: `Policy for including ancestors in the index. Default value: "NONE" Possible values: ["NONE", "ALL_ANCESTORS"]`, - Default: "NONE", - }, - "properties": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `An ordered list of properties to index on.`, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "direction": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"ASCENDING", "DESCENDING"}), - Description: `The direction the index should optimize for sorting. Possible values: ["ASCENDING", "DESCENDING"]`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The property name to index.`, - }, - }, - }, - }, - "index_id": { - Type: schema.TypeString, - Computed: true, - Description: `The index id.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceDatastoreIndexCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - kindProp, err := expandDatastoreIndexKind(d.Get("kind"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("kind"); !tpgresource.IsEmptyValue(reflect.ValueOf(kindProp)) && (ok || !reflect.DeepEqual(v, kindProp)) { - obj["kind"] = kindProp - } - ancestorProp, err := expandDatastoreIndexAncestor(d.Get("ancestor"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ancestor"); !tpgresource.IsEmptyValue(reflect.ValueOf(ancestorProp)) && (ok || !reflect.DeepEqual(v, ancestorProp)) { - obj["ancestor"] = ancestorProp - } - propertiesProp, err := expandDatastoreIndexProperties(d.Get("properties"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("properties"); !tpgresource.IsEmptyValue(reflect.ValueOf(propertiesProp)) && (ok || !reflect.DeepEqual(v, propertiesProp)) { - obj["properties"] = propertiesProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DatastoreBasePath}}projects/{{project}}/indexes") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new Index: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Index: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, - }) - if err != nil { - return fmt.Errorf("Error creating Index: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/indexes/{{index_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // Use the resource in the operation response to populate - // identity fields and d.Id() before read - var opRes map[string]interface{} - err = DatastoreOperationWaitTimeWithResponse( - config, res, &opRes, project, "Creating Index", userAgent, - d.Timeout(schema.TimeoutCreate)) - if err != nil { - // The resource didn't actually create - d.SetId("") - - return fmt.Errorf("Error waiting to create Index: %s", err) - } - - if err := d.Set("index_id", flattenDatastoreIndexIndexId(opRes["indexId"], d, config)); err != nil { - return err - } - - // This may have caused the ID to update - update it if so. - id, err = tpgresource.ReplaceVars(d, config, "projects/{{project}}/indexes/{{index_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating Index %q: %#v", d.Id(), res) - - return resourceDatastoreIndexRead(d, meta) -} - -func resourceDatastoreIndexRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DatastoreBasePath}}projects/{{project}}/indexes/{{index_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Index: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DatastoreIndex %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading Index: %s", err) - } - - if err := d.Set("index_id", flattenDatastoreIndexIndexId(res["indexId"], d, config)); err != nil { - return fmt.Errorf("Error reading Index: %s", err) - } - if err := d.Set("kind", flattenDatastoreIndexKind(res["kind"], d, config)); err != nil { - return fmt.Errorf("Error reading Index: %s", err) - } - if err := d.Set("ancestor", flattenDatastoreIndexAncestor(res["ancestor"], d, config)); err != nil { - return fmt.Errorf("Error reading Index: %s", err) - } - if err := d.Set("properties", flattenDatastoreIndexProperties(res["properties"], d, config)); err != nil { - return fmt.Errorf("Error reading Index: %s", err) - } - - return nil -} - -func resourceDatastoreIndexDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Index: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{DatastoreBasePath}}projects/{{project}}/indexes/{{index_id}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting Index %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "Index") - } - - err = DatastoreOperationWaitTime( - config, res, project, "Deleting Index", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting Index %q: %#v", d.Id(), res) - return nil -} - -func resourceDatastoreIndexImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/indexes/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/indexes/{{index_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenDatastoreIndexIndexId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDatastoreIndexKind(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDatastoreIndexAncestor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDatastoreIndexProperties(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenDatastoreIndexPropertiesName(original["name"], d, config), - "direction": flattenDatastoreIndexPropertiesDirection(original["direction"], d, config), - }) - } - return transformed -} -func flattenDatastoreIndexPropertiesName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDatastoreIndexPropertiesDirection(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandDatastoreIndexKind(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDatastoreIndexAncestor(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDatastoreIndexProperties(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandDatastoreIndexPropertiesName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedDirection, err := expandDatastoreIndexPropertiesDirection(original["direction"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDirection); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["direction"] = transformedDirection - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDatastoreIndexPropertiesName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDatastoreIndexPropertiesDirection(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/google/services/datastore/resource_datastore_index_generated_test.go b/google/services/datastore/resource_datastore_index_generated_test.go deleted file mode 100644 index efda0f75a7a..00000000000 --- a/google/services/datastore/resource_datastore_index_generated_test.go +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package datastore_test - -import ( - "fmt" - "strings" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - - "github.com/hashicorp/terraform-provider-google/google/acctest" - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func TestAccDatastoreIndex_datastoreIndexExample(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_id": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckDatastoreIndexDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccDatastoreIndex_datastoreIndexExample(context), - }, - { - ResourceName: "google_datastore_index.default", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccDatastoreIndex_datastoreIndexExample(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_firestore_database" "database" { - project = "%{project_id}" - # google_datastore_index resources only support the (default) database. - # However, google_firestore_index can express any Datastore Mode index - # and should be preferred in all cases. - name = "(default)" - location_id = "nam5" - type = "DATASTORE_MODE" - - delete_protection_state = "DELETE_PROTECTION_DISABLED" - deletion_policy = "DELETE" -} - -resource "google_datastore_index" "default" { - kind = "foo" - properties { - name = "tf_test_property_a%{random_suffix}" - direction = "ASCENDING" - } - properties { - name = "tf_test_property_b%{random_suffix}" - direction = "ASCENDING" - } - - depends_on = [google_firestore_database.database] -} -`, context) -} - -func testAccCheckDatastoreIndexDestroyProducer(t *testing.T) func(s *terraform.State) error { - return func(s *terraform.State) error { - for name, rs := range s.RootModule().Resources { - if rs.Type != "google_datastore_index" { - continue - } - if strings.HasPrefix(name, "data.") { - continue - } - - config := acctest.GoogleProviderConfig(t) - - url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{DatastoreBasePath}}projects/{{project}}/indexes/{{index_id}}") - if err != nil { - return err - } - - billingProject := "" - - if config.BillingProject != "" { - billingProject = config.BillingProject - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: config.UserAgent, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, - }) - if err == nil { - return fmt.Errorf("DatastoreIndex still exists at %s", url) - } - } - - return nil - } -} diff --git a/google/services/datastore/resource_datastore_index_sweeper.go b/google/services/datastore/resource_datastore_index_sweeper.go deleted file mode 100644 index b907400cf69..00000000000 --- a/google/services/datastore/resource_datastore_index_sweeper.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package datastore - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("DatastoreIndex", testSweepDatastoreIndex) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepDatastoreIndex(region string) error { - resourceName := "DatastoreIndex" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://datastore.googleapis.com/v1/projects/{{project}}/indexes", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["indexes"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - var name string - // Id detected in the delete URL, attempt to use id. - if obj["id"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) - } else if obj["name"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - } else { - log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) - return nil - } - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://datastore.googleapis.com/v1/projects/{{project}}/indexes/{{index_id}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/google/services/dialogflow/resource_dialogflow_agent_test.go b/google/services/dialogflow/resource_dialogflow_agent_test.go index 1d067a684b2..22c2470c80e 100644 --- a/google/services/dialogflow/resource_dialogflow_agent_test.go +++ b/google/services/dialogflow/resource_dialogflow_agent_test.go @@ -54,6 +54,7 @@ func testAccDialogflowAgent_full1(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { @@ -97,6 +98,7 @@ func testAccDialogflowAgent_full2(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { diff --git a/google/services/dialogflow/resource_dialogflow_entity_type_test.go b/google/services/dialogflow/resource_dialogflow_entity_type_test.go index 490fe18fef3..da36086f83a 100644 --- a/google/services/dialogflow/resource_dialogflow_entity_type_test.go +++ b/google/services/dialogflow/resource_dialogflow_entity_type_test.go @@ -51,6 +51,7 @@ func testAccDialogflowEntityType_full1(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { @@ -102,6 +103,7 @@ func testAccDialogflowEntityType_full2(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { diff --git a/google/services/dialogflow/resource_dialogflow_fulfillment_test.go b/google/services/dialogflow/resource_dialogflow_fulfillment_test.go index 15b9f5881ed..30ae2725ade 100644 --- a/google/services/dialogflow/resource_dialogflow_fulfillment_test.go +++ b/google/services/dialogflow/resource_dialogflow_fulfillment_test.go @@ -51,6 +51,7 @@ func testAccDialogflowFulfillment_basic(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { @@ -93,6 +94,7 @@ func testAccDialogflowEntityType_full(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { diff --git a/google/services/dialogflow/resource_dialogflow_intent_generated_test.go b/google/services/dialogflow/resource_dialogflow_intent_generated_test.go index 5babcccda9d..f302fcc15f8 100644 --- a/google/services/dialogflow/resource_dialogflow_intent_generated_test.go +++ b/google/services/dialogflow/resource_dialogflow_intent_generated_test.go @@ -62,6 +62,7 @@ resource "google_project" "agent_project" { project_id = "tf-test-my-project%{random_suffix}" name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { diff --git a/google/services/dialogflow/resource_dialogflow_intent_test.go b/google/services/dialogflow/resource_dialogflow_intent_test.go index 97848542594..47463c712ea 100644 --- a/google/services/dialogflow/resource_dialogflow_intent_test.go +++ b/google/services/dialogflow/resource_dialogflow_intent_test.go @@ -76,6 +76,7 @@ func testAccDialogflowIntent_basic(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { @@ -117,6 +118,7 @@ func testAccDialogflowIntent_full1(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { @@ -167,6 +169,7 @@ func testAccDialogflowIntent_full2(context map[string]interface{}) string { project_id = "tf-test-dialogflow-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { diff --git a/google/services/dns/resource_dns_managed_zone_generated_test.go b/google/services/dns/resource_dns_managed_zone_generated_test.go index 626eb42c7db..418f9e0e7d8 100644 --- a/google/services/dns/resource_dns_managed_zone_generated_test.go +++ b/google/services/dns/resource_dns_managed_zone_generated_test.go @@ -332,6 +332,7 @@ resource "google_project" "project_1" { project_id = "tf-test-project-1%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "project_2" { @@ -339,6 +340,7 @@ resource "google_project" "project_2" { project_id = "tf-test-project-2%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_compute_network" "network_1_project_1" { diff --git a/google/services/dns/resource_dns_policy_generated_test.go b/google/services/dns/resource_dns_policy_generated_test.go index 72bb1cb3e14..503a96fc93c 100644 --- a/google/services/dns/resource_dns_policy_generated_test.go +++ b/google/services/dns/resource_dns_policy_generated_test.go @@ -153,6 +153,7 @@ resource "google_project" "project_1" { project_id = "tf-test-project-1%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project" "project_2" { @@ -160,6 +161,7 @@ resource "google_project" "project_2" { project_id = "tf-test-project-2%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_compute_network" "network_1_project_1" { diff --git a/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go b/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go index cd0e9f4640d..654770469ab 100644 --- a/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go +++ b/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go @@ -128,6 +128,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "contentwarehouse" { @@ -161,6 +162,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -203,6 +205,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -244,6 +247,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -285,6 +289,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -343,6 +348,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -408,6 +414,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -456,6 +463,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -497,6 +505,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { @@ -538,6 +547,7 @@ resource "google_project" "project" { name = "tf-test-%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_document_ai_warehouse_location" "loc" { diff --git a/google/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go b/google/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go index 8362316d5fe..c73577fc24d 100644 --- a/google/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go +++ b/google/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go @@ -31,6 +31,7 @@ import ( ) func TestAccEdgecontainerCluster_edgecontainerClusterExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -87,6 +88,7 @@ data "google_project" "project" {} } func TestAccEdgecontainerCluster_edgecontainerClusterWithMaintenanceWindowExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/google/services/edgenetwork/resource_edgenetwork_network.go b/google/services/edgenetwork/resource_edgenetwork_network.go index 195d72f2028..deaaba40079 100644 --- a/google/services/edgenetwork/resource_edgenetwork_network.go +++ b/google/services/edgenetwork/resource_edgenetwork_network.go @@ -35,6 +35,7 @@ func ResourceEdgenetworkNetwork() *schema.Resource { return &schema.Resource{ Create: resourceEdgenetworkNetworkCreate, Read: resourceEdgenetworkNetworkRead, + Update: resourceEdgenetworkNetworkUpdate, Delete: resourceEdgenetworkNetworkDelete, Importer: &schema.ResourceImporter{ @@ -43,10 +44,12 @@ func ResourceEdgenetworkNetwork() *schema.Resource { Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(20 * time.Minute), + Update: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(30 * time.Minute), }, CustomizeDiff: customdiff.All( + tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, ), @@ -76,11 +79,14 @@ func ResourceEdgenetworkNetwork() *schema.Resource { Description: `A free-text description of the resource. Max length 1024 characters.`, }, "labels": { - Type: schema.TypeMap, - Optional: true, - ForceNew: true, - Description: `Labels associated with this resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, + Type: schema.TypeMap, + Optional: true, + Description: `Labels associated with this resource. + + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, }, "mtu": { Type: schema.TypeInt, @@ -96,12 +102,26 @@ func ResourceEdgenetworkNetwork() *schema.Resource { A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045123456Z'.`, }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "name": { Type: schema.TypeString, Computed: true, Description: `The canonical name of this resource, with format 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}'`, }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "update_time": { Type: schema.TypeString, Computed: true, @@ -128,12 +148,6 @@ func resourceEdgenetworkNetworkCreate(d *schema.ResourceData, meta interface{}) } obj := make(map[string]interface{}) - labelsProp, err := expandEdgenetworkNetworkLabels(d.Get("labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } descriptionProp, err := expandEdgenetworkNetworkDescription(d.Get("description"), d, config) if err != nil { return err @@ -146,6 +160,12 @@ func resourceEdgenetworkNetworkCreate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("mtu"); !tpgresource.IsEmptyValue(reflect.ValueOf(mtuProp)) && (ok || !reflect.DeepEqual(v, mtuProp)) { obj["mtu"] = mtuProp } + labelsProp, err := expandEdgenetworkNetworkEffectiveLabels(d.Get("effective_labels"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp + } url, err := tpgresource.ReplaceVars(d, config, "{{EdgenetworkBasePath}}projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks?networkId={{network_id}}") if err != nil { @@ -263,10 +283,21 @@ func resourceEdgenetworkNetworkRead(d *schema.ResourceData, meta interface{}) er if err := d.Set("mtu", flattenEdgenetworkNetworkMtu(res["mtu"], d, config)); err != nil { return fmt.Errorf("Error reading Network: %s", err) } + if err := d.Set("terraform_labels", flattenEdgenetworkNetworkTerraformLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Network: %s", err) + } + if err := d.Set("effective_labels", flattenEdgenetworkNetworkEffectiveLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Network: %s", err) + } return nil } +func resourceEdgenetworkNetworkUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "labels" and "terraform_labels" are mutable + return resourceEdgenetworkNetworkRead(d, meta) +} + func resourceEdgenetworkNetworkDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -350,7 +381,18 @@ func flattenEdgenetworkNetworkName(v interface{}, d *schema.ResourceData, config } func flattenEdgenetworkNetworkLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + if v == nil { + return v + } + + transformed := make(map[string]interface{}) + if l, ok := d.GetOkExists("labels"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } + } + + return transformed } func flattenEdgenetworkNetworkDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -382,15 +424,23 @@ func flattenEdgenetworkNetworkMtu(v interface{}, d *schema.ResourceData, config return v // let terraform core handle it otherwise } -func expandEdgenetworkNetworkLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { +func flattenEdgenetworkNetworkTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { - return map[string]string{}, nil + return v } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) + + transformed := make(map[string]interface{}) + if l, ok := d.GetOkExists("terraform_labels"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } } - return m, nil + + return transformed +} + +func flattenEdgenetworkNetworkEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v } func expandEdgenetworkNetworkDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { @@ -400,3 +450,14 @@ func expandEdgenetworkNetworkDescription(v interface{}, d tpgresource.TerraformR func expandEdgenetworkNetworkMtu(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } + +func expandEdgenetworkNetworkEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} diff --git a/google/services/edgenetwork/resource_edgenetwork_subnet.go b/google/services/edgenetwork/resource_edgenetwork_subnet.go index d27fe211001..42ea2404929 100644 --- a/google/services/edgenetwork/resource_edgenetwork_subnet.go +++ b/google/services/edgenetwork/resource_edgenetwork_subnet.go @@ -35,6 +35,7 @@ func ResourceEdgenetworkSubnet() *schema.Resource { return &schema.Resource{ Create: resourceEdgenetworkSubnetCreate, Read: resourceEdgenetworkSubnetRead, + Update: resourceEdgenetworkSubnetUpdate, Delete: resourceEdgenetworkSubnetDelete, Importer: &schema.ResourceImporter{ @@ -43,10 +44,12 @@ func ResourceEdgenetworkSubnet() *schema.Resource { Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(20 * time.Minute), + Update: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(30 * time.Minute), }, CustomizeDiff: customdiff.All( + tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, ), @@ -102,11 +105,14 @@ Must be of the form: 'projects/{{project}}/locations/{{location}}/zones/{{zone}} }, }, "labels": { - Type: schema.TypeMap, - Optional: true, - ForceNew: true, - Description: `Labels associated with this resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, + Type: schema.TypeMap, + Optional: true, + Description: `Labels associated with this resource. + + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, }, "vlan_id": { Type: schema.TypeInt, @@ -122,6 +128,13 @@ Must be of the form: 'projects/{{project}}/locations/{{location}}/zones/{{zone}} A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045123456Z'.`, }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "name": { Type: schema.TypeString, Computed: true, @@ -133,6 +146,13 @@ fractional digits. Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045 Computed: true, Description: `Current stage of the resource to the device by config push.`, }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "update_time": { Type: schema.TypeString, Computed: true, @@ -159,12 +179,6 @@ func resourceEdgenetworkSubnetCreate(d *schema.ResourceData, meta interface{}) e } obj := make(map[string]interface{}) - labelsProp, err := expandEdgenetworkSubnetLabels(d.Get("labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } descriptionProp, err := expandEdgenetworkSubnetDescription(d.Get("description"), d, config) if err != nil { return err @@ -195,6 +209,12 @@ func resourceEdgenetworkSubnetCreate(d *schema.ResourceData, meta interface{}) e } else if v, ok := d.GetOkExists("vlan_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(vlanIdProp)) && (ok || !reflect.DeepEqual(v, vlanIdProp)) { obj["vlanId"] = vlanIdProp } + labelsProp, err := expandEdgenetworkSubnetEffectiveLabels(d.Get("effective_labels"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp + } url, err := tpgresource.ReplaceVars(d, config, "{{EdgenetworkBasePath}}projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets?subnetId={{subnet_id}}") if err != nil { @@ -324,10 +344,21 @@ func resourceEdgenetworkSubnetRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("state", flattenEdgenetworkSubnetState(res["state"], d, config)); err != nil { return fmt.Errorf("Error reading Subnet: %s", err) } + if err := d.Set("terraform_labels", flattenEdgenetworkSubnetTerraformLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Subnet: %s", err) + } + if err := d.Set("effective_labels", flattenEdgenetworkSubnetEffectiveLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Subnet: %s", err) + } return nil } +func resourceEdgenetworkSubnetUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "labels" and "terraform_labels" are mutable + return resourceEdgenetworkSubnetRead(d, meta) +} + func resourceEdgenetworkSubnetDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -411,7 +442,18 @@ func flattenEdgenetworkSubnetName(v interface{}, d *schema.ResourceData, config } func flattenEdgenetworkSubnetLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + if v == nil { + return v + } + + transformed := make(map[string]interface{}) + if l, ok := d.GetOkExists("labels"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } + } + + return transformed } func flattenEdgenetworkSubnetDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -462,15 +504,23 @@ func flattenEdgenetworkSubnetState(v interface{}, d *schema.ResourceData, config return v } -func expandEdgenetworkSubnetLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { +func flattenEdgenetworkSubnetTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { - return map[string]string{}, nil + return v } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) + + transformed := make(map[string]interface{}) + if l, ok := d.GetOkExists("terraform_labels"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } } - return m, nil + + return transformed +} + +func flattenEdgenetworkSubnetEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v } func expandEdgenetworkSubnetDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { @@ -496,3 +546,14 @@ func expandEdgenetworkSubnetIpv6Cidr(v interface{}, d tpgresource.TerraformResou func expandEdgenetworkSubnetVlanId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } + +func expandEdgenetworkSubnetEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} diff --git a/google/services/firestore/resource_firestore_document_generated_test.go b/google/services/firestore/resource_firestore_document_generated_test.go index b629a9aba3d..9b1895280d1 100644 --- a/google/services/firestore/resource_firestore_document_generated_test.go +++ b/google/services/firestore/resource_firestore_document_generated_test.go @@ -67,6 +67,7 @@ resource "google_project" "project" { project_id = "tf-test-project-id%{random_suffix}" name = "tf-test-project-id%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -138,6 +139,7 @@ resource "google_project" "project" { project_id = "tf-test-project-id%{random_suffix}" name = "tf-test-project-id%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/firestore/resource_firestore_document_test.go b/google/services/firestore/resource_firestore_document_test.go index e900f68acad..1ab822e56c4 100644 --- a/google/services/firestore/resource_firestore_document_test.go +++ b/google/services/firestore/resource_firestore_document_test.go @@ -50,6 +50,7 @@ resource "google_project" "project" { project_id = "tf-test%s" name = "tf-test%s" org_id = "%s" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/firestore/resource_firestore_field_test.go b/google/services/firestore/resource_firestore_field_test.go index bf099930172..4336e3abdf5 100644 --- a/google/services/firestore/resource_firestore_field_test.go +++ b/google/services/firestore/resource_firestore_field_test.go @@ -80,6 +80,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/gkehub/resource_gke_hub_feature_membership_test.go b/google/services/gkehub/resource_gke_hub_feature_membership_test.go index ea3166f107d..0750f45330e 100644 --- a/google/services/gkehub/resource_gke_hub_feature_membership_test.go +++ b/google/services/gkehub/resource_gke_hub_feature_membership_test.go @@ -1315,6 +1315,7 @@ resource "google_project" "project" { project_id = "tf-test-gkehub%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "anthos" { diff --git a/google/services/gkehub2/iam_gke_hub_feature_test.go b/google/services/gkehub2/iam_gke_hub_feature_test.go index 490078d5a79..09530b009b9 100644 --- a/google/services/gkehub2/iam_gke_hub_feature_test.go +++ b/google/services/gkehub2/iam_gke_hub_feature_test.go @@ -130,6 +130,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "mcsd" { project = google_project.project.project_id @@ -166,6 +167,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "mcsd" { project = google_project.project.project_id @@ -215,6 +217,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "mcsd" { project = google_project.project.project_id @@ -252,6 +255,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "mcsd" { project = google_project.project.project_id @@ -288,6 +292,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "mcsd" { project = google_project.project.project_id diff --git a/google/services/gkehub2/resource_gke_hub_feature_test.go b/google/services/gkehub2/resource_gke_hub_feature_test.go index 487bb870abc..1583e224cd6 100644 --- a/google/services/gkehub2/resource_gke_hub_feature_test.go +++ b/google/services/gkehub2/resource_gke_hub_feature_test.go @@ -927,6 +927,7 @@ resource "google_project" "project" { project_id = "tf-test-gkehub%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "mesh" { @@ -982,6 +983,7 @@ resource "google_project" "project_2" { project_id = "tf-test-gkehub%{random_suffix}-2" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "compute_2" { diff --git a/google/services/gkehub2/resource_gke_hub_fleet_test.go b/google/services/gkehub2/resource_gke_hub_fleet_test.go index 628b55de9cd..6558a50e41b 100755 --- a/google/services/gkehub2/resource_gke_hub_fleet_test.go +++ b/google/services/gkehub2/resource_gke_hub_fleet_test.go @@ -120,6 +120,7 @@ resource "google_project" "project" { project_id = "tf-test-gkehub%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "gkehub" { diff --git a/google/services/iam2/resource_iam_access_boundary_policy_test.go b/google/services/iam2/resource_iam_access_boundary_policy_test.go index 8bb6d6934ba..3449554d3a6 100644 --- a/google/services/iam2/resource_iam_access_boundary_policy_test.go +++ b/google/services/iam2/resource_iam_access_boundary_policy_test.go @@ -77,6 +77,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_access_context_manager_access_level" "test-access" { @@ -131,6 +132,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_access_context_manager_access_level" "test-access" { diff --git a/google/services/iam2/resource_iam_deny_policy_generated_test.go b/google/services/iam2/resource_iam_deny_policy_generated_test.go index c35eda03ad8..d4e9ce315de 100644 --- a/google/services/iam2/resource_iam_deny_policy_generated_test.go +++ b/google/services/iam2/resource_iam_deny_policy_generated_test.go @@ -65,6 +65,7 @@ resource "google_project" "project" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_iam_deny_policy" "example" { diff --git a/google/services/iam2/resource_iam_deny_policy_test.go b/google/services/iam2/resource_iam_deny_policy_test.go index aabed11955e..5e7b094adda 100644 --- a/google/services/iam2/resource_iam_deny_policy_test.go +++ b/google/services/iam2/resource_iam_deny_policy_test.go @@ -98,6 +98,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_iam_deny_policy" "example" { @@ -144,6 +145,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_iam_deny_policy" "example" { @@ -195,6 +197,7 @@ resource "google_iam_deny_policy" "example" { resource "google_folder" "folder" { display_name = "tf-test-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } `, context) } @@ -217,6 +220,7 @@ resource "google_iam_deny_policy" "example" { resource "google_folder" "folder" { display_name = "tf-test-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } `, context) } diff --git a/google/services/iap/data_source_iap_client_test.go b/google/services/iap/data_source_iap_client_test.go index 6d12a5eb9b0..e041a37e74e 100644 --- a/google/services/iap/data_source_iap_client_test.go +++ b/google/services/iap/data_source_iap_client_test.go @@ -45,6 +45,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_project_service" "project_service" { diff --git a/google/services/iap/iam_iap_tunnel_generated_test.go b/google/services/iap/iam_iap_tunnel_generated_test.go index 1dac8463a7d..2c60e8e1af0 100644 --- a/google/services/iap/iam_iap_tunnel_generated_test.go +++ b/google/services/iap/iam_iap_tunnel_generated_test.go @@ -382,6 +382,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -412,6 +413,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -455,6 +457,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -487,6 +490,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -517,6 +521,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -547,6 +552,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -582,6 +588,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -635,6 +642,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -670,6 +678,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -723,6 +732,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/iap/iam_iap_web_generated_test.go b/google/services/iap/iam_iap_web_generated_test.go index 84a65e10210..60a27d58160 100644 --- a/google/services/iap/iam_iap_web_generated_test.go +++ b/google/services/iap/iam_iap_web_generated_test.go @@ -382,6 +382,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -412,6 +413,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -455,6 +457,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -487,6 +490,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -517,6 +521,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -547,6 +552,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -582,6 +588,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -635,6 +642,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -670,6 +678,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -723,6 +732,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/iap/iam_iap_web_type_app_engine_generated_test.go b/google/services/iap/iam_iap_web_type_app_engine_generated_test.go index 22c8101249e..1b788a034d7 100644 --- a/google/services/iap/iam_iap_web_type_app_engine_generated_test.go +++ b/google/services/iap/iam_iap_web_type_app_engine_generated_test.go @@ -399,6 +399,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -437,6 +438,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -489,6 +491,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -529,6 +532,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -567,6 +571,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -605,6 +610,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -648,6 +654,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -711,6 +718,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -754,6 +762,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -817,6 +826,7 @@ resource "google_project" "project" { project_id = "%{project_id}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/iap/iam_iap_web_type_compute_generated_test.go b/google/services/iap/iam_iap_web_type_compute_generated_test.go index c525d0a5e90..59d77e305da 100644 --- a/google/services/iap/iam_iap_web_type_compute_generated_test.go +++ b/google/services/iap/iam_iap_web_type_compute_generated_test.go @@ -382,6 +382,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -412,6 +413,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -455,6 +457,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -487,6 +490,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -517,6 +521,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -547,6 +552,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -582,6 +588,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -635,6 +642,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -670,6 +678,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -723,6 +732,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/iap/resource_iap_brand_test.go b/google/services/iap/resource_iap_brand_test.go index d3961c95c1a..0b98766ab60 100644 --- a/google/services/iap/resource_iap_brand_test.go +++ b/google/services/iap/resource_iap_brand_test.go @@ -42,6 +42,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_project_service" "project_service" { diff --git a/google/services/iap/resource_iap_client_generated_test.go b/google/services/iap/resource_iap_client_generated_test.go index 4ead34bbbc2..ad7da5dc6cb 100644 --- a/google/services/iap/resource_iap_client_generated_test.go +++ b/google/services/iap/resource_iap_client_generated_test.go @@ -64,6 +64,7 @@ resource "google_project" "project" { project_id = "tf-test-my-project%{random_suffix}" name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_project_service" "project_service" { diff --git a/google/services/identityplatform/resource_identity_platform_config_generated_test.go b/google/services/identityplatform/resource_identity_platform_config_generated_test.go index 669fde220a3..38cafb32eb0 100644 --- a/google/services/identityplatform/resource_identity_platform_config_generated_test.go +++ b/google/services/identityplatform/resource_identity_platform_config_generated_test.go @@ -62,6 +62,7 @@ resource "google_project" "default" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_acct}" + deletion_policy = "DELETE" labels = { firebase = "enabled" } @@ -160,6 +161,7 @@ resource "google_project" "default" { name = "tf-test-my-project-1%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_acct}" + deletion_policy = "DELETE" labels = { firebase = "enabled" } diff --git a/google/services/identityplatform/resource_identity_platform_config_test.go b/google/services/identityplatform/resource_identity_platform_config_test.go index f0c7a61a993..43301893e4b 100644 --- a/google/services/identityplatform/resource_identity_platform_config_test.go +++ b/google/services/identityplatform/resource_identity_platform_config_test.go @@ -56,6 +56,7 @@ resource "google_project" "basic" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_acct}" + deletion_policy = "DELETE" labels = { firebase = "enabled" } @@ -134,6 +135,7 @@ resource "google_project" "basic" { name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_acct}" + deletion_policy = "DELETE" labels = { firebase = "enabled" } diff --git a/google/services/identityplatform/resource_identity_platform_project_default_config.go b/google/services/identityplatform/resource_identity_platform_project_default_config.go deleted file mode 100644 index f33f61bb41f..00000000000 --- a/google/services/identityplatform/resource_identity_platform_project_default_config.go +++ /dev/null @@ -1,810 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package identityplatform - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceIdentityPlatformProjectDefaultConfig() *schema.Resource { - return &schema.Resource{ - Create: resourceIdentityPlatformProjectDefaultConfigCreate, - Read: resourceIdentityPlatformProjectDefaultConfigRead, - Update: resourceIdentityPlatformProjectDefaultConfigUpdate, - Delete: resourceIdentityPlatformProjectDefaultConfigDelete, - - Importer: &schema.ResourceImporter{ - State: resourceIdentityPlatformProjectDefaultConfigImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - DeprecationMessage: "`google_identity_platform_config` is deprecated and will be removed in the next major release of the provider. Use the `google_identity_platform_config` resource instead. It contains a more comprehensive list of fields, and was created before `google_identity_platform_project_default_config` was added.", - - Schema: map[string]*schema.Schema{ - "sign_in": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration related to local sign in methods.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow_duplicate_emails": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether to allow more than one account to have the same email.`, - }, - "anonymous": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration options related to authenticating an anonymous user.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Required: true, - Description: `Whether anonymous user auth is enabled for the project or not.`, - }, - }, - }, - }, - "email": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration options related to authenticating a user by their email address.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether email auth is enabled for the project or not.`, - }, - "password_required": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether a password is required for email auth or not. If true, both an email and -password must be provided to sign in. If false, a user may sign in via either -email/password or email link.`, - }, - }, - }, - }, - "phone_number": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration options related to authenticated a user by their phone number.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether phone number auth is enabled for the project or not.`, - }, - "test_phone_numbers": { - Type: schema.TypeMap, - Optional: true, - Description: `A map of that can be used for phone auth testing.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - "hash_config": { - Type: schema.TypeList, - Computed: true, - Description: `Output only. Hash config information.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "algorithm": { - Type: schema.TypeString, - Computed: true, - Description: `Different password hash algorithms used in Identity Toolkit.`, - }, - "memory_cost": { - Type: schema.TypeInt, - Computed: true, - Description: `Memory cost for hash calculation. Used by scrypt and other similar password derivation algorithms. See https://tools.ietf.org/html/rfc7914 for explanation of field.`, - }, - "rounds": { - Type: schema.TypeInt, - Computed: true, - Description: `How many rounds for hash calculation. Used by scrypt and other similar password derivation algorithms.`, - }, - "salt_separator": { - Type: schema.TypeString, - Computed: true, - Description: `Non-printable character to be inserted between the salt and plain text password in base64.`, - }, - "signer_key": { - Type: schema.TypeString, - Computed: true, - Description: `Signer key in base64.`, - }, - }, - }, - }, - }, - }, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The name of the Config resource. Example: "projects/my-awesome-project/config"`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceIdentityPlatformProjectDefaultConfigCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - signInProp, err := expandIdentityPlatformProjectDefaultConfigSignIn(d.Get("sign_in"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("sign_in"); !tpgresource.IsEmptyValue(reflect.ValueOf(signInProp)) && (ok || !reflect.DeepEqual(v, signInProp)) { - obj["signIn"] = signInProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IdentityPlatformBasePath}}projects/{{project}}/config") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new ProjectDefaultConfig: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectDefaultConfig: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ProjectDefaultConfig: %s", err) - } - if err := d.Set("name", flattenIdentityPlatformProjectDefaultConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{project}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating ProjectDefaultConfig %q: %#v", d.Id(), res) - - return resourceIdentityPlatformProjectDefaultConfigRead(d, meta) -} - -func resourceIdentityPlatformProjectDefaultConfigRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IdentityPlatformBasePath}}projects/{{project}}/config") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectDefaultConfig: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformProjectDefaultConfig %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading ProjectDefaultConfig: %s", err) - } - - if err := d.Set("name", flattenIdentityPlatformProjectDefaultConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectDefaultConfig: %s", err) - } - if err := d.Set("sign_in", flattenIdentityPlatformProjectDefaultConfigSignIn(res["signIn"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectDefaultConfig: %s", err) - } - - return nil -} - -func resourceIdentityPlatformProjectDefaultConfigUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectDefaultConfig: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - signInProp, err := expandIdentityPlatformProjectDefaultConfigSignIn(d.Get("sign_in"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("sign_in"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, signInProp)) { - obj["signIn"] = signInProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IdentityPlatformBasePath}}projects/{{project}}/config") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating ProjectDefaultConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("sign_in") { - updateMask = append(updateMask, "signIn") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating ProjectDefaultConfig %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating ProjectDefaultConfig %q: %#v", d.Id(), res) - } - - } - - return resourceIdentityPlatformProjectDefaultConfigRead(d, meta) -} - -func resourceIdentityPlatformProjectDefaultConfigDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectDefaultConfig: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{IdentityPlatformBasePath}}projects/{{project}}/config") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting ProjectDefaultConfig %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ProjectDefaultConfig") - } - - log.Printf("[DEBUG] Finished deleting ProjectDefaultConfig %q: %#v", d.Id(), res) - return nil -} - -func resourceIdentityPlatformProjectDefaultConfigImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/config/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{project}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenIdentityPlatformProjectDefaultConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignIn(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["email"] = - flattenIdentityPlatformProjectDefaultConfigSignInEmail(original["email"], d, config) - transformed["phone_number"] = - flattenIdentityPlatformProjectDefaultConfigSignInPhoneNumber(original["phoneNumber"], d, config) - transformed["anonymous"] = - flattenIdentityPlatformProjectDefaultConfigSignInAnonymous(original["anonymous"], d, config) - transformed["allow_duplicate_emails"] = - flattenIdentityPlatformProjectDefaultConfigSignInAllowDuplicateEmails(original["allowDuplicateEmails"], d, config) - transformed["hash_config"] = - flattenIdentityPlatformProjectDefaultConfigSignInHashConfig(original["hashConfig"], d, config) - return []interface{}{transformed} -} -func flattenIdentityPlatformProjectDefaultConfigSignInEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["enabled"] = - flattenIdentityPlatformProjectDefaultConfigSignInEmailEnabled(original["enabled"], d, config) - transformed["password_required"] = - flattenIdentityPlatformProjectDefaultConfigSignInEmailPasswordRequired(original["passwordRequired"], d, config) - return []interface{}{transformed} -} -func flattenIdentityPlatformProjectDefaultConfigSignInEmailEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInEmailPasswordRequired(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInPhoneNumber(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["enabled"] = - flattenIdentityPlatformProjectDefaultConfigSignInPhoneNumberEnabled(original["enabled"], d, config) - transformed["test_phone_numbers"] = - flattenIdentityPlatformProjectDefaultConfigSignInPhoneNumberTestPhoneNumbers(original["testPhoneNumbers"], d, config) - return []interface{}{transformed} -} -func flattenIdentityPlatformProjectDefaultConfigSignInPhoneNumberEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInPhoneNumberTestPhoneNumbers(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInAnonymous(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["enabled"] = - flattenIdentityPlatformProjectDefaultConfigSignInAnonymousEnabled(original["enabled"], d, config) - return []interface{}{transformed} -} -func flattenIdentityPlatformProjectDefaultConfigSignInAnonymousEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInAllowDuplicateEmails(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInHashConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["algorithm"] = - flattenIdentityPlatformProjectDefaultConfigSignInHashConfigAlgorithm(original["algorithm"], d, config) - transformed["signer_key"] = - flattenIdentityPlatformProjectDefaultConfigSignInHashConfigSignerKey(original["signerKey"], d, config) - transformed["salt_separator"] = - flattenIdentityPlatformProjectDefaultConfigSignInHashConfigSaltSeparator(original["saltSeparator"], d, config) - transformed["rounds"] = - flattenIdentityPlatformProjectDefaultConfigSignInHashConfigRounds(original["rounds"], d, config) - transformed["memory_cost"] = - flattenIdentityPlatformProjectDefaultConfigSignInHashConfigMemoryCost(original["memoryCost"], d, config) - return []interface{}{transformed} -} -func flattenIdentityPlatformProjectDefaultConfigSignInHashConfigAlgorithm(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInHashConfigSignerKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInHashConfigSaltSeparator(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIdentityPlatformProjectDefaultConfigSignInHashConfigRounds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenIdentityPlatformProjectDefaultConfigSignInHashConfigMemoryCost(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func expandIdentityPlatformProjectDefaultConfigSignIn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEmail, err := expandIdentityPlatformProjectDefaultConfigSignInEmail(original["email"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["email"] = transformedEmail - } - - transformedPhoneNumber, err := expandIdentityPlatformProjectDefaultConfigSignInPhoneNumber(original["phone_number"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPhoneNumber); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["phoneNumber"] = transformedPhoneNumber - } - - transformedAnonymous, err := expandIdentityPlatformProjectDefaultConfigSignInAnonymous(original["anonymous"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAnonymous); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["anonymous"] = transformedAnonymous - } - - transformedAllowDuplicateEmails, err := expandIdentityPlatformProjectDefaultConfigSignInAllowDuplicateEmails(original["allow_duplicate_emails"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAllowDuplicateEmails); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["allowDuplicateEmails"] = transformedAllowDuplicateEmails - } - - transformedHashConfig, err := expandIdentityPlatformProjectDefaultConfigSignInHashConfig(original["hash_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedHashConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["hashConfig"] = transformedHashConfig - } - - return transformed, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEnabled, err := expandIdentityPlatformProjectDefaultConfigSignInEmailEnabled(original["enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enabled"] = transformedEnabled - } - - transformedPasswordRequired, err := expandIdentityPlatformProjectDefaultConfigSignInEmailPasswordRequired(original["password_required"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPasswordRequired); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["passwordRequired"] = transformedPasswordRequired - } - - return transformed, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInEmailEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInEmailPasswordRequired(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInPhoneNumber(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEnabled, err := expandIdentityPlatformProjectDefaultConfigSignInPhoneNumberEnabled(original["enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enabled"] = transformedEnabled - } - - transformedTestPhoneNumbers, err := expandIdentityPlatformProjectDefaultConfigSignInPhoneNumberTestPhoneNumbers(original["test_phone_numbers"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTestPhoneNumbers); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["testPhoneNumbers"] = transformedTestPhoneNumbers - } - - return transformed, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInPhoneNumberEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInPhoneNumberTestPhoneNumbers(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInAnonymous(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEnabled, err := expandIdentityPlatformProjectDefaultConfigSignInAnonymousEnabled(original["enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enabled"] = transformedEnabled - } - - return transformed, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInAnonymousEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInAllowDuplicateEmails(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInHashConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAlgorithm, err := expandIdentityPlatformProjectDefaultConfigSignInHashConfigAlgorithm(original["algorithm"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAlgorithm); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["algorithm"] = transformedAlgorithm - } - - transformedSignerKey, err := expandIdentityPlatformProjectDefaultConfigSignInHashConfigSignerKey(original["signer_key"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSignerKey); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["signerKey"] = transformedSignerKey - } - - transformedSaltSeparator, err := expandIdentityPlatformProjectDefaultConfigSignInHashConfigSaltSeparator(original["salt_separator"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSaltSeparator); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["saltSeparator"] = transformedSaltSeparator - } - - transformedRounds, err := expandIdentityPlatformProjectDefaultConfigSignInHashConfigRounds(original["rounds"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRounds); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["rounds"] = transformedRounds - } - - transformedMemoryCost, err := expandIdentityPlatformProjectDefaultConfigSignInHashConfigMemoryCost(original["memory_cost"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMemoryCost); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["memoryCost"] = transformedMemoryCost - } - - return transformed, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInHashConfigAlgorithm(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInHashConfigSignerKey(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInHashConfigSaltSeparator(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInHashConfigRounds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIdentityPlatformProjectDefaultConfigSignInHashConfigMemoryCost(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/google/services/identityplatform/resource_identity_platform_project_default_config_sweeper.go b/google/services/identityplatform/resource_identity_platform_project_default_config_sweeper.go deleted file mode 100644 index e2743acf41d..00000000000 --- a/google/services/identityplatform/resource_identity_platform_project_default_config_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package identityplatform - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("IdentityPlatformProjectDefaultConfig", testSweepIdentityPlatformProjectDefaultConfig) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepIdentityPlatformProjectDefaultConfig(region string) error { - resourceName := "IdentityPlatformProjectDefaultConfig" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://identitytoolkit.googleapis.com/v2/projects/{{project}}/config", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["projectDefaultConfigs"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://identitytoolkit.googleapis.com/v2/projects/{{project}}/config" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go b/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go index 0c620aa3890..a1869f00023 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go +++ b/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go @@ -66,6 +66,7 @@ resource "google_project" "target_project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_iam_member" "dns_peer_binding" { diff --git a/google/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go b/google/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go index 6cd690d568b..3f3f65b4fed 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go +++ b/google/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go @@ -55,6 +55,7 @@ resource "google_project" "target_project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_iam_member" "dns_peer_binding" { @@ -117,6 +118,7 @@ resource "google_project" "target_project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_iam_member" "dns_peer_binding" { diff --git a/google/services/integrations/resource_integrations_auth_config_test.go b/google/services/integrations/resource_integrations_auth_config_test.go index c7e1bed20d1..880d3ce1621 100644 --- a/google/services/integrations/resource_integrations_auth_config_test.go +++ b/google/services/integrations/resource_integrations_auth_config_test.go @@ -48,7 +48,7 @@ func testAccIntegrationsAuthConfig_full(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_integrations_client" "client" { location = "southamerica-west1" - provision_gmek = true + create_sample_integrations = true } resource "google_integrations_auth_config" "update_example" { @@ -74,7 +74,7 @@ func testAccIntegrationsAuthConfig_update(context map[string]interface{}) string return acctest.Nprintf(` resource "google_integrations_client" "client" { location = "southamerica-west1" - provision_gmek = true + create_sample_integrations = true } resource "google_integrations_auth_config" "update_example" { diff --git a/google/services/integrations/resource_integrations_client.go b/google/services/integrations/resource_integrations_client.go index 6c013ce7ea8..99aa38384d5 100644 --- a/google/services/integrations/resource_integrations_client.go +++ b/google/services/integrations/resource_integrations_client.go @@ -107,30 +107,12 @@ encrypted with GMEK.`, }, }, }, - ConflictsWith: []string{"provision_gmek"}, }, "create_sample_integrations": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Indicates if sample integrations should be created along with provisioning.`, - ConflictsWith: []string{"create_sample_workflows"}, - }, - "create_sample_workflows": { - Type: schema.TypeBool, - Optional: true, - Deprecated: "`create_sample_workflows` is deprecated and will be removed in a future major release. Use `create_sample_integrations` instead.", - ForceNew: true, - Description: `Indicates if sample workflow should be created along with provisioning.`, - ConflictsWith: []string{"create_sample_integrations"}, - }, - "provision_gmek": { - Type: schema.TypeBool, - Optional: true, - Deprecated: "`provision_gmek` is deprecated and will be removed in a future major release. Client would be provisioned as gmek if `cloud_kms_config` is not given.", - ForceNew: true, - Description: `Indicates provision with GMEK or CMEK.`, - ConflictsWith: []string{"cloud_kms_config"}, + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Indicates if sample integrations should be created along with provisioning.`, }, "run_as_service_account": { Type: schema.TypeString, @@ -163,24 +145,12 @@ func resourceIntegrationsClientCreate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("cloud_kms_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(cloudKmsConfigProp)) && (ok || !reflect.DeepEqual(v, cloudKmsConfigProp)) { obj["cloudKmsConfig"] = cloudKmsConfigProp } - createSampleWorkflowsProp, err := expandIntegrationsClientCreateSampleWorkflows(d.Get("create_sample_workflows"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("create_sample_workflows"); !tpgresource.IsEmptyValue(reflect.ValueOf(createSampleWorkflowsProp)) && (ok || !reflect.DeepEqual(v, createSampleWorkflowsProp)) { - obj["createSampleWorkflows"] = createSampleWorkflowsProp - } createSampleIntegrationsProp, err := expandIntegrationsClientCreateSampleIntegrations(d.Get("create_sample_integrations"), d, config) if err != nil { return err } else if v, ok := d.GetOkExists("create_sample_integrations"); !tpgresource.IsEmptyValue(reflect.ValueOf(createSampleIntegrationsProp)) && (ok || !reflect.DeepEqual(v, createSampleIntegrationsProp)) { obj["createSampleIntegrations"] = createSampleIntegrationsProp } - provisionGmekProp, err := expandIntegrationsClientProvisionGmek(d.Get("provision_gmek"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("provision_gmek"); !tpgresource.IsEmptyValue(reflect.ValueOf(provisionGmekProp)) && (ok || !reflect.DeepEqual(v, provisionGmekProp)) { - obj["provisionGmek"] = provisionGmekProp - } runAsServiceAccountProp, err := expandIntegrationsClientRunAsServiceAccount(d.Get("run_as_service_account"), d, config) if err != nil { return err @@ -445,18 +415,10 @@ func expandIntegrationsClientCloudKmsConfigKmsProjectId(v interface{}, d tpgreso return v, nil } -func expandIntegrationsClientCreateSampleWorkflows(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandIntegrationsClientCreateSampleIntegrations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } -func expandIntegrationsClientProvisionGmek(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandIntegrationsClientRunAsServiceAccount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/google/services/integrations/resource_integrations_client_generated_test.go b/google/services/integrations/resource_integrations_client_generated_test.go index bffa69e52ee..3bc0f7b0579 100644 --- a/google/services/integrations/resource_integrations_client_generated_test.go +++ b/google/services/integrations/resource_integrations_client_generated_test.go @@ -49,7 +49,7 @@ func TestAccIntegrationsClient_integrationsClientBasicExample(t *testing.T) { ResourceName: "google_integrations_client.example", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_integrations", "create_sample_workflows", "location", "provision_gmek", "run_as_service_account"}, + ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_integrations", "location", "run_as_service_account"}, }, }, }) @@ -83,7 +83,7 @@ func TestAccIntegrationsClient_integrationsClientFullExample(t *testing.T) { ResourceName: "google_integrations_client.example", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_integrations", "create_sample_workflows", "location", "provision_gmek", "run_as_service_account"}, + ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_integrations", "location", "run_as_service_account"}, }, }, }) @@ -129,41 +129,6 @@ resource "google_integrations_client" "example" { `, context) } -func TestAccIntegrationsClient_integrationsClientDeprecatedFieldsExample(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckIntegrationsClientDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccIntegrationsClient_integrationsClientDeprecatedFieldsExample(context), - }, - { - ResourceName: "google_integrations_client.example", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_integrations", "create_sample_workflows", "location", "provision_gmek", "run_as_service_account"}, - }, - }, - }) -} - -func testAccIntegrationsClient_integrationsClientDeprecatedFieldsExample(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_integrations_client" "example" { - location = "asia-south1" - provision_gmek = true - create_sample_workflows = true -} -`, context) -} - func testAccCheckIntegrationsClientDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { for name, rs := range s.RootModule().Resources { diff --git a/google/services/kms/iam_kms_crypto_key_test.go b/google/services/kms/iam_kms_crypto_key_test.go index dbfe1dc48c6..db91f068461 100644 --- a/google/services/kms/iam_kms_crypto_key_test.go +++ b/google/services/kms/iam_kms_crypto_key_test.go @@ -262,6 +262,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -306,6 +307,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -359,6 +361,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -403,6 +406,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { diff --git a/google/services/kms/iam_kms_key_ring_test.go b/google/services/kms/iam_kms_key_ring_test.go index b57cd7a45d1..ff910b0a2e5 100644 --- a/google/services/kms/iam_kms_key_ring_test.go +++ b/google/services/kms/iam_kms_key_ring_test.go @@ -176,6 +176,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -215,6 +216,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -263,6 +265,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -302,6 +305,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { diff --git a/google/services/kms/resource_kms_crypto_key_test.go b/google/services/kms/resource_kms_crypto_key_test.go index 0f1b41f8158..17a97350ff9 100644 --- a/google/services/kms/resource_kms_crypto_key_test.go +++ b/google/services/kms/resource_kms_crypto_key_test.go @@ -628,6 +628,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -658,6 +659,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -686,6 +688,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -713,6 +716,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -745,6 +749,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -767,6 +772,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -798,6 +804,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -830,6 +837,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -864,6 +872,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -902,6 +911,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -932,6 +942,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -966,6 +977,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1004,6 +1016,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1042,6 +1055,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { diff --git a/google/services/kms/resource_kms_key_ring_test.go b/google/services/kms/resource_kms_key_ring_test.go index 41ab253a19d..e3c797382e1 100644 --- a/google/services/kms/resource_kms_key_ring_test.go +++ b/google/services/kms/resource_kms_key_ring_test.go @@ -64,6 +64,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -86,6 +87,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { diff --git a/google/services/logging/data_source_google_logging_folder_settings_test.go b/google/services/logging/data_source_google_logging_folder_settings_test.go index 3dc359d92c3..b46c21b7eb2 100644 --- a/google/services/logging/data_source_google_logging_folder_settings_test.go +++ b/google/services/logging/data_source_google_logging_folder_settings_test.go @@ -39,6 +39,7 @@ func testAccLoggingFolderSettings_datasource(context map[string]interface{}) str resource "google_folder" "default" { display_name = "%{folder_name}" parent = "organizations/%{org_id}" + deletion_protection = false } data "google_logging_folder_settings" "settings" { diff --git a/google/services/logging/data_source_google_logging_project_cmek_settings_test.go b/google/services/logging/data_source_google_logging_project_cmek_settings_test.go index a06b9309128..f535470c3a2 100644 --- a/google/services/logging/data_source_google_logging_project_cmek_settings_test.go +++ b/google/services/logging/data_source_google_logging_project_cmek_settings_test.go @@ -46,6 +46,7 @@ resource "google_project" "default" { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "logging_service" { diff --git a/google/services/logging/data_source_google_logging_project_settings_test.go b/google/services/logging/data_source_google_logging_project_settings_test.go index e625056c66a..1c020937a86 100644 --- a/google/services/logging/data_source_google_logging_project_settings_test.go +++ b/google/services/logging/data_source_google_logging_project_settings_test.go @@ -42,6 +42,7 @@ func testAccLoggingProjectSettings_datasource(context map[string]interface{}) st name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "logging_service" { diff --git a/google/services/logging/resource_logging_bucket_config_test.go b/google/services/logging/resource_logging_bucket_config_test.go index 6eb9b804a39..d4e22254534 100644 --- a/google/services/logging/resource_logging_bucket_config_test.go +++ b/google/services/logging/resource_logging_bucket_config_test.go @@ -258,6 +258,7 @@ func testAccLoggingBucketConfigFolder_basic(context map[string]interface{}, rete resource "google_folder" "default" { display_name = "%{folder_name}" parent = "organizations/%{org_id}" + deletion_protection = false } resource "google_logging_folder_bucket_config" "basic" { @@ -277,6 +278,7 @@ resource "google_project" "default" { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_logging_project_bucket_config" "basic" { @@ -296,6 +298,7 @@ resource "google_project" "default" { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } // time_sleep would allow for permissions to be granted before creating log bucket @@ -325,6 +328,7 @@ resource "google_project" "default" { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_logging_project_bucket_config" "fixed_locked" { @@ -351,6 +355,7 @@ resource "google_project" "default" { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "logging_service" { @@ -505,6 +510,7 @@ func getLoggingBucketConfigs(context map[string]interface{}) map[string]string { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account_name}" + deletion_policy = "DELETE" } resource "google_logging_project_bucket_config" "basic" { @@ -623,6 +629,7 @@ resource "google_project" "default" { name = "%{project_name}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_logging_project_bucket_config" "basic" { diff --git a/google/services/logging/resource_logging_folder_exclusion_test.go b/google/services/logging/resource_logging_folder_exclusion_test.go index edce51e491d..f532ef08abf 100644 --- a/google/services/logging/resource_logging_folder_exclusion_test.go +++ b/google/services/logging/resource_logging_folder_exclusion_test.go @@ -239,6 +239,7 @@ resource "google_logging_folder_exclusion" "basic" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, exclusionName, description, envvar.GetTestProjectFromEnv(), folderName, folderParent) } @@ -255,6 +256,7 @@ resource "google_logging_folder_exclusion" "full-folder" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, exclusionName, description, envvar.GetTestProjectFromEnv(), folderName, folderParent) } @@ -264,6 +266,7 @@ func testAccLoggingFolderExclusion_multipleCfg(folderName, folderParent, exclusi resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, folderName, folderParent) diff --git a/google/services/logging/resource_logging_folder_settings_generated_test.go b/google/services/logging/resource_logging_folder_settings_generated_test.go index 47bf03ecb0e..5972c2bb3ba 100644 --- a/google/services/logging/resource_logging_folder_settings_generated_test.go +++ b/google/services/logging/resource_logging_folder_settings_generated_test.go @@ -65,6 +65,7 @@ resource "google_logging_folder_settings" "example" { resource "google_folder" "my_folder" { display_name = "tf-test-folder-name%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } data "google_logging_folder_settings" "settings" { diff --git a/google/services/logging/resource_logging_folder_settings_test.go b/google/services/logging/resource_logging_folder_settings_test.go index 082458a3451..ece0fb6b8dd 100644 --- a/google/services/logging/resource_logging_folder_settings_test.go +++ b/google/services/logging/resource_logging_folder_settings_test.go @@ -60,6 +60,7 @@ resource "google_logging_folder_settings" "example" { resource "google_folder" "my_folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } data "google_logging_folder_settings" "settings" { @@ -83,6 +84,7 @@ resource "google_logging_folder_settings" "example" { resource "google_folder" "my_folder" { display_name = "tf-test-folder-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } `, context) } diff --git a/google/services/logging/resource_logging_folder_sink_test.go b/google/services/logging/resource_logging_folder_sink_test.go index af685801055..aff79611e84 100644 --- a/google/services/logging/resource_logging_folder_sink_test.go +++ b/google/services/logging/resource_logging_folder_sink_test.go @@ -402,6 +402,7 @@ resource "google_storage_bucket" "log-bucket" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent) } @@ -425,6 +426,7 @@ resource "google_storage_bucket" "log-bucket" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent) } @@ -448,6 +450,7 @@ resource "google_storage_bucket" "log-bucket" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent) } @@ -468,8 +471,9 @@ resource "google_storage_bucket" "log-bucket" { } resource "google_folder" "my-folder" { - display_name = "%s" - parent = "%s" + display_name = "%s" + parent = "%s" + deletion_protection = false }`, sinkName, bucketName, folderName, folderParent) } @@ -491,6 +495,7 @@ resource "google_storage_bucket" "log-bucket" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent) } @@ -521,6 +526,7 @@ resource "google_storage_bucket" "log-bucket" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent) } @@ -547,6 +553,7 @@ resource "google_bigquery_dataset" "logging_sink" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false }`, sinkName, envvar.GetTestProjectFromEnv(), envvar.GetTestProjectFromEnv(), bqDatasetID, folderName, folderParent) } @@ -568,6 +575,7 @@ resource "google_bigquery_dataset" "logging_sink" { resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false }`, sinkName, envvar.GetTestProjectFromEnv(), envvar.GetTestProjectFromEnv(), bqDatasetID, folderName, folderParent) } @@ -585,6 +593,7 @@ resource "google_logging_folder_sink" "intercept_update" { resource "google_folder" "intercept_folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, sinkName, envvar.GetTestProjectFromEnv(), envvar.GetTestProjectFromEnv(), intercept_children, folderName, folderParent) } diff --git a/google/services/logging/resource_logging_project_sink_test.go b/google/services/logging/resource_logging_project_sink_test.go index 4cccdfb1e2c..48ce41db5ff 100644 --- a/google/services/logging/resource_logging_project_sink_test.go +++ b/google/services/logging/resource_logging_project_sink_test.go @@ -378,7 +378,8 @@ resource "google_project" "project" { project_id = "%s" name = "%s" org_id = "%s" - billing_account = "%s" + billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "logging_service" { @@ -519,6 +520,7 @@ resource "google_project" "destination-project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_logging_project_bucket_config" "destination-bucket" { @@ -581,6 +583,7 @@ resource "google_project" "destination-project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_logging_project_bucket_config" "destination-bucket" { diff --git a/google/services/monitoring/resource_monitoring_monitored_project_generated_test.go b/google/services/monitoring/resource_monitoring_monitored_project_generated_test.go index ca2ef3f9bc2..f13131c961e 100644 --- a/google/services/monitoring/resource_monitoring_monitored_project_generated_test.go +++ b/google/services/monitoring/resource_monitoring_monitored_project_generated_test.go @@ -70,6 +70,7 @@ resource "google_project" "basic" { project_id = "tf-test-m-id%{random_suffix}" name = "tf-test-m-id%{random_suffix}-display" org_id = "%{org_id}" + deletion_policy = "DELETE" } `, context) } @@ -112,6 +113,7 @@ resource "google_project" "basic" { project_id = "tf-test-m-id%{random_suffix}" name = "tf-test-m-id%{random_suffix}-display" org_id = "%{org_id}" + deletion_policy = "DELETE" } `, context) } diff --git a/google/services/monitoring/resource_monitoring_monitored_project_test.go b/google/services/monitoring/resource_monitoring_monitored_project_test.go index 72a963d96e6..7099fa6b0ad 100644 --- a/google/services/monitoring/resource_monitoring_monitored_project_test.go +++ b/google/services/monitoring/resource_monitoring_monitored_project_test.go @@ -78,6 +78,7 @@ resource "google_project" "basic" { project_id = "tf-test-m-id%{random_suffix}" name = "tf-test-m-id%{random_suffix}-display" org_id = "%{org_id}" + deletion_policy = "DELETE" } `, context) } @@ -93,6 +94,7 @@ resource "google_project" "basic" { project_id = "tf-test-m-id%{random_suffix}" name = "tf-test-m-id%{random_suffix}-display" org_id = "%{org_id}" + deletion_policy = "DELETE" } `, context) } diff --git a/google/services/orgpolicy/resource_org_policy_policy_test.go b/google/services/orgpolicy/resource_org_policy_policy_test.go index 1ec155015ec..5c05a9953dd 100644 --- a/google/services/orgpolicy/resource_org_policy_policy_test.go +++ b/google/services/orgpolicy/resource_org_policy_policy_test.go @@ -186,6 +186,7 @@ resource "google_project" "basic" { project_id = "tf-test-id%{random_suffix}" name = "tf-test-id%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } @@ -210,6 +211,7 @@ resource "google_org_policy_policy" "primary" { resource "google_folder" "basic" { parent = "organizations/%{org_id}" display_name = "tf-test-folder%{random_suffix}" + deletion_protection = false } @@ -247,6 +249,7 @@ resource "google_org_policy_policy" "primary" { resource "google_folder" "basic" { parent = "organizations/%{org_id}" display_name = "tf-test-folder%{random_suffix}" + deletion_protection = false } @@ -338,6 +341,7 @@ resource "google_project" "basic" { project_id = "tf-test-id%{random_suffix}" name = "tf-test-id%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } @@ -375,6 +379,7 @@ resource "google_project" "basic" { project_id = "tf-test-id%{random_suffix}" name = "tf-test-id%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } diff --git a/google/services/oslogin/resource_os_login_ssh_public_key_test.go b/google/services/oslogin/resource_os_login_ssh_public_key_test.go index 90d09a0b65e..10f0108732a 100644 --- a/google/services/oslogin/resource_os_login_ssh_public_key_test.go +++ b/google/services/oslogin/resource_os_login_ssh_public_key_test.go @@ -49,6 +49,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { project = google_project.project.project_id diff --git a/google/services/pubsub/resource_pubsub_topic.go b/google/services/pubsub/resource_pubsub_topic.go index b85fde5cff6..823ac047cd9 100644 --- a/google/services/pubsub/resource_pubsub_topic.go +++ b/google/services/pubsub/resource_pubsub_topic.go @@ -169,7 +169,6 @@ and is not a valid configuration.`, }, "schema_settings": { Type: schema.TypeList, - Computed: true, Optional: true, Description: `Settings for validating messages published against a schema.`, MaxItems: 1, diff --git a/google/services/pubsub/resource_pubsub_topic_test.go b/google/services/pubsub/resource_pubsub_topic_test.go index 8dfb57b9737..4214683fa8e 100644 --- a/google/services/pubsub/resource_pubsub_topic_test.go +++ b/google/services/pubsub/resource_pubsub_topic_test.go @@ -95,6 +95,9 @@ func TestAccPubsubTopic_schema(t *testing.T) { { Config: testAccPubsubTopic_updateWithNewSchema(topic, schema2), }, + { + Config: testAccPubsubTopic_updateWithNewSchema(topic, ""), + }, { ResourceName: "google_pubsub_topic.bar", ImportStateId: topic, @@ -230,7 +233,8 @@ resource "google_pubsub_topic" "bar" { } func testAccPubsubTopic_updateWithNewSchema(topic, schema string) string { - return fmt.Sprintf(` + if schema != "" { + return fmt.Sprintf(` resource "google_pubsub_schema" "foo" { name = "%s" type = "PROTOCOL_BUFFER" @@ -245,6 +249,13 @@ resource "google_pubsub_topic" "bar" { } } `, schema, topic) + } else { + return fmt.Sprintf(` + resource "google_pubsub_topic" "bar" { + name = "%s" + } + `, topic) + } } func testAccPubsubTopic_updateWithKinesisIngestionSettings(topic string) string { diff --git a/google/services/redis/resource_redis_cluster.go b/google/services/redis/resource_redis_cluster.go index 5d3a833df7a..9f2bfe60d60 100644 --- a/google/services/redis/resource_redis_cluster.go +++ b/google/services/redis/resource_redis_cluster.go @@ -95,6 +95,14 @@ projects/{network_project_id_or_number}/global/networks/{network_id}.`, Description: `Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. Default value: "AUTH_MODE_DISABLED" Possible values: ["AUTH_MODE_UNSPECIFIED", "AUTH_MODE_IAM_AUTH", "AUTH_MODE_DISABLED"]`, Default: "AUTH_MODE_DISABLED", }, + "deletion_protection_enabled": { + Type: schema.TypeBool, + Optional: true, + Description: `Optional. Indicates if the cluster is deletion protected or not. +If the value if set to true, any delete cluster operation will fail. +Default value is true.`, + Default: true, + }, "node_type": { Type: schema.TypeString, Computed: true, @@ -347,6 +355,12 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("shard_count"); !tpgresource.IsEmptyValue(reflect.ValueOf(shardCountProp)) && (ok || !reflect.DeepEqual(v, shardCountProp)) { obj["shardCount"] = shardCountProp } + deletionProtectionEnabledProp, err := expandRedisClusterDeletionProtectionEnabled(d.Get("deletion_protection_enabled"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("deletion_protection_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(deletionProtectionEnabledProp)) && (ok || !reflect.DeepEqual(v, deletionProtectionEnabledProp)) { + obj["deletionProtectionEnabled"] = deletionProtectionEnabledProp + } redisConfigsProp, err := expandRedisClusterRedisConfigs(d.Get("redis_configs"), d, config) if err != nil { return err @@ -502,6 +516,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("shard_count", flattenRedisClusterShardCount(res["shardCount"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } + if err := d.Set("deletion_protection_enabled", flattenRedisClusterDeletionProtectionEnabled(res["deletionProtectionEnabled"], d, config)); err != nil { + return fmt.Errorf("Error reading Cluster: %s", err) + } if err := d.Set("redis_configs", flattenRedisClusterRedisConfigs(res["redisConfigs"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -543,6 +560,12 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("shard_count"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, shardCountProp)) { obj["shardCount"] = shardCountProp } + deletionProtectionEnabledProp, err := expandRedisClusterDeletionProtectionEnabled(d.Get("deletion_protection_enabled"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("deletion_protection_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, deletionProtectionEnabledProp)) { + obj["deletionProtectionEnabled"] = deletionProtectionEnabledProp + } redisConfigsProp, err := expandRedisClusterRedisConfigs(d.Get("redis_configs"), d, config) if err != nil { return err @@ -571,6 +594,10 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error updateMask = append(updateMask, "shardCount") } + if d.HasChange("deletion_protection_enabled") { + updateMask = append(updateMask, "deletionProtectionEnabled") + } + if d.HasChange("redis_configs") { updateMask = append(updateMask, "redisConfigs") } @@ -958,6 +985,10 @@ func flattenRedisClusterShardCount(v interface{}, d *schema.ResourceData, config return v // let terraform core handle it otherwise } +func flattenRedisClusterDeletionProtectionEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenRedisClusterRedisConfigs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1042,6 +1073,10 @@ func expandRedisClusterShardCount(v interface{}, d tpgresource.TerraformResource return v, nil } +func expandRedisClusterDeletionProtectionEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandRedisClusterRedisConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/google/services/redis/resource_redis_cluster_generated_test.go b/google/services/redis/resource_redis_cluster_generated_test.go index eaf87766575..f5cd4465a02 100644 --- a/google/services/redis/resource_redis_cluster_generated_test.go +++ b/google/services/redis/resource_redis_cluster_generated_test.go @@ -34,8 +34,8 @@ func TestAccRedisCluster_redisClusterHaExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "prevent_destroy": false, - "random_suffix": acctest.RandString(t, 10), + "deletion_protection_enabled": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -72,16 +72,14 @@ resource "google_redis_cluster" "cluster-ha" { redis_configs = { maxmemory-policy = "volatile-ttl" } + deletion_protection_enabled = false + zone_distribution_config { mode = "MULTI_ZONE" } depends_on = [ google_network_connectivity_service_connection_policy.default ] - - lifecycle { - prevent_destroy = %{prevent_destroy} - } } resource "google_network_connectivity_service_connection_policy" "default" { @@ -113,8 +111,8 @@ func TestAccRedisCluster_redisClusterHaSingleZoneExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "prevent_destroy": false, - "random_suffix": acctest.RandString(t, 10), + "deletion_protection_enabled": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -148,13 +146,11 @@ resource "google_redis_cluster" "cluster-ha-single-zone" { mode = "SINGLE_ZONE" zone = "us-central1-f" } + deletion_protection_enabled = false depends_on = [ google_network_connectivity_service_connection_policy.default ] - lifecycle { - prevent_destroy = %{prevent_destroy} - } } resource "google_network_connectivity_service_connection_policy" "default" { diff --git a/google/services/resourcemanager/data_source_google_active_folder_test.go b/google/services/resourcemanager/data_source_google_active_folder_test.go index 7831c8be1ed..12eac292032 100644 --- a/google/services/resourcemanager/data_source_google_active_folder_test.go +++ b/google/services/resourcemanager/data_source_google_active_folder_test.go @@ -130,6 +130,7 @@ func testAccDataSourceGoogleActiveFolderConfig(parent string, displayName string resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_active_folder" "my_folder" { @@ -144,6 +145,7 @@ func testAccDataSourceGoogleActiveFolderConfig_Search(parent string, displayName resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } # Wait after folder creation to limit eventual consistency errors. diff --git a/google/services/resourcemanager/data_source_google_folder.go b/google/services/resourcemanager/data_source_google_folder.go index 5ddb5447bf7..d692875a3e1 100644 --- a/google/services/resourcemanager/data_source_google_folder.go +++ b/google/services/resourcemanager/data_source_google_folder.go @@ -52,6 +52,10 @@ func DataSourceGoogleFolder() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "deletion_protection": { + Type: schema.TypeBool, + Computed: true, + }, }, } } @@ -73,6 +77,10 @@ func dataSourceFolderRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("%s not found", id) } + if err := d.Set("deletion_protection", nil); err != nil { + return fmt.Errorf("Error setting deletion_protection: %s", err) + } + if v, ok := d.GetOk("lookup_organization"); ok && v.(bool) { organization, err := lookupOrganizationName(d.Id(), userAgent, d, config) if err != nil { diff --git a/google/services/resourcemanager/data_source_google_folder_organization_policy_test.go b/google/services/resourcemanager/data_source_google_folder_organization_policy_test.go index c88ada9cc04..76df3e5ba7e 100644 --- a/google/services/resourcemanager/data_source_google_folder_organization_policy_test.go +++ b/google/services/resourcemanager/data_source_google_folder_organization_policy_test.go @@ -35,6 +35,7 @@ func testAccDataSourceGoogleFolderOrganizationPolicy_basic(org, folder string) s resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "resource" { diff --git a/google/services/resourcemanager/data_source_google_folder_test.go b/google/services/resourcemanager/data_source_google_folder_test.go index 9c19c9be1a5..453b0649e34 100644 --- a/google/services/resourcemanager/data_source_google_folder_test.go +++ b/google/services/resourcemanager/data_source_google_folder_test.go @@ -125,6 +125,7 @@ func testAccCheckGoogleFolder_byFullNameConfig(parent string, displayName string resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folder" "folder" { @@ -138,6 +139,7 @@ func testAccCheckGoogleFolder_byShortNameConfig(parent string, displayName strin resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folder" "folder" { @@ -151,6 +153,7 @@ func testAccCheckGoogleFolder_lookupOrganizationConfig(parent string, displayNam resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folder" "folder" { diff --git a/google/services/resourcemanager/data_source_google_folders_test.go b/google/services/resourcemanager/data_source_google_folders_test.go index 2f04f2413cf..829a2884559 100644 --- a/google/services/resourcemanager/data_source_google_folders_test.go +++ b/google/services/resourcemanager/data_source_google_folders_test.go @@ -42,6 +42,7 @@ func testAccCheckGoogleFoldersConfig(parent string, displayName string) string { resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folders" "root-test" { diff --git a/google/services/resourcemanager/data_source_google_project_service_test.go b/google/services/resourcemanager/data_source_google_project_service_test.go index 1d2b6d06cc7..99d04f4eff9 100644 --- a/google/services/resourcemanager/data_source_google_project_service_test.go +++ b/google/services/resourcemanager/data_source_google_project_service_test.go @@ -38,6 +38,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "foo" { diff --git a/google/services/resourcemanager/data_source_google_project_test.go b/google/services/resourcemanager/data_source_google_project_test.go index 97316068a46..38faf85a92b 100644 --- a/google/services/resourcemanager/data_source_google_project_test.go +++ b/google/services/resourcemanager/data_source_google_project_test.go @@ -44,6 +44,7 @@ resource "google_project" "project" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" labels = { my-label = "my-label-value" } diff --git a/google/services/resourcemanager/resource_google_folder.go b/google/services/resourcemanager/resource_google_folder.go index 074017ba0da..a54bd163b50 100644 --- a/google/services/resourcemanager/resource_google_folder.go +++ b/google/services/resourcemanager/resource_google_folder.go @@ -67,6 +67,12 @@ func ResourceGoogleFolder() *schema.Resource { Computed: true, Description: `Timestamp when the Folder was created. Assigned by the server. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".`, }, + "deletion_protection": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: `When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the instance will fail. When the field is set to false, deleting the instance is allowed.`, + }, }, UseJSONNumber: true, } @@ -138,7 +144,12 @@ func resourceGoogleFolderRead(d *schema.ResourceData, meta interface{}) error { if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Folder Not Found : %s", d.Id())) } - + // Explicitly set client-side fields to default values if unset + if _, ok := d.GetOkExists("deletion_protection"); !ok { + if err := d.Set("deletion_protection", true); err != nil { + return fmt.Errorf("Error setting deletion_protection: %s", err) + } + } if err := d.Set("name", folder.Name); err != nil { return fmt.Errorf("Error setting name: %s", err) } @@ -168,6 +179,19 @@ func resourceGoogleFolderUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return err } + + clientSideFields := map[string]bool{"deletion_protection": true} + clientSideOnly := true + for field := range ResourceGoogleFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + return nil + } + displayName := d.Get("display_name").(string) d.Partial(true) @@ -224,6 +248,11 @@ func resourceGoogleFolderDelete(d *schema.ResourceData, meta interface{}) error if err != nil { return err } + + if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy folder without setting deletion_protection=false and running `terraform apply`") + } + displayName := d.Get("display_name").(string) var op *resourceManagerV3.Operation diff --git a/google/services/resourcemanager/resource_google_folder_iam_audit_config_test.go b/google/services/resourcemanager/resource_google_folder_iam_audit_config_test.go index 2d107837cff..fc5bf225e4a 100644 --- a/google/services/resourcemanager/resource_google_folder_iam_audit_config_test.go +++ b/google/services/resourcemanager/resource_google_folder_iam_audit_config_test.go @@ -279,6 +279,7 @@ func testAccFolderAssociateAuditConfigBasic(org, fname, service string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -300,6 +301,7 @@ func testAccFolderAssociateAuditConfigMultiple(org, fname, service, service2 str resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -329,6 +331,7 @@ func testAccFolderAssociateAuditConfigUpdated(org, fname, service string) string resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -350,6 +353,7 @@ func testAccFolderAssociateAuditConfigDropMemberFromBasic(org, fname, service st resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -377,6 +381,7 @@ func testAccFolderAssociateAuditConfigMembers(org, fname, service string, member resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -394,6 +399,7 @@ func testAccFolderAssociateAuditConfigLogType(org, fname, service, logType strin resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_folder_iam_binding_test.go b/google/services/resourcemanager/resource_google_folder_iam_binding_test.go index e8c75cb26b0..22af0afad31 100644 --- a/google/services/resourcemanager/resource_google_folder_iam_binding_test.go +++ b/google/services/resourcemanager/resource_google_folder_iam_binding_test.go @@ -295,6 +295,7 @@ func testAccFolderIamBasic(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } `, org, fname) } @@ -304,6 +305,7 @@ func testAccFolderAssociateBindingBasic(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { @@ -319,6 +321,7 @@ func testAccFolderAssociateBindingMultiple(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { @@ -340,6 +343,7 @@ func testAccFolderAssociateBindingUpdated(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { @@ -355,6 +359,7 @@ func testAccFolderAssociateBindingDropMemberFromBasic(org, fname string) string resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_folder_iam_member_test.go b/google/services/resourcemanager/resource_google_folder_iam_member_test.go index 58f8eb619b4..123396c8539 100644 --- a/google/services/resourcemanager/resource_google_folder_iam_member_test.go +++ b/google/services/resourcemanager/resource_google_folder_iam_member_test.go @@ -129,6 +129,7 @@ func testAccFolderAssociateMemberBasic(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_member" "acceptance" { @@ -144,6 +145,7 @@ func testAccFolderAssociateMemberMultiple(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_member" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_folder_iam_policy_test.go b/google/services/resourcemanager/resource_google_folder_iam_policy_test.go index d43dca4cc3b..a69bce74152 100644 --- a/google/services/resourcemanager/resource_google_folder_iam_policy_test.go +++ b/google/services/resourcemanager/resource_google_folder_iam_policy_test.go @@ -111,6 +111,7 @@ func testAccFolderIamPolicy_basic(folder, parent, role, member string) string { resource "google_folder" "permissiontest" { display_name = "%s" parent = "%s" + deletion_protection = false } data "google_iam_policy" "test" { @@ -136,6 +137,7 @@ func testAccFolderIamPolicy_basic2(folder, parent, role, member, role2, member2 resource "google_folder" "permissiontest" { display_name = "%s" parent = "%s" + deletion_protection = false } data "google_iam_policy" "test" { @@ -162,6 +164,7 @@ func testAccFolderIamPolicy_auditConfigs(folder, parent, role, member string) st resource "google_folder" "permissiontest" { display_name = "%s" parent = "%s" + deletion_protection = false } data "google_iam_policy" "test" { diff --git a/google/services/resourcemanager/resource_google_folder_organization_policy_test.go b/google/services/resourcemanager/resource_google_folder_organization_policy_test.go index 97262b0cdb8..d93bdb639e0 100644 --- a/google/services/resourcemanager/resource_google_folder_organization_policy_test.go +++ b/google/services/resourcemanager/resource_google_folder_organization_policy_test.go @@ -312,6 +312,7 @@ func testAccFolderOrganizationPolicy_boolean(org, folder string, enforced bool) resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "bool" { @@ -331,6 +332,7 @@ func testAccFolderOrganizationPolicy_list_allowAll(org, folder string) string { resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "list" { @@ -351,6 +353,7 @@ func testAccFolderOrganizationPolicy_list_allowSome(org, folder, project string) resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "list" { @@ -371,6 +374,7 @@ func testAccFolderOrganizationPolicy_list_denySome(org, folder string) string { resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "list" { @@ -394,6 +398,7 @@ func testAccFolderOrganizationPolicy_restore_defaultTrue(org, folder string) str resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "restore" { diff --git a/google/services/resourcemanager/resource_google_folder_test.go b/google/services/resourcemanager/resource_google_folder_test.go index a5eec8bd192..2f33f7b30b2 100644 --- a/google/services/resourcemanager/resource_google_folder_test.go +++ b/google/services/resourcemanager/resource_google_folder_test.go @@ -44,9 +44,10 @@ func TestAccFolder_rename(t *testing.T) { testAccCheckGoogleFolderDisplayName(&folder, newFolderDisplayName), )}, { - ResourceName: "google_folder.folder1", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_folder.folder1", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_protection"}, }, }, }) @@ -155,6 +156,7 @@ func testAccFolder_basic(folder, parent string) string { resource "google_folder" "folder1" { display_name = "%s" parent = "%s" + deletion_protection = false } `, folder, parent) } @@ -164,11 +166,13 @@ func testAccFolder_move(folder1, folder2, parent string) string { resource "google_folder" "folder1" { display_name = "%s" parent = google_folder.folder2.name + deletion_protection = false } resource "google_folder" "folder2" { display_name = "%s" parent = "%s" + deletion_protection = false } `, folder1, folder2, parent) } diff --git a/google/services/resourcemanager/resource_google_project.go b/google/services/resourcemanager/resource_google_project.go index f37d1b26b91..f4677dd73c9 100644 --- a/google/services/resourcemanager/resource_google_project.go +++ b/google/services/resourcemanager/resource_google_project.go @@ -69,17 +69,10 @@ func ResourceGoogleProject() *schema.Resource { ValidateFunc: verify.ValidateProjectID(), Description: `The project ID. Changing this forces a new project to be created.`, }, - "skip_delete": { - Type: schema.TypeBool, - Deprecated: `skip_delete is deprecated and will be removed in 6.0.0. Please use deletion_policy instead. A skip_delete value of false can be changed to a deletion_policy value of DELETE and a skip_delete value of true to a deletion_policy value of ABANDON for equivalent behavior.`, - Optional: true, - Computed: true, - Description: `If true, the Terraform resource can be deleted without deleting the Project via the Google API.`, - }, "deletion_policy": { Type: schema.TypeString, Optional: true, - Default: "DELETE", + Default: "PREVENT", Description: `The deletion policy for the Project. Setting PREVENT will protect the project against any destroy actions caused by a terraform apply or terraform destroy. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "PREVENT", "ABANDON", "DELETE"`, ValidateFunc: validation.StringInSlice([]string{"PREVENT", "ABANDON", "DELETE"}, false), @@ -318,7 +311,7 @@ func resourceGoogleProjectRead(d *schema.ResourceData, meta interface{}) error { } // Explicitly set client-side fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DELETE"); err != nil { + if err := d.Set("deletion_policy", "PREVENT"); err != nil { return fmt.Errorf("Error setting deletion_policy: %s", err) } } @@ -516,7 +509,6 @@ func resourceGoogleProjectDelete(d *schema.ResourceData, meta interface{}) error return err } deletionPolicy := d.Get("deletion_policy").(string) - // Only delete projects if skip_delete isn't set if deletionPolicy == "PREVENT" { return fmt.Errorf("Cannot destroy project as deletion_policy is set to PREVENT.") } else if deletionPolicy == "ABANDON" { @@ -525,19 +517,16 @@ func resourceGoogleProjectDelete(d *schema.ResourceData, meta interface{}) error return nil } else { // Only delete projects if deletion_policy isn't PREVENT or ABANDON - // Only delete projects if skip_delete isn't set - if !d.Get("skip_delete").(bool) { - parts := strings.Split(d.Id(), "/") - pid := parts[len(parts)-1] - if err := transport_tpg.Retry(transport_tpg.RetryOptions{ - RetryFunc: func() error { - _, delErr := config.NewResourceManagerClient(userAgent).Projects.Delete(pid).Do() - return delErr - }, - Timeout: d.Timeout(schema.TimeoutDelete), - }); err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Project %s", pid)) - } + parts := strings.Split(d.Id(), "/") + pid := parts[len(parts)-1] + if err := transport_tpg.Retry(transport_tpg.RetryOptions{ + RetryFunc: func() error { + _, delErr := config.NewResourceManagerClient(userAgent).Projects.Delete(pid).Do() + return delErr + }, + Timeout: d.Timeout(schema.TimeoutDelete), + }); err != nil { + return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Project %s", pid)) } } d.SetId("") diff --git a/google/services/resourcemanager/resource_google_project_default_service_accounts_test.go b/google/services/resourcemanager/resource_google_project_default_service_accounts_test.go index 3c7822538e1..f5158b13f2a 100644 --- a/google/services/resourcemanager/resource_google_project_default_service_accounts_test.go +++ b/google/services/resourcemanager/resource_google_project_default_service_accounts_test.go @@ -48,6 +48,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_default_service_accounts" "acceptance" { @@ -179,6 +180,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_project_iam_audit_config_test.go b/google/services/resourcemanager/resource_google_project_iam_audit_config_test.go index b32275654e5..f24b8e61724 100644 --- a/google/services/resourcemanager/resource_google_project_iam_audit_config_test.go +++ b/google/services/resourcemanager/resource_google_project_iam_audit_config_test.go @@ -309,6 +309,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_audit_config" "acceptance" { @@ -331,6 +332,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_audit_config" "acceptance" { @@ -361,6 +363,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_audit_config" "acceptance" { @@ -383,6 +386,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_audit_config" "acceptance" { @@ -411,6 +415,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_audit_config" "acceptance" { @@ -429,6 +434,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_audit_config" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_project_iam_binding_test.go b/google/services/resourcemanager/resource_google_project_iam_binding_test.go index d7c1e35f54c..d820b18c94b 100644 --- a/google/services/resourcemanager/resource_google_project_iam_binding_test.go +++ b/google/services/resourcemanager/resource_google_project_iam_binding_test.go @@ -284,6 +284,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "acceptance" { @@ -300,6 +301,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "acceptance" { @@ -322,6 +324,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "acceptance" { @@ -338,6 +341,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "acceptance" { @@ -354,6 +358,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "acceptance" { @@ -370,6 +375,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_project_iam_member_remove_test.go b/google/services/resourcemanager/resource_google_project_iam_member_remove_test.go index 600373d53a4..92f22be56f2 100644 --- a/google/services/resourcemanager/resource_google_project_iam_member_remove_test.go +++ b/google/services/resourcemanager/resource_google_project_iam_member_remove_test.go @@ -96,6 +96,7 @@ resource "google_project" "project" { project_id = "tf-test-%s" name = "tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "bar" { @@ -124,6 +125,7 @@ resource "google_project" "project" { project_id = "tf-test-%s" name = "tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "bar" { @@ -152,6 +154,7 @@ resource "google_project" "project" { project_id = "tf-test-%s" name = "tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "bar" { @@ -180,6 +183,7 @@ resource "google_project" "project" { project_id = "tf-test-%s" name = "tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "bar" { @@ -208,6 +212,7 @@ resource "google_project" "project" { project_id = "tf-test-%s" name = "tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "bar" { @@ -242,6 +247,7 @@ resource "google_project" "project" { project_id = "tf-test-%s" name = "tf-test-%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_binding" "bar" { diff --git a/google/services/resourcemanager/resource_google_project_iam_member_test.go b/google/services/resourcemanager/resource_google_project_iam_member_test.go index 0e7b1bb018a..496eb01c00f 100644 --- a/google/services/resourcemanager/resource_google_project_iam_member_test.go +++ b/google/services/resourcemanager/resource_google_project_iam_member_test.go @@ -200,6 +200,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_member" "acceptance" { @@ -216,6 +217,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_member" "acceptance" { @@ -238,6 +240,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_member" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_project_iam_policy_test.go b/google/services/resourcemanager/resource_google_project_iam_policy_test.go index ac7bfc6b560..2c613554899 100644 --- a/google/services/resourcemanager/resource_google_project_iam_policy_test.go +++ b/google/services/resourcemanager/resource_google_project_iam_policy_test.go @@ -266,6 +266,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_policy" "acceptance" { @@ -301,6 +302,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_policy" "acceptance" { @@ -354,6 +356,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } `, pid, pid, org) } @@ -364,6 +367,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_policy" "acceptance" { @@ -386,6 +390,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_policy" "acceptance" { @@ -417,6 +422,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_policy" "acceptance" { @@ -470,6 +476,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_iam_policy" "acceptance" { diff --git a/google/services/resourcemanager/resource_google_project_service_test.go b/google/services/resourcemanager/resource_google_project_service_test.go index 90a8f29d593..c69ee0e63ad 100644 --- a/google/services/resourcemanager/resource_google_project_service_test.go +++ b/google/services/resourcemanager/resource_google_project_service_test.go @@ -205,6 +205,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -226,6 +227,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -248,6 +250,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -263,6 +266,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -285,6 +289,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } // by passing through locals, we break the dependency chain @@ -315,6 +320,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { diff --git a/google/services/resourcemanager/resource_google_project_test.go b/google/services/resourcemanager/resource_google_project_test.go index 19b9ec00675..b46dc627b73 100644 --- a/google/services/resourcemanager/resource_google_project_test.go +++ b/google/services/resourcemanager/resource_google_project_test.go @@ -62,7 +62,7 @@ func TestAccProject_create(t *testing.T) { Steps: []resource.TestStep{ // This step creates a new project { - Config: testAccProject_create(pid, org), + Config: testAccProject(pid, org), Check: resource.ComposeTestCheckFunc( testAccCheckGoogleProjectExists("google_project.acceptance", pid), ), @@ -98,7 +98,7 @@ func TestAccProject_billing(t *testing.T) { ResourceName: "google_project.acceptance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"skip_delete", "deletion_policy"}, + ImportStateVerifyIgnore: []string{"deletion_policy"}, }, // Update to a different billing account { @@ -109,7 +109,7 @@ func TestAccProject_billing(t *testing.T) { }, // Unlink the billing account { - Config: testAccProject_create(pid, org), + Config: testAccProject(pid, org), Check: resource.ComposeTestCheckFunc( testAccCheckGoogleProjectHasBillingAccount(t, "google_project.acceptance", pid, ""), ), @@ -139,7 +139,7 @@ func TestAccProject_labels(t *testing.T) { ResourceName: "google_project.acceptance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"skip_delete", "labels", "terraform_labels", "deletion_policy"}, + ImportStateVerifyIgnore: []string{"deletion_policy", "labels", "terraform_labels"}, }, // update project with labels { @@ -151,7 +151,7 @@ func TestAccProject_labels(t *testing.T) { }, // update project delete labels { - Config: testAccProject_create(pid, org), + Config: testAccProject(pid, org), Check: resource.ComposeTestCheckFunc( testAccCheckGoogleProjectExists("google_project.acceptance", pid), testAccCheckGoogleProjectHasNoLabels(t, "google_project.acceptance", pid), @@ -212,7 +212,7 @@ func TestAccProject_migrateParent(t *testing.T) { ResourceName: "google_project.acceptance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"skip_delete", "deletion_policy"}, + ImportStateVerifyIgnore: []string{"deletion_policy"}, }, { Config: testAccProject_migrateParentOrg(pid, folderDisplayName, org), @@ -221,7 +221,7 @@ func TestAccProject_migrateParent(t *testing.T) { ResourceName: "google_project.acceptance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"skip_delete", "deletion_policy"}, + ImportStateVerifyIgnore: []string{"deletion_policy"}, }, { Config: testAccProject_migrateParentFolder(pid, folderDisplayName, org), @@ -230,7 +230,7 @@ func TestAccProject_migrateParent(t *testing.T) { ResourceName: "google_project.acceptance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"skip_delete", "deletion_policy"}, + ImportStateVerifyIgnore: []string{"deletion_policy"}, }, }, }) @@ -369,7 +369,7 @@ func TestAccProject_noAllowDestroy(t *testing.T) { ResourceName: "google_project.acceptance", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"skip_delete", "deletion_policy"}, + ImportStateVerifyIgnore: []string{"deletion_policy"}, }, { Config: testAccProject_noAllowDestroy(pid, org), @@ -377,7 +377,7 @@ func TestAccProject_noAllowDestroy(t *testing.T) { ExpectError: regexp.MustCompile("deletion_policy"), }, { - Config: testAccProject_create(pid, org), + Config: testAccProject(pid, org), }, }, }) @@ -417,10 +417,22 @@ func testAccProject_createWithoutOrg(pid string) string { resource "google_project" "acceptance" { project_id = "%s" name = "%s" + deletion_policy = "DELETE" } `, pid, pid) } +func testAccProject(pid, org string) string { + return fmt.Sprintf(` +resource "google_project" "acceptance" { + project_id = "%s" + name = "%s" + org_id = "%s" + deletion_policy = "DELETE" +} +`, pid, pid, org) +} + func testAccProject_noAllowDestroy(pid, org string) string { return fmt.Sprintf(` resource "google_project" "acceptance" { @@ -450,16 +462,22 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } `, pid, pid, org, billing) } 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" org_id = "%s" + deletion_policy = "DELETE" labels = {`, pid, pid, org) l := "" @@ -478,6 +496,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" # requires billing to enable compute API + deletion_policy = "DELETE" auto_create_network = false } `, pid, pid, org, billing) @@ -488,6 +507,7 @@ func testAccProject_parentFolder(pid, folderName, org string) string { resource "google_project" "acceptance" { project_id = "%s" name = "%s" + deletion_policy = "DELETE" folder_id = google_folder.folder1.id } @@ -495,6 +515,7 @@ resource "google_project" "acceptance" { resource "google_folder" "folder1" { display_name = "%s" parent = "organizations/%s" + deletion_protection = false } `, pid, pid, folderName, org) } @@ -504,6 +525,7 @@ func testAccProject_migrateParentFolder(pid, folderName, org string) string { resource "google_project" "acceptance" { project_id = "%s" name = "%s" + deletion_policy = "DELETE" folder_id = google_folder.folder1.id } @@ -511,6 +533,7 @@ resource "google_project" "acceptance" { resource "google_folder" "folder1" { display_name = "%s" parent = "organizations/%s" + deletion_protection = false } `, pid, pid, folderName, org) } @@ -520,6 +543,7 @@ func testAccProject_migrateParentOrg(pid, folderName, org string) string { resource "google_project" "acceptance" { project_id = "%s" name = "%s" + deletion_policy = "DELETE" org_id = "%s" } @@ -527,6 +551,7 @@ resource "google_project" "acceptance" { resource "google_folder" "folder1" { display_name = "%s" parent = "organizations/%s" + deletion_protection = false } `, pid, pid, org, folderName, org) } diff --git a/google/services/resourcemanager/resource_resourcemanager_lien_test.go b/google/services/resourcemanager/resource_resourcemanager_lien_test.go index 518e4877671..a407a33e534 100644 --- a/google/services/resourcemanager/resource_resourcemanager_lien_test.go +++ b/google/services/resourcemanager/resource_resourcemanager_lien_test.go @@ -102,6 +102,7 @@ resource "google_project" "project" { project_id = "%s" name = "some test project" org_id = "%s" + deletion_policy = "DELETE" } resource "google_resource_manager_lien" "lien" { diff --git a/google/services/secretmanager/data_source_secret_manager_secrets_test.go b/google/services/secretmanager/data_source_secret_manager_secrets_test.go index 8ece0cca7da..abad9755c58 100644 --- a/google/services/secretmanager/data_source_secret_manager_secrets_test.go +++ b/google/services/secretmanager/data_source_secret_manager_secrets_test.go @@ -32,8 +32,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": {}, }, ), ), @@ -44,6 +47,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}" @@ -84,8 +91,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": {}, }, ), ), @@ -96,6 +106,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/google/services/securitycenter/resource_scc_folder_custom_module_test.go b/google/services/securitycenter/resource_scc_folder_custom_module_test.go index 9cefa9d7e22..9f50775330f 100644 --- a/google/services/securitycenter/resource_scc_folder_custom_module_test.go +++ b/google/services/securitycenter/resource_scc_folder_custom_module_test.go @@ -72,6 +72,7 @@ func testAccSecurityCenterFolderCustomModule_sccFolderCustomModuleBasicExample(c resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "time_sleep" "wait_1_minute" { @@ -109,6 +110,7 @@ func testAccSecurityCenterFolderCustomModule_sccFolderCustomModuleFullExample(co resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_folder_custom_module" "example" { @@ -151,6 +153,7 @@ func testAccSecurityCenterFolderCustomModule_sccFolderCustomModuleUpdate(context resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_folder_custom_module" "example" { diff --git a/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go b/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go index 40edcec87f9..737decbfbc3 100644 --- a/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go +++ b/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go @@ -72,6 +72,7 @@ func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule_sc resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "time_sleep" "wait_1_minute" { @@ -110,6 +111,7 @@ func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule_sc resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "example" { @@ -153,6 +155,7 @@ func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule_sc resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "example" { diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go b/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go index ecf8fc9fedc..6203f489d88 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go +++ b/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go @@ -57,6 +57,7 @@ func testAccSecurityCenterV2FolderMuteConfig_basic(context map[string]interface{ resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "time_sleep" "wait_1_minute" { @@ -83,6 +84,7 @@ func testAccSecurityCenterV2FolderMuteConfig_update(context map[string]interface resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_v2_folder_mute_config" "default" { diff --git a/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go b/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go index fa10cfa1cfa..d79f3cde9fc 100644 --- a/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go +++ b/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go @@ -47,6 +47,7 @@ resource "google_project" "host" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host-compute" { diff --git a/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go b/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go index ce8cf2b1df6..e7b6b7d822b 100644 --- a/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go +++ b/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go @@ -38,6 +38,7 @@ resource "google_project" "host" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "host-compute" { diff --git a/google/services/servicenetworking/resource_service_networking_connection_test.go b/google/services/servicenetworking/resource_service_networking_connection_test.go index 68261bf0be4..ddc02dfbca7 100644 --- a/google/services/servicenetworking/resource_service_networking_connection_test.go +++ b/google/services/servicenetworking/resource_service_networking_connection_test.go @@ -188,6 +188,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "servicenetworking" { @@ -225,6 +226,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "servicenetworking" { @@ -280,6 +282,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "servicenetworking" { diff --git a/google/services/sql/resource_sql_database_instance.go b/google/services/sql/resource_sql_database_instance.go index 22eb7dd1d8c..9e99c62cf9c 100644 --- a/google/services/sql/resource_sql_database_instance.go +++ b/google/services/sql/resource_sql_database_instance.go @@ -76,7 +76,6 @@ var ( ipConfigurationKeys = []string{ "settings.0.ip_configuration.0.authorized_networks", "settings.0.ip_configuration.0.ipv4_enabled", - "settings.0.ip_configuration.0.require_ssl", "settings.0.ip_configuration.0.private_network", "settings.0.ip_configuration.0.allocated_ip_range", "settings.0.ip_configuration.0.enable_private_path_for_google_cloud_services", @@ -1402,7 +1401,8 @@ func expandIpConfiguration(configured []interface{}, databaseVersion string) *sq _ipConfiguration := configured[0].(map[string]interface{}) - forceSendFields := []string{"Ipv4Enabled", "RequireSsl"} + forceSendFields := []string{"Ipv4Enabled"} + nullFields := []string{"RequireSsl"} if !strings.HasPrefix(databaseVersion, "SQLSERVER") { forceSendFields = append(forceSendFields, "EnablePrivatePathForGoogleCloudServices") @@ -1410,12 +1410,12 @@ func expandIpConfiguration(configured []interface{}, databaseVersion string) *sq return &sqladmin.IpConfiguration{ Ipv4Enabled: _ipConfiguration["ipv4_enabled"].(bool), - RequireSsl: _ipConfiguration["require_ssl"].(bool), PrivateNetwork: _ipConfiguration["private_network"].(string), AllocatedIpRange: _ipConfiguration["allocated_ip_range"].(string), AuthorizedNetworks: expandAuthorizedNetworks(_ipConfiguration["authorized_networks"].(*schema.Set).List()), EnablePrivatePathForGoogleCloudServices: _ipConfiguration["enable_private_path_for_google_cloud_services"].(bool), ForceSendFields: forceSendFields, + NullFields: nullFields, PscConfig: expandPscConfig(_ipConfiguration["psc_config"].(*schema.Set).List()), SslMode: _ipConfiguration["ssl_mode"].(string), ServerCaMode: _ipConfiguration["server_ca_mode"].(string), @@ -2258,8 +2258,8 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration, d *schema "ipv4_enabled": ipConfiguration.Ipv4Enabled, "private_network": ipConfiguration.PrivateNetwork, "allocated_ip_range": ipConfiguration.AllocatedIpRange, - "require_ssl": ipConfiguration.RequireSsl, "enable_private_path_for_google_cloud_services": ipConfiguration.EnablePrivatePathForGoogleCloudServices, + "ssl_mode": ipConfiguration.SslMode, "server_ca_mode": ipConfiguration.ServerCaMode, } diff --git a/google/services/sql/resource_sql_database_instance_test.go b/google/services/sql/resource_sql_database_instance_test.go index 727682973cc..5da372e82e6 100644 --- a/google/services/sql/resource_sql_database_instance_test.go +++ b/google/services/sql/resource_sql_database_instance_test.go @@ -2378,9 +2378,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) { // We don't do ImportStateVerify for the ssl_mode because of the implementation. The ssl_mode is expected to be discarded if the local state doesn't have it. Steps: []resource.TestStep{ { - Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, false, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"), + Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "false"), resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "ALLOW_UNENCRYPTED_AND_ENCRYPTED"), ), }, @@ -2391,9 +2390,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) { ImportStateVerifyIgnore: []string{"deletion_protection", "settings.0.ip_configuration.0.ssl_mode"}, }, { - Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, false, "ENCRYPTED_ONLY"), + Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "ENCRYPTED_ONLY"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "false"), resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "ENCRYPTED_ONLY"), ), }, @@ -2404,9 +2402,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) { ImportStateVerifyIgnore: []string{"deletion_protection", "settings.0.ip_configuration.0.ssl_mode"}, }, { - Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, true, "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"), + Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "true"), resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"), ), }, @@ -2417,9 +2414,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) { ImportStateVerifyIgnore: []string{"deletion_protection", "settings.0.ip_configuration.0.ssl_mode"}, }, { - Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, false, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"), + Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "false"), resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "ALLOW_UNENCRYPTED_AND_ENCRYPTED"), ), }, @@ -2459,7 +2455,7 @@ func TestAccSqlDatabaseInstance_useInternalCaByDefault(t *testing.T) { }) } -func testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName string, databaseVersion string, requireSsl bool, sslMode string) string { +func testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName string, databaseVersion string, sslMode string) string { return fmt.Sprintf(` resource "google_sql_database_instance" "instance" { name = "%s" @@ -2470,11 +2466,10 @@ resource "google_sql_database_instance" "instance" { tier = "db-g1-small" ip_configuration { ipv4_enabled = true - require_ssl = %t ssl_mode = "%s" } } -}`, databaseName, databaseVersion, requireSsl, sslMode) +}`, databaseName, databaseVersion, sslMode) } func testAccSqlDatabaseInstance_sqlMysqlInstancePvpExample(context map[string]interface{}) string { @@ -2558,7 +2553,7 @@ resource "google_sql_database_instance" "instance" { collation = "Polish_CI_AS" ip_configuration { ipv4_enabled = true - require_ssl = true + ssl_mode = "ENCRYPTED_ONLY" } } } @@ -3037,6 +3032,7 @@ resource "google_project" "testproject" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_sql_database_instance" "instance" { @@ -3064,6 +3060,7 @@ resource "google_project" "testproject" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_sql_database_instance" "instance" { @@ -3097,6 +3094,7 @@ resource "google_project" "testproject" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_sql_database_instance" "instance" { @@ -3130,6 +3128,7 @@ resource "google_project" "testproject" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_sql_database_instance" "instance" { @@ -3164,6 +3163,7 @@ resource "google_project" "testproject" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_sql_database_instance" "instance" { diff --git a/google/services/storage/data_source_google_storage_buckets_test.go b/google/services/storage/data_source_google_storage_buckets_test.go index e87e2332a8c..b04be367577 100644 --- a/google/services/storage/data_source_google_storage_buckets_test.go +++ b/google/services/storage/data_source_google_storage_buckets_test.go @@ -72,6 +72,7 @@ resource "google_project" "acceptance" { project_id = local.project_id org_id = local.organization billing_account = local.billing_account + deletion_policy = "DELETE" } resource "google_storage_bucket" "one" { diff --git a/google/services/storage/resource_storage_bucket.go b/google/services/storage/resource_storage_bucket.go index 76680ea779b..f513dd5c1a3 100644 --- a/google/services/storage/resource_storage_bucket.go +++ b/google/services/storage/resource_storage_bucket.go @@ -49,7 +49,7 @@ func ResourceStorageBucket() *schema.Resource { Read: schema.DefaultTimeout(4 * time.Minute), }, - SchemaVersion: 2, + SchemaVersion: 3, StateUpgraders: []schema.StateUpgrader{ { Type: resourceStorageBucketV0().CoreConfigSchema().ImpliedType(), @@ -61,6 +61,11 @@ func ResourceStorageBucket() *schema.Resource { Upgrade: ResourceStorageBucketStateUpgradeV1, Version: 1, }, + { + Type: resourceStorageBucketV2().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceStorageBucketStateUpgradeV2, + Version: 2, + }, }, Schema: map[string]*schema.Schema{ @@ -233,12 +238,6 @@ func ResourceStorageBucket() *schema.Resource { Optional: true, Description: `Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.`, }, - "no_age": { - Type: schema.TypeBool, - Deprecated: "`no_age` is deprecated and will be removed in a future major release. Use `send_age_if_zero` instead.", - Optional: true, - Description: `While set true, age value will be omitted.Required to set true when age is unset in the config file.`, - }, "with_state": { Type: schema.TypeString, Computed: true, @@ -272,7 +271,6 @@ func ResourceStorageBucket() *schema.Resource { "send_age_if_zero": { Type: schema.TypeBool, Optional: true, - Default: true, Description: `While set true, age value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the age field. It can be used alone or together with age.`, }, "send_days_since_noncurrent_time_if_zero": { @@ -1413,14 +1411,12 @@ func flattenBucketLifecycleRuleCondition(index int, d *schema.ResourceData, cond // are already present otherwise setting them to individual default values. if v, ok := d.GetOk(fmt.Sprintf("lifecycle_rule.%d.condition", index)); ok { state_condition := v.(*schema.Set).List()[0].(map[string]interface{}) - ruleCondition["no_age"] = state_condition["no_age"].(bool) ruleCondition["send_days_since_noncurrent_time_if_zero"] = state_condition["send_days_since_noncurrent_time_if_zero"].(bool) ruleCondition["send_days_since_custom_time_if_zero"] = state_condition["send_days_since_custom_time_if_zero"].(bool) ruleCondition["send_num_newer_versions_if_zero"] = state_condition["send_num_newer_versions_if_zero"].(bool) ruleCondition["send_age_if_zero"] = state_condition["send_age_if_zero"].(bool) } else { - ruleCondition["no_age"] = false - ruleCondition["send_age_if_zero"] = true + ruleCondition["send_age_if_zero"] = false ruleCondition["send_days_since_noncurrent_time_if_zero"] = false ruleCondition["send_days_since_custom_time_if_zero"] = false ruleCondition["send_num_newer_versions_if_zero"] = false @@ -1573,15 +1569,10 @@ func expandStorageBucketLifecycleRuleCondition(v interface{}) (*storage.BucketLi condition := conditions[0].(map[string]interface{}) transformed := &storage.BucketLifecycleRuleCondition{} - // Setting high precedence of no_age over age and send_age_if_zero. - // Only sets age value when no_age is not present or no_age is present and has false value - if v, ok := condition["no_age"]; !ok || !(v.(bool)) { - if v, ok := condition["age"]; ok { - age := int64(v.(int)) - u, ok := condition["send_age_if_zero"] - if age > 0 || (ok && u.(bool)) { - transformed.Age = &age - } + if v, ok := condition["age"]; ok { + age := int64(v.(int)) + if u, ok := condition["send_age_if_zero"]; age > 0 || (ok && u.(bool)) { + transformed.Age = &age } } @@ -1692,15 +1683,8 @@ func resourceGCSBucketLifecycleRuleConditionHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) - if v, ok := m["no_age"]; ok && v.(bool) { - buf.WriteString(fmt.Sprintf("%t-", v.(bool))) - } else { - if v, ok := m["send_age_if_zero"]; ok { - buf.WriteString(fmt.Sprintf("%t-", v.(bool))) - } - if v, ok := m["age"]; ok { - buf.WriteString(fmt.Sprintf("%d-", v.(int))) - } + if v, ok := m["age"]; ok { + buf.WriteString(fmt.Sprintf("%d-", v.(int))) } if v, ok := m["days_since_custom_time"]; ok { @@ -1744,6 +1728,10 @@ func resourceGCSBucketLifecycleRuleConditionHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%d-", v.(int))) } + if v, ok := m["send_age_if_zero"]; ok { + buf.WriteString(fmt.Sprintf("%t-", v.(bool))) + } + if v, ok := m["send_days_since_noncurrent_time_if_zero"]; ok { buf.WriteString(fmt.Sprintf("%t-", v.(bool))) } @@ -1866,8 +1854,7 @@ func setStorageBucket(d *schema.ResourceData, config *transport_tpg.Config, res if err := d.Set("autoclass", flattenBucketAutoclass(res.Autoclass)); err != nil { return fmt.Errorf("Error setting autoclass: %s", err) } - // lifecycle_rule contains terraform only variable no_age. - // Passing config("d") to flattener function to set no_age separately. + // Passing config("d") to flattener function to set virtual fields separately. if err := d.Set("lifecycle_rule", flattenBucketLifecycle(d, res.Lifecycle)); err != nil { return fmt.Errorf("Error setting lifecycle_rule: %s", err) } diff --git a/google/services/storage/resource_storage_bucket_600_migration.go b/google/services/storage/resource_storage_bucket_600_migration.go index 60459e1ee2a..a9f3a81f503 100644 --- a/google/services/storage/resource_storage_bucket_600_migration.go +++ b/google/services/storage/resource_storage_bucket_600_migration.go @@ -529,3 +529,530 @@ func ResourceStorageBucketStateUpgradeV1(_ context.Context, rawState map[string] log.Printf("[DEBUG] Attributes after migration: %#v", rawState) return rawState, nil } + +func resourceStorageBucketV2() *schema.Resource { + return &schema.Resource{ + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceStorageBucketV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceStorageBucketStateUpgradeV0, + Version: 0, + }, + { + Type: resourceStorageBucketV1().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceStorageBucketStateUpgradeV1, + Version: 1, + }, + }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The name of the bucket.`, + ValidateFunc: verify.ValidateGCSName, + }, + + "encryption": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "default_kms_key_name": { + Type: schema.TypeString, + Required: true, + Description: `A Cloud KMS key that will be used to encrypt objects inserted into this bucket, if no encryption method is specified. You must pay attention to whether the crypto key is available in the location that this bucket is created in. See the docs for more details.`, + }, + }, + }, + Description: `The bucket's encryption configuration.`, + }, + + "requester_pays": { + Type: schema.TypeBool, + Optional: true, + Description: `Enables Requester Pays on a storage bucket.`, + }, + + "force_destroy": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: `When deleting a bucket, this boolean option will delete all contained objects. If you try to delete a bucket that contains objects, Terraform will fail that run.`, + }, + + "labels": { + Type: schema.TypeMap, + ValidateFunc: labelKeyValidator, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: `A set of key/value label pairs to assign to the bucket.`, + }, + + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `The combination of labels configured directly on the resource and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "location": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + StateFunc: func(s interface{}) string { + return strings.ToUpper(s.(string)) + }, + Description: `The Google Cloud Storage location`, + }, + + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, + }, + + "project_number": { + Type: schema.TypeInt, + Computed: true, + Description: `The project number of the project in which the resource belongs.`, + }, + + "self_link": { + Type: schema.TypeString, + Computed: true, + Description: `The URI of the created resource.`, + }, + + "url": { + Type: schema.TypeString, + Computed: true, + Description: `The base URL of the bucket, in the format gs://.`, + }, + + "storage_class": { + Type: schema.TypeString, + Optional: true, + Default: "STANDARD", + Description: `The Storage Class of the new bucket. Supported values include: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE.`, + }, + + "lifecycle_rule": { + Type: schema.TypeList, + Optional: true, + MaxItems: 100, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 1, + Set: resourceGCSBucketLifecycleRuleActionHash, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Required: true, + Description: `The type of the action of this Lifecycle Rule. Supported values include: Delete, SetStorageClass and AbortIncompleteMultipartUpload.`, + }, + "storage_class": { + Type: schema.TypeString, + Optional: true, + Description: `The target Storage Class of objects affected by this Lifecycle Rule. Supported values include: MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE.`, + }, + }, + }, + Description: `The Lifecycle Rule's action configuration. A single block of this type is supported.`, + }, + "condition": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 1, + Set: resourceGCSBucketLifecycleRuleConditionHash, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "age": { + Type: schema.TypeInt, + Optional: true, + Description: `Minimum age of an object in days to satisfy this condition.`, + }, + "created_before": { + Type: schema.TypeString, + Optional: true, + Description: `Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.`, + }, + "custom_time_before": { + Type: schema.TypeString, + Optional: true, + Description: `Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.`, + }, + "days_since_custom_time": { + Type: schema.TypeInt, + Optional: true, + Description: `Number of days elapsed since the user-specified timestamp set on an object.`, + }, + "days_since_noncurrent_time": { + Type: schema.TypeInt, + Optional: true, + Description: `Number of days elapsed since the noncurrent timestamp of an object. This + condition is relevant only for versioned objects.`, + }, + "noncurrent_time_before": { + Type: schema.TypeString, + Optional: true, + Description: `Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.`, + }, + "no_age": { + Type: schema.TypeBool, + Deprecated: "`no_age` is deprecated and will be removed in a future major release. Use `send_age_if_zero` instead.", + Optional: true, + Description: `While set true, age value will be omitted.Required to set true when age is unset in the config file.`, + }, + "with_state": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"LIVE", "ARCHIVED", "ANY", ""}, false), + Description: `Match to live and/or archived objects. Unversioned buckets have only live objects. Supported values include: "LIVE", "ARCHIVED", "ANY".`, + }, + "matches_storage_class": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: `Storage Class of objects to satisfy this condition. Supported values include: MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, STANDARD, DURABLE_REDUCED_AVAILABILITY.`, + }, + "num_newer_versions": { + Type: schema.TypeInt, + Optional: true, + Description: `Relevant only for versioned objects. The number of newer versions of an object to satisfy this condition.`, + }, + "matches_prefix": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: `One or more matching name prefixes to satisfy this condition.`, + }, + "matches_suffix": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: `One or more matching name suffixes to satisfy this condition.`, + }, + "send_age_if_zero": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: `While set true, age value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the age field. It can be used alone or together with age.`, + }, + "send_days_since_noncurrent_time_if_zero": { + Type: schema.TypeBool, + Optional: true, + Description: `While set true, days_since_noncurrent_time value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the days_since_noncurrent_time field. It can be used alone or together with days_since_noncurrent_time.`, + }, + "send_days_since_custom_time_if_zero": { + Type: schema.TypeBool, + Optional: true, + Description: `While set true, days_since_custom_time value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the days_since_custom_time field. It can be used alone or together with days_since_custom_time.`, + }, + "send_num_newer_versions_if_zero": { + Type: schema.TypeBool, + Optional: true, + Description: `While set true, num_newer_versions value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the num_newer_versions field. It can be used alone or together with num_newer_versions.`, + }, + }, + }, + Description: `The Lifecycle Rule's condition configuration.`, + }, + }, + }, + Description: `The bucket's Lifecycle Rules configuration.`, + }, + + "enable_object_retention": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Enables each object in the bucket to have its own retention policy, which prevents deletion until stored for a specific length of time.`, + }, + + "versioning": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + Description: `While set to true, versioning is fully enabled for this bucket.`, + }, + }, + }, + Description: `The bucket's Versioning configuration.`, + }, + + "autoclass": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + Description: `While set to true, autoclass automatically transitions objects in your bucket to appropriate storage classes based on each object's access pattern.`, + }, + "terminal_storage_class": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `The storage class that objects in the bucket eventually transition to if they are not read for a certain length of time. Supported values include: NEARLINE, ARCHIVE.`, + }, + }, + }, + Description: `The bucket's autoclass configuration.`, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + _, n := d.GetChange(strings.TrimSuffix(k, ".#")) + if !strings.HasSuffix(k, ".#") { + return false + } + var l []interface{} + if new == "1" && old == "0" { + l = n.([]interface{}) + contents, ok := l[0].(map[string]interface{}) + if !ok { + return false + } + if contents["enabled"] == false { + return true + } + } + if new == "0" && old == "1" { + n := d.Get(strings.TrimSuffix(k, ".#")) + l = n.([]interface{}) + contents := l[0].(map[string]interface{}) + if contents["enabled"] == false { + return true + } + } + return false + }, + }, + "website": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "main_page_suffix": { + Type: schema.TypeString, + Optional: true, + AtLeastOneOf: []string{"website.0.not_found_page", "website.0.main_page_suffix"}, + Description: `Behaves as the bucket's directory index where missing objects are treated as potential directories.`, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return old != "" && new == "" + }, + }, + "not_found_page": { + Type: schema.TypeString, + Optional: true, + AtLeastOneOf: []string{"website.0.main_page_suffix", "website.0.not_found_page"}, + Description: `The custom object to return when a requested resource is not found.`, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return old != "" && new == "" + }, + }, + }, + }, + Description: `Configuration if the bucket acts as a website.`, + }, + + "retention_policy": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_locked": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: `If set to true, the bucket will be locked and permanently restrict edits to the bucket's retention policy. Caution: Locking a bucket is an irreversible action.`, + }, + "retention_period": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(1, math.MaxInt32), + Description: `The period of time, in seconds, that objects in the bucket must be retained and cannot be deleted, overwritten, or archived. The value must be less than 3,155,760,000 seconds.`, + }, + }, + }, + Description: `Configuration of the bucket's data retention policy for how long objects in the bucket should be retained.`, + }, + + "cors": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "origin": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: `The list of Origins eligible to receive CORS response headers. Note: "*" is permitted in the list of origins, and means "any Origin".`, + }, + "method": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: `The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means "any method".`, + }, + "response_header": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: `The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains.`, + }, + "max_age_seconds": { + Type: schema.TypeInt, + Optional: true, + Description: `The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses.`, + }, + }, + }, + Description: `The bucket's Cross-Origin Resource Sharing (CORS) configuration.`, + }, + + "default_event_based_hold": { + Type: schema.TypeBool, + Optional: true, + Description: `Whether or not to automatically apply an eventBasedHold to new objects added to the bucket.`, + }, + + "logging": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "log_bucket": { + Type: schema.TypeString, + Required: true, + Description: `The bucket that will receive log objects.`, + }, + "log_object_prefix": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `The object prefix for log objects. If it's not provided, by default Google Cloud Storage sets this to this bucket's name.`, + }, + }, + }, + Description: `The bucket's Access & Storage Logs configuration.`, + }, + "uniform_bucket_level_access": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: `Enables uniform bucket-level access on a bucket.`, + }, + "custom_placement_config": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_locations": { + Type: schema.TypeSet, + Required: true, + ForceNew: true, + MaxItems: 2, + MinItems: 2, + Elem: &schema.Schema{ + Type: schema.TypeString, + StateFunc: func(s interface{}) string { + return strings.ToUpper(s.(string)) + }, + }, + Description: `The list of individual regions that comprise a dual-region bucket. See the docs for a list of acceptable regions. Note: If any of the data_locations changes, it will recreate the bucket.`, + }, + }, + }, + Description: `The bucket's custom location configuration, which specifies the individual regions that comprise a dual-region bucket. If the bucket is designated a single or multi-region, the parameters are empty.`, + }, + "rpo": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Specifies the RPO setting of bucket. If set 'ASYNC_TURBO', The Turbo Replication will be enabled for the dual-region bucket. Value 'DEFAULT' will set RPO setting to default. Turbo Replication is only for buckets in dual-regions.See the docs for more details.`, + }, + "public_access_prevention": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Prevents public access to a bucket.`, + }, + "soft_delete_policy": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Computed: true, + Description: `The bucket's soft delete policy, which defines the period of time that soft-deleted objects will be retained, and cannot be permanently deleted. If it is not provided, by default Google Cloud Storage sets this to default soft delete policy`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "retention_duration_seconds": { + Type: schema.TypeInt, + Default: 604800, + Optional: true, + Description: `The duration in seconds that soft-deleted objects in the bucket will be retained and cannot be permanently deleted. Default value is 604800.`, + }, + "effective_time": { + Type: schema.TypeString, + Computed: true, + Description: `Server-determined value that indicates the time from which the policy, or one with a greater retention, was effective. This value is in RFC 3339 format.`, + }, + }, + }, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceStorageBucketStateUpgradeV2(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + log.Printf("[DEBUG] Attributes before migration: %#v", rawState) + if rawState["lifecycle_rule"] != nil { + rawRules := rawState["lifecycle_rule"].([]interface{}) + for i, r := range rawRules { + newRule := r.(map[string]interface{}) + if newRule["condition"] != nil { + newCondition := newRule["condition"].([]interface{})[0].(map[string]interface{}) + newCondition["send_age_if_zero"] = false + newRule["condition"].([]interface{})[0] = newCondition + } + rawState["lifecycle_rule"].([]interface{})[i] = newRule + } + } + log.Printf("[DEBUG] Attributes after migration: %#v", rawState) + return rawState, nil +} diff --git a/google/services/storage/resource_storage_bucket_test.go b/google/services/storage/resource_storage_bucket_test.go index 91a2753daeb..bc5116878de 100644 --- a/google/services/storage/resource_storage_bucket_test.go +++ b/google/services/storage/resource_storage_bucket_test.go @@ -657,14 +657,13 @@ func TestAccStorageBucket_lifecycleRulesVirtualFields(t *testing.T) { ResourceName: "google_storage_bucket.bucket", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"force_destroy", "lifecycle_rule.1.condition.0.no_age", "lifecycle_rule.1.condition.0.send_days_since_noncurrent_time_if_zero", "lifecycle_rule.2.condition.0.send_days_since_noncurrent_time_if_zero", "lifecycle_rule.1.condition.0.send_days_since_custom_time_if_zero", "lifecycle_rule.2.condition.0.send_days_since_custom_time_if_zero", "lifecycle_rule.1.condition.0.send_num_newer_versions_if_zero", "lifecycle_rule.2.condition.0.send_num_newer_versions_if_zero", "lifecycle_rule.1.condition.0.send_age_if_zero"}, + ImportStateVerifyIgnore: []string{"force_destroy", "lifecycle_rule.1.condition.0.send_days_since_noncurrent_time_if_zero", "lifecycle_rule.2.condition.0.send_days_since_noncurrent_time_if_zero", "lifecycle_rule.1.condition.0.send_days_since_custom_time_if_zero", "lifecycle_rule.2.condition.0.send_days_since_custom_time_if_zero", "lifecycle_rule.1.condition.0.send_num_newer_versions_if_zero", "lifecycle_rule.2.condition.0.send_num_newer_versions_if_zero", "lifecycle_rule.1.condition.0.send_age_if_zero", "lifecycle_rule.2.condition.0.send_age_if_zero"}, }, { Config: testAccStorageBucket_customAttributes_withLifecycleVirtualFieldsUpdate2(bucketName), Check: resource.ComposeTestCheckFunc( testAccCheckStorageBucketExists( t, "google_storage_bucket.bucket", bucketName, &bucket), - testAccCheckStorageBucketLifecycleConditionNoAge(nil, &bucket, 1), testAccCheckStorageBucketLifecycleConditionNoAge(nil, &bucket, 2), ), }, @@ -672,7 +671,7 @@ func TestAccStorageBucket_lifecycleRulesVirtualFields(t *testing.T) { ResourceName: "google_storage_bucket.bucket", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"force_destroy", "lifecycle_rule.1.condition.0.no_age", "lifecycle_rule.0.condition.0.send_days_since_noncurrent_time_if_zero", "lifecycle_rule.0.condition.0.send_days_since_custom_time_if_zero", "lifecycle_rule.0.condition.0.send_num_newer_versions_if_zero", "lifecycle_rule.0.condition.0.send_age_if_zero", "lifecycle_rule.1.condition.0.send_age_if_zero", "lifecycle_rule.2.condition.0.send_age_if_zero"}, + ImportStateVerifyIgnore: []string{"force_destroy", "lifecycle_rule.0.condition.0.send_days_since_noncurrent_time_if_zero", "lifecycle_rule.0.condition.0.send_days_since_custom_time_if_zero", "lifecycle_rule.0.condition.0.send_num_newer_versions_if_zero", "lifecycle_rule.0.condition.0.send_age_if_zero", "lifecycle_rule.1.condition.0.send_age_if_zero", "lifecycle_rule.2.condition.0.send_age_if_zero"}, }, { Config: testAccStorageBucket_customAttributes_withLifecycle1(bucketName), @@ -1870,6 +1869,7 @@ resource "google_storage_bucket" "bucket" { type = "Delete" } condition { + send_age_if_zero = true age = 0 } } @@ -1917,7 +1917,6 @@ resource "google_storage_bucket" "bucket" { } condition { age = 10 - no_age = false days_since_noncurrent_time = 0 send_days_since_noncurrent_time_if_zero = false days_since_custom_time = 0 @@ -1931,7 +1930,6 @@ resource "google_storage_bucket" "bucket" { type = "Delete" } condition { - no_age = true days_since_noncurrent_time = 0 send_days_since_noncurrent_time_if_zero = true days_since_custom_time = 0 @@ -1945,6 +1943,7 @@ resource "google_storage_bucket" "bucket" { type = "Delete" } condition { + send_age_if_zero = true send_days_since_noncurrent_time_if_zero = true send_days_since_custom_time_if_zero = true send_num_newer_versions_if_zero = true @@ -1966,7 +1965,6 @@ resource "google_storage_bucket" "bucket" { } condition { age = 10 - no_age = false days_since_noncurrent_time = 0 send_days_since_noncurrent_time_if_zero = true days_since_custom_time = 0 @@ -1981,7 +1979,6 @@ resource "google_storage_bucket" "bucket" { } condition { age = 10 - no_age = true send_age_if_zero = false custom_time_before = "2022-09-01" days_since_noncurrent_time = 0 @@ -2449,6 +2446,7 @@ resource "google_project" "acceptance" { project_id = "tf-test-%{random_suffix}" org_id = "%{organization}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { diff --git a/google/services/tags/resource_tags_test.go b/google/services/tags/resource_tags_test.go index 7e526ba0876..9f38d2dbbde 100644 --- a/google/services/tags/resource_tags_test.go +++ b/google/services/tags/resource_tags_test.go @@ -380,6 +380,7 @@ resource "google_project" "project" { project_id = "%{project_id}" name = "%{project_id}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_tags_tag_key" "key" { diff --git a/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go b/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go index a6fbeeccec8..4a8d57584a3 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go +++ b/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go @@ -292,6 +292,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint_test.go b/google/services/vertexai/resource_vertex_ai_index_endpoint_test.go index b8b1486f4bd..1f7f16f67f4 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint_test.go +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint_test.go @@ -11,6 +11,7 @@ import ( ) func TestAccVertexAIIndexEndpoint_updated(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/google/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go b/google/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go index 2764f3b6649..47a81e1f537 100644 --- a/google/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go +++ b/google/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go @@ -44,6 +44,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "vmwareengine" { diff --git a/google/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go b/google/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go index 2b405e78684..f3074f8ce14 100644 --- a/google/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go +++ b/google/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go @@ -45,6 +45,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "vmwareengine" { diff --git a/google/services/vmwareengine/data_source_google_vmwareengine_network_test.go b/google/services/vmwareengine/data_source_google_vmwareengine_network_test.go index 57b6d1a88d3..e0e365fe56e 100644 --- a/google/services/vmwareengine/data_source_google_vmwareengine_network_test.go +++ b/google/services/vmwareengine/data_source_google_vmwareengine_network_test.go @@ -44,6 +44,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "vmwareengine" { diff --git a/google/services/vmwareengine/resource_vmwareengine_network_test.go b/google/services/vmwareengine/resource_vmwareengine_network_test.go index 3ccf73a47e1..acf10b1db96 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network_test.go +++ b/google/services/vmwareengine/resource_vmwareengine_network_test.go @@ -67,6 +67,7 @@ resource "google_project" "acceptance" { project_id = "tf-test-%{random_suffix}" org_id = "%{organization}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { diff --git a/google/services/vpcaccess/data_source_vpc_access_connector_test.go b/google/services/vpcaccess/data_source_vpc_access_connector_test.go index e768e4fbe66..c21c4f49243 100644 --- a/google/services/vpcaccess/data_source_vpc_access_connector_test.go +++ b/google/services/vpcaccess/data_source_vpc_access_connector_test.go @@ -39,9 +39,11 @@ func testAccVPCAccessConnectorDatasourceConfig(suffix string) string { return fmt.Sprintf(` resource "google_vpc_access_connector" "connector" { name = "tf-test-%s" - ip_cidr_range = "10.8.0.32/28" - network = "default" - region = "us-central1" + ip_cidr_range = "10.8.0.32/28" + network = "default" + region = "us-central1" + min_throughput = 200 + max_throughput = 300 } data "google_vpc_access_connector" "connector" { diff --git a/google/services/vpcaccess/resource_vpc_access_connector.go b/google/services/vpcaccess/resource_vpc_access_connector.go index 9d3879fb7b9..c6cad98161b 100644 --- a/google/services/vpcaccess/resource_vpc_access_connector.go +++ b/google/services/vpcaccess/resource_vpc_access_connector.go @@ -79,9 +79,11 @@ func ResourceVPCAccessConnector() *schema.Resource { ForceNew: true, Description: `Maximum value of instances in autoscaling group underlying the connector. Value must be between 3 and 10, inclusive. Must be higher than the value specified by min_instances.`, + ConflictsWith: []string{"max_throughput"}, }, "max_throughput": { Type: schema.TypeInt, + Computed: true, Optional: true, ForceNew: true, ValidateFunc: validation.IntBetween(200, 1000), @@ -89,7 +91,7 @@ higher than the value specified by min_instances.`, when using an e2-micro machine type. Value must be a multiple of 100 from 300 through 1000. Must be higher than the value specified by min_throughput. If both max_throughput and max_instances are provided, max_instances takes precedence over max_throughput. The use of max_throughput is discouraged in favor of max_instances.`, - Default: 300, + ConflictsWith: []string{"max_instances"}, }, "min_instances": { Type: schema.TypeInt, @@ -98,16 +100,18 @@ max_throughput is discouraged in favor of max_instances.`, ForceNew: true, Description: `Minimum value of instances in autoscaling group underlying the connector. Value must be between 2 and 9, inclusive. Must be lower than the value specified by max_instances.`, + ConflictsWith: []string{"min_throughput"}, }, "min_throughput": { Type: schema.TypeInt, + Computed: true, Optional: true, ForceNew: true, ValidateFunc: validation.IntBetween(200, 1000), Description: `Minimum throughput of the connector in Mbps. Default and min is 200. Refers to the expected throughput when using an e2-micro machine type. Value must be a multiple of 100 from 200 through 900. Must be lower than the value specified by max_throughput. If both min_throughput and min_instances are provided, min_instances takes precedence over min_throughput. The use of min_throughput is discouraged in favor of min_instances.`, - Default: 200, + ConflictsWith: []string{"min_instances"}, }, "network": { Type: schema.TypeString, diff --git a/google/services/vpcaccess/resource_vpc_access_connector_generated_test.go b/google/services/vpcaccess/resource_vpc_access_connector_generated_test.go index f0ef1300c30..206782be467 100644 --- a/google/services/vpcaccess/resource_vpc_access_connector_generated_test.go +++ b/google/services/vpcaccess/resource_vpc_access_connector_generated_test.go @@ -62,6 +62,8 @@ resource "google_vpc_access_connector" "connector" { name = "tf-test-vpc-con%{random_suffix}" ip_cidr_range = "10.8.0.0/28" network = "%{network_name}" + min_instances = 2 + max_instances = 3 } `, context) } @@ -100,6 +102,8 @@ resource "google_vpc_access_connector" "connector" { name = google_compute_subnetwork.custom_test.name } machine_type = "e2-standard-4" + min_instances = 2 + max_instances = 3 } resource "google_compute_subnetwork" "custom_test" { diff --git a/google/services/vpcaccess/resource_vpc_access_connector_test.go b/google/services/vpcaccess/resource_vpc_access_connector_test.go index 29fea181f22..081b3ae8e42 100644 --- a/google/services/vpcaccess/resource_vpc_access_connector_test.go +++ b/google/services/vpcaccess/resource_vpc_access_connector_test.go @@ -3,6 +3,7 @@ package vpcaccess_test import ( + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -33,6 +34,81 @@ func TestAccVPCAccessConnector_vpcAccessConnectorThroughput(t *testing.T) { }) } +func TestAccVPCAccessConnector_vpcAccessConnectorThroughput_combiningThroughputAndInstancesFields_conflict(t *testing.T) { + // Need to skip this test as the expected failure happens before the provider interacts with APIs + // In VCR mode this test fails due to lack of cassettes + acctest.SkipIfVcr(t) + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckVPCAccessConnectorDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccVPCAccessConnector_vpcAccessConnectorThroughput_bothThroughputAndInstances(context), + // When all 4 of min_instance/max_instance and min_throughput/max_throughput fields are sent to the API + // the API ignores the throughput field values. Instead the API returns values for min and max throughput + // based on the value of min and max instances. The mismatch with the config causes a permadiff. + // Due to this we make the fields conflict with each other. + ExpectError: regexp.MustCompile("conflicts with"), + }, + }, + }) +} + +func TestAccVPCAccessConnector_vpcAccessConnectorThroughput_usingThroughputOrInstancesLimits(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckVPCAccessConnectorDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccVPCAccessConnector_vpcAccessConnectorThroughput_justThroughputFields(context), + Check: resource.ComposeTestCheckFunc( + // These fields are set by the config in this test step + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "min_throughput", "400"), + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "max_throughput", "800"), + // These fields aren't set in the config; the API sets and returns values + // based on the thoughput values provided + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "min_instances", "4"), + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "max_instances", "8"), + ), + }, + { + Config: testAccVPCAccessConnector_vpcAccessConnectorThroughput_justInstanceFields(context), + Check: resource.ComposeTestCheckFunc( + // These fields are set by the config in this test step + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "min_instances", "5"), + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "max_instances", "7"), + // These fields aren't set in the config; the API sets and returns values + // based on the instance limit values provided + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "min_throughput", "500"), + resource.TestCheckResourceAttr( + "google_vpc_access_connector.connector", "max_throughput", "700"), + ), + }, + }, + }) +} + func testAccVPCAccessConnector_vpcAccessConnectorThroughput(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_vpc_access_connector" "connector" { @@ -59,3 +135,86 @@ resource "google_compute_network" "custom_test" { } `, context) } + +func testAccVPCAccessConnector_vpcAccessConnectorThroughput_bothThroughputAndInstances(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_vpc_access_connector" "connector" { + name = "tf-test-vpc-con%{random_suffix}" + subnet { + name = google_compute_subnetwork.custom_test.name + } + machine_type = "e2-standard-4" + min_instances = 2 + max_instances = 3 + min_throughput = 400 + max_throughput = 1000 + region = "us-central1" +} + +resource "google_compute_subnetwork" "custom_test" { + name = "tf-test-vpc-con%{random_suffix}" + ip_cidr_range = "10.2.0.0/28" + region = "us-central1" + network = google_compute_network.custom_test.id +} + +resource "google_compute_network" "custom_test" { + name = "tf-test-vpc-con%{random_suffix}" + auto_create_subnetworks = false +} +`, context) +} + +func testAccVPCAccessConnector_vpcAccessConnectorThroughput_justInstanceFields(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_vpc_access_connector" "connector" { + name = "tf-test-vpc-con%{random_suffix}" + subnet { + name = google_compute_subnetwork.custom_test.name + } + machine_type = "e2-standard-4" + min_instances = 5 + max_instances = 7 + region = "us-central1" +} + +resource "google_compute_subnetwork" "custom_test" { + name = "tf-test-vpc-con%{random_suffix}" + ip_cidr_range = "10.2.0.0/28" + region = "us-central1" + network = google_compute_network.custom_test.id +} + +resource "google_compute_network" "custom_test" { + name = "tf-test-vpc-con%{random_suffix}" + auto_create_subnetworks = false +} +`, context) +} + +func testAccVPCAccessConnector_vpcAccessConnectorThroughput_justThroughputFields(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_vpc_access_connector" "connector" { + name = "tf-test-vpc-con%{random_suffix}" + subnet { + name = google_compute_subnetwork.custom_test.name + } + machine_type = "e2-standard-4" + min_throughput = 400 + max_throughput = 800 + region = "us-central1" +} + +resource "google_compute_subnetwork" "custom_test" { + name = "tf-test-vpc-con%{random_suffix}" + ip_cidr_range = "10.2.0.0/28" + region = "us-central1" + network = google_compute_network.custom_test.id +} + +resource "google_compute_network" "custom_test" { + name = "tf-test-vpc-con%{random_suffix}" + auto_create_subnetworks = false +} +`, context) +} diff --git a/google/services/workflows/resource_workflows_workflow.go b/google/services/workflows/resource_workflows_workflow.go index cb80bd1f16d..75db8259139 100644 --- a/google/services/workflows/resource_workflows_workflow.go +++ b/google/services/workflows/resource_workflows_workflow.go @@ -733,7 +733,12 @@ func resourceWorkflowsWorkflowEncoder(d *schema.ResourceData, meta interface{}, if v, ok := d.GetOk("name"); ok { ResName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - ResName = id.PrefixedUniqueId(v.(string)) + prefix := v.(string) + if len(prefix) > 37 { + ResName = tpgresource.ReducedPrefixedUniqueId(prefix) + } else { + ResName = id.PrefixedUniqueId(prefix) + } } else { ResName = id.UniqueId() } diff --git a/google/sweeper/gcp_sweeper_test.go b/google/sweeper/gcp_sweeper_test.go index 2aebaa297c3..2b1782afb32 100644 --- a/google/sweeper/gcp_sweeper_test.go +++ b/google/sweeper/gcp_sweeper_test.go @@ -55,7 +55,6 @@ import ( _ "github.com/hashicorp/terraform-provider-google/google/services/dataplex" _ "github.com/hashicorp/terraform-provider-google/google/services/dataproc" _ "github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore" - _ "github.com/hashicorp/terraform-provider-google/google/services/datastore" _ "github.com/hashicorp/terraform-provider-google/google/services/datastream" _ "github.com/hashicorp/terraform-provider-google/google/services/deploymentmanager" _ "github.com/hashicorp/terraform-provider-google/google/services/dialogflow" diff --git a/google/tpgresource/labels.go b/google/tpgresource/labels.go index b64bc794753..ac6db4f4f90 100644 --- a/google/tpgresource/labels.go +++ b/google/tpgresource/labels.go @@ -57,8 +57,9 @@ func SetDataSourceLabels(d *schema.ResourceData) error { return nil } -func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error { - raw := d.Get("labels") +// 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{}, skipAttribution bool) error { + raw := d.Get(labelsField) if raw == nil { return nil } @@ -73,7 +74,7 @@ func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) // If "labels" field is computed, set "terraform_labels" and "effective_labels" to computed. // https://github.com/hashicorp/terraform-provider-google/issues/16217 - if !d.GetRawPlan().GetAttr("labels").IsWhollyKnown() { + if !d.GetRawPlan().GetAttr(labelsField).IsWhollyKnown() { if err := d.SetNewComputed("terraform_labels"); err != nil { return fmt.Errorf("error setting terraform_labels to computed: %w", err) } @@ -93,7 +94,7 @@ func SetLabelsDiff(_ context.Context, 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 || @@ -133,6 +134,24 @@ func SetLabelsDiff(_ context.Context, 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, 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, false) + } +} + func SetMetadataLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error { l := d.Get("metadata").([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/google/tpgresource/utils.go b/google/tpgresource/utils.go index ab376408eb9..55a9f50535a 100644 --- a/google/tpgresource/utils.go +++ b/google/tpgresource/utils.go @@ -24,6 +24,7 @@ import ( "github.com/hashicorp/go-cty/cty" fwDiags "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "golang.org/x/exp/maps" @@ -880,3 +881,16 @@ func DefaultProviderZone(_ context.Context, diff *schema.ResourceDiff, meta inte return nil } + +// id.UniqueId() returns a timestamp + incremental hash +// This function truncates the timestamp to provide a prefix + 9 using +// YYmmdd + last 3 digits of the incremental hash +func ReducedPrefixedUniqueId(prefix string) string { + // uniqueID is timestamp + 8 digit counter (YYYYmmddHHMMSSssss + 12345678) + uniqueId := id.PrefixedUniqueId("") + // last three digits of the counter (678) + counter := uniqueId[len(uniqueId)-3:] + // YYmmdd of date + date := uniqueId[2:8] + return prefix + date + counter +} diff --git a/google/transport/config.go b/google/transport/config.go index 947a062b9e1..5abac270f56 100644 --- a/google/transport/config.go +++ b/google/transport/config.go @@ -235,7 +235,6 @@ type Config struct { DataplexBasePath string DataprocBasePath string DataprocMetastoreBasePath string - DatastoreBasePath string DatastreamBasePath string DeploymentManagerBasePath string DialogflowBasePath string @@ -375,7 +374,6 @@ const DataPipelineBasePathKey = "DataPipeline" const DataplexBasePathKey = "Dataplex" const DataprocBasePathKey = "Dataproc" const DataprocMetastoreBasePathKey = "DataprocMetastore" -const DatastoreBasePathKey = "Datastore" const DatastreamBasePathKey = "Datastream" const DeploymentManagerBasePathKey = "DeploymentManager" const DialogflowBasePathKey = "Dialogflow" @@ -509,7 +507,6 @@ var DefaultBasePaths = map[string]string{ DataplexBasePathKey: "https://dataplex.googleapis.com/v1/", DataprocBasePathKey: "https://dataproc.googleapis.com/v1/", DataprocMetastoreBasePathKey: "https://metastore.googleapis.com/v1/", - DatastoreBasePathKey: "https://datastore.googleapis.com/v1/", DatastreamBasePathKey: "https://datastream.googleapis.com/v1/", DeploymentManagerBasePathKey: "https://www.googleapis.com/deploymentmanager/v2/", DialogflowBasePathKey: "https://dialogflow.googleapis.com/v2/", @@ -906,11 +903,6 @@ func SetEndpointDefaults(d *schema.ResourceData) error { "GOOGLE_DATAPROC_METASTORE_CUSTOM_ENDPOINT", }, DefaultBasePaths[DataprocMetastoreBasePathKey])) } - if d.Get("datastore_custom_endpoint") == "" { - d.Set("datastore_custom_endpoint", MultiEnvDefault([]string{ - "GOOGLE_DATASTORE_CUSTOM_ENDPOINT", - }, DefaultBasePaths[DatastoreBasePathKey])) - } if d.Get("datastream_custom_endpoint") == "" { d.Set("datastream_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_DATASTREAM_CUSTOM_ENDPOINT", @@ -2212,7 +2204,6 @@ func ConfigureBasePaths(c *Config) { c.DataplexBasePath = DefaultBasePaths[DataplexBasePathKey] c.DataprocBasePath = DefaultBasePaths[DataprocBasePathKey] c.DataprocMetastoreBasePath = DefaultBasePaths[DataprocMetastoreBasePathKey] - c.DatastoreBasePath = DefaultBasePaths[DatastoreBasePathKey] c.DatastreamBasePath = DefaultBasePaths[DatastreamBasePathKey] c.DeploymentManagerBasePath = DefaultBasePaths[DeploymentManagerBasePathKey] c.DialogflowBasePath = DefaultBasePaths[DialogflowBasePathKey] diff --git a/website/docs/d/vpc_access_connector.html.markdown b/website/docs/d/vpc_access_connector.html.markdown index b107af9a6a5..a44818a7a13 100644 --- a/website/docs/d/vpc_access_connector.html.markdown +++ b/website/docs/d/vpc_access_connector.html.markdown @@ -26,6 +26,8 @@ resource "google_vpc_access_connector" "connector" { ip_cidr_range = "10.8.0.0/28" network = "default" region = "us-central1" + min_instances = 2 + max_instances = 3 } ``` diff --git a/website/docs/guides/provider_reference.html.markdown b/website/docs/guides/provider_reference.html.markdown index 8b03ef43503..9adb671d0ae 100644 --- a/website/docs/guides/provider_reference.html.markdown +++ b/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/website/docs/guides/version_6_upgrade.html.markdown b/website/docs/guides/version_6_upgrade.html.markdown index d056ec29af1..8b9dfcbcdb9 100644 --- a/website/docs/guides/version_6_upgrade.html.markdown +++ b/website/docs/guides/version_6_upgrade.html.markdown @@ -88,9 +88,29 @@ terraform { ## Provider -### Provider-level change example header +### Compute: `name_prefix` max length has been extended from 37 to 54 characters -Description of the change and how users should adjust their configuration (if needed). +Affected resources: `google_compute_instance_template`, `google_compute_region_instance_template`, `google_compute_ssl_certificate`, +and `google_compute_region_ssl_certificate` + +Previously, the max length of `name_prefix` was 37 characters since the autogenerated UUID suffix was 26 characters which combined to +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 @@ -108,6 +128,10 @@ Description of the change and how users should adjust their configuration (if ne A `view` can no longer be created when `schema` contains required fields +### `allow_resource_tags_on_deletion` is now removed + +Resource tags are now always allowed on table deletion. + ## Resource: `google_bigquery_reservation` ### `multi_region_auxiliary` is now removed @@ -155,6 +179,17 @@ and then run `terraform apply` to apply the change. ## Resource: `google_cloud_run_v2_job` +### Job deletion now prevented by default with `deletion_protection` + +The field `deletion_protection` has been added with a default value of `true`. This field prevents +Terraform from destroying or recreating the Job. In 6.0.0, existing jobs will have +`deletion_protection` set to `true` during the next refresh unless otherwise set in configuration. + +**`deletion_protection` does NOT prevent deletion outside of Terraform.** + +To disable deletion protection, explicitly set this field to `false` in configuration +and then run `terraform apply` to apply the change. + ### retyped `containers.env` to SET from ARRAY Previously, `containers.env` was a list, making it order-dependent. It is now a set. @@ -163,6 +198,17 @@ If you were relying on accessing an individual environment variable by index (fo ## Resource: `google_cloud_run_v2_service` +### Service deletion now prevented by default with `deletion_protection` + +The field `deletion_protection` has been added with a default value of `true`. This field prevents +Terraform from destroying or recreating the Service. In 6.0.0, existing services will have +`deletion_protection` set to `true` during the next refresh unless otherwise set in configuration. + +**`deletion_protection` does NOT prevent deletion outside of Terraform.** + +To disable deletion protection, explicitly set this field to `false` in configuration +and then run `terraform apply` to apply the change. + ### `liveness_probe` no longer defaults from API Cloud Run does not provide a default value for liveness probe. Now removing this field @@ -174,6 +220,18 @@ Previously, `containers.env` was a list, making it order-dependent. It is now a If you were relying on accessing an individual environment variable by index (for example, `google_cloud_run_v2_service.template.containers.0.env.0.name`), then that will now need to by hash (for example, `google_cloud_run_v2_service.template.containers.0.env..name`). +## Resource: `google_composer_environment` + +### `ip_allocation_policy = []` is no longer valid configuration + +There was no functional difference between setting `ip_allocation_policy = []` and not setting `ip_allocation_policy` at all. Removing the field from configuration should not produce a diff. + +## Resources: `google_compute_instance_from_template` and `google_compute_instance_from_machine_image` + +### `network_interface.alias_ip_range, network_interface.access_config, attached_disk, guest_accelerator, service_account, scratch_disk` can no longer be set to an empty block `[]` + +`field = []` is no longer valid configuration for these fields. Removing the fields from configuration should not produce a diff. + ## Resource: `google_compute_subnetwork` ### `secondary_ip_range = []` is no longer valid configuration @@ -214,7 +272,7 @@ Support for the deletionProtectionEnabled field has been added. Redis clusters w ### Fields `min_throughput` and `max_throughput` no longer have default values -The fields `min_throughput` and `max_throughput` no longer have default values +The fields `min_throughput` and `max_throughput` no longer have default values set by the provider. This was necessary to add conflicting field validation, also described in this guide. @@ -224,7 +282,7 @@ will default to values present in data returned from the API. ### Conflicting field validation added for `min_throughput` and `min_instances`, and `max_throughput` and `max_instances` The provider will now enforce that `google_vpc_access_connector` resources can only -include one of `min_throughput` and `min_instances` and one of `max_throughput`and +include one of `min_throughput` and `min_instances` and one of `max_throughput` and `max_instances`. Previously if a user included all four fields in a resource block they would experience a permadiff. This is a result of how `min_instances` and `max_instances` fields' values take precedence in the API, and how the API calculates @@ -235,12 +293,138 @@ resource blocks that contain both fields in a conflicting pair, and remove one o The fields that are removed from the configuration will still have Computed values, that are derived from the API. +## Resource: `google_folder` + +### Folder deletion now prevented by default with `deletion_protection` + +The field `deletion_protection` has been added with a default value of `true`. This field prevents +Terraform from destroying or recreating the Folder. In 6.0.0, existing folders will have +`deletion_protection` set to `true` during the next refresh unless otherwise set in configuration. + +**`deletion_protection` does NOT prevent deletion outside of Terraform.** + +To disable deletion protection, explicitly set this field to `false` in configuration +and then run `terraform apply` to apply the change. + +## Resource: `google_storage_bucket` + +### `lifecycle_rule.condition.no_age` is now removed + +Previously `lifecycle_rule.condition.age` attribute was being set zero value by default and `lifecycle_rule.condition.no_age` was introduced to prevent that. +Now `lifecycle_rule.condition.no_age` is no longer supported and `lifecycle_rule.condition.age` won't set a zero value by default. +Removed in favor of the field `lifecycle_rule.condition.send_age_if_zero` which can be used to set zero value for `lifecycle_rule.condition.age` attribute. + +For a seamless update, if your state today uses `no_age=true`, update it to remove `no_age` and set `send_age_if_zero=false`. If you do not use `no_age=true`, you will need to add `send_age_if_zero=true` to your state to avoid any changes after updating to 6.0.0. + +## Resource: `google_container_cluster` + +### `advanced_datapath_observability_config.relay_mode` is now removed + +Previously, through `relay_mode` field usage, users could both enable Dataplane V2 +Flow Observability feature (that deploys Hubble relay component) and configure +managed load balancers. Due to users' needs to have better control over how +Hubble relay components shall be exposed in their clusters, managed load +balancer deployments are not supported anymore and users are expected to deploy +their own load balancers. + +If `advanced_datapath_observability_config` is defined, `enable_relay` is now a +required field instead and users are expected to use this field instead. + +Recommended migration from `relay_mode` to `enable_relay` depending on +`relay_mode` value: +* `DISABLED`: set `enable_relay` to `false` +* `INTERNAL_VPC_LB`: set `enable_relay` to `true` and define internal load + balancer with VPC scope +* `EXTERNAL_LB`: set `enable_relay` to `true` and define external load balancer + with public access + +See exported endpoints for Dataplane V2 Observability feature to learn what +target you might wish to expose with load balancers: +https://cloud.google.com/kubernetes-engine/docs/concepts/about-dpv2-observability#gke-dataplane-v2-observability-endpoints + +## Resource: `google_container_cluster` + +### Three label-related fields are now present + +* `resource_labels` field is non-authoritative and only manages the labels defined by +the users on the resource through Terraform. +* The new output-only `terraform_labels` field merges the labels defined by the users +on the resource through Terraform and the default labels configured on the provider. +* The new output-only `effective_labels` field lists all of labels present on the resource +in GCP, including the labels configured through Terraform, the system, and other clients. + +## Data source: `google_container_cluster` + +### Three label-related fields are now present + +All three of `resource_labels`, `effective_labels` and `terraform_labels` will now be present. +All of these three fields include all of the labels present on the resource in GCP including +the labels configured through Terraform, the system, and other clients, equivalent to +`effective_labels` on the resource. + +## Resource: `google_edgenetwork_network` + +### Three label-related fields are now present + +* `labels` field is non-authoritative and only manages the labels defined by +the users on the resource through Terraform. +* The new output-only `terraform_labels` field merges the labels defined by the users +on the resource through Terraform and the default labels configured on the provider. +* The new output-only `effective_labels` field lists all of labels present on the resource +in GCP, including the labels configured through Terraform, the system, and other clients. + +## Resource: `google_edgenetwork_subnet` + +### Three label-related fields are now present + +* `labels` field is non-authoritative and only manages the labels defined by +the users on the resource through Terraform. +* The new output-only `terraform_labels` field merges the labels defined by the users +on the resource through Terraform and the default labels configured on the provider. +* The new output-only `effective_labels` field lists all of labels present on the resource +in GCP, including the labels configured through Terraform, the system, and other clients. + +## Resource: `google_workstations_workstation_config` + +### `host.gce_instance.disable_ssh` now defaults to true + +* `disable_ssh` field now defaults to true. To enable SSH, please set `disable_ssh` to false. + ## Removals +### Resource: `google_alloydb_cluster` + +## `network` is now removed + +`network` has been removed in favor of `network_config.network` + ### Resource: `google_identity_platform_project_default_config` is now removed `google_identity_platform_project_default_config` is removed in favor of `google_identity_platform_project_config` +## Resource: `google_integrations_client` + +### `create_sample_worklfows` and `provision_gmek` is now removed + +`create_sample_worklfows` and `provision_gmek` is now removed in favor of `create_sample_integrations` + +## Resource: `google_project` + +### Project deletion now prevented by default with `deletion_policy` + +The field `skip_delete` is removed and the default value for `deletion_policy` is now +`PREVENT` instead of `DELETE`. The `PREVENT` value for `deletion_policy` stops Terraform +from deleting or recreating your project. Setting this field to `ABANDON` allows the +resource to be abandoned instead of deleted. To remove deletion protection entirely, +explicitly set this field to `DELETE` in your configuration and run `terraform apply`. A +`skip_delete` value of `false` can be changed to a `deletion_policy` value of `DELETE` and +a `skip_delete` value of `true` to a `deletion_policy` value of `ABANDON` for equivalent +behavior. + +### Resource: `google_datastore_index` is now removed + +`google_datastore_index` is removed in favor of `google_firestore_index` + ## Resource: `google_storage_bucket` ### `lifecycle_rule.condition.no_age` is now removed diff --git a/website/docs/r/access_context_manager_access_policy.html.markdown b/website/docs/r/access_context_manager_access_policy.html.markdown index bb457d7ef23..962ce0c627c 100644 --- a/website/docs/r/access_context_manager_access_policy.html.markdown +++ b/website/docs/r/access_context_manager_access_policy.html.markdown @@ -57,6 +57,7 @@ resource "google_project" "project" { project_id = "my-project-name" name = "my-project-name" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_access_context_manager_access_policy" "access-policy" { diff --git a/website/docs/r/active_directory_domain.html.markdown b/website/docs/r/active_directory_domain.html.markdown index c7fcdfe20fb..c5a22c4aec8 100644 --- a/website/docs/r/active_directory_domain.html.markdown +++ b/website/docs/r/active_directory_domain.html.markdown @@ -36,6 +36,7 @@ resource "google_active_directory_domain" "ad-domain" { domain_name = "tfgen.org.com" locations = ["us-central1"] reserved_ip_range = "192.168.255.0/24" + deletion_protection = false } ``` @@ -82,6 +83,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the domain. Defaults to true. +When a`terraform destroy` or `terraform apply` would delete the domain, +the command will fail if this field is not set to false in Terraform state. +When the field is set to true or unset in Terraform state, a `terraform apply` +or `terraform destroy` that would delete the domain will fail. +When the field is set to false, deleting the domain is allowed. + ## Attributes Reference diff --git a/website/docs/r/active_directory_domain_trust.html.markdown b/website/docs/r/active_directory_domain_trust.html.markdown index dbbcdf5d0cb..6c17ed2b255 100644 --- a/website/docs/r/active_directory_domain_trust.html.markdown +++ b/website/docs/r/active_directory_domain_trust.html.markdown @@ -43,6 +43,7 @@ resource "google_active_directory_domain_trust" "ad-domain-trust" { trust_direction = "OUTBOUND" trust_type = "FOREST" trust_handshake_secret = "Testing1!" + deletion_protection = false } ``` diff --git a/website/docs/r/active_directory_peering.html.markdown b/website/docs/r/active_directory_peering.html.markdown index 7154372a6fd..1dff7f730eb 100644 --- a/website/docs/r/active_directory_peering.html.markdown +++ b/website/docs/r/active_directory_peering.html.markdown @@ -39,6 +39,7 @@ resource "google_active_directory_peering" "ad-domain-peering" { domain_resource = google_active_directory_domain.ad-domain.name peering_id = "ad-domain-peering" authorized_network = google_compute_network.peered-network.id + deletion_protection = false labels = { foo = "bar" } @@ -50,6 +51,7 @@ resource "google_active_directory_domain" "ad-domain" { locations = ["us-central1"] reserved_ip_range = "192.168.255.0/24" authorized_networks = [google_compute_network.source-network.id] + deletion_protection = false } resource "google_compute_network" "peered-network" { @@ -75,6 +77,7 @@ resource "google_project" "peered-project" { project_id = "my-peered-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } ``` diff --git a/website/docs/r/alloydb_cluster.html.markdown b/website/docs/r/alloydb_cluster.html.markdown index 718a4d8e28d..e1a3a0d3cd1 100644 --- a/website/docs/r/alloydb_cluster.html.markdown +++ b/website/docs/r/alloydb_cluster.html.markdown @@ -177,8 +177,9 @@ resource "google_alloydb_cluster" "restored_from_backup" { resource "google_alloydb_cluster" "restored_via_pitr" { cluster_id = "alloydb-pitr-restored" location = "us-central1" - network = data.google_compute_network.default.id - + network_config { + network = data.google_compute_network.default.id + } restore_continuous_backup_source { cluster = google_alloydb_cluster.source.name point_in_time = "2023-08-03T19:19:00.094Z" @@ -212,7 +213,9 @@ resource "google_service_networking_connection" "vpc_connection" { resource "google_alloydb_cluster" "primary" { cluster_id = "alloydb-primary-cluster" location = "us-central1" - network = google_compute_network.default.id + network_config { + network = google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -230,7 +233,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "alloydb-secondary-cluster" location = "us-east1" - network = google_compute_network.default.id + network_config { + network = google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { @@ -293,13 +298,6 @@ The following arguments are supported: EncryptionConfig describes the encryption config of a cluster or a backup that is encrypted with a CMEK (customer-managed encryption key). Structure is [documented below](#nested_encryption_config). -* `network` - - (Optional, Deprecated) - The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form: - "projects/{projectNumber}/global/networks/{network_id}". - - ~> **Warning:** `network` is deprecated and will be removed in a future major release. Instead, use `network_config` to define the network configuration. - * `network_config` - (Optional) Metadata related to network configuration. diff --git a/website/docs/r/alloydb_instance.html.markdown b/website/docs/r/alloydb_instance.html.markdown index 8c753175271..11c0fde863d 100644 --- a/website/docs/r/alloydb_instance.html.markdown +++ b/website/docs/r/alloydb_instance.html.markdown @@ -87,7 +87,9 @@ resource "google_service_networking_connection" "vpc_connection" { resource "google_alloydb_cluster" "primary" { cluster_id = "alloydb-primary-cluster" location = "us-central1" - network = google_compute_network.default.id + network_config { + network = google_compute_network.default.id + } } resource "google_alloydb_instance" "primary" { @@ -105,7 +107,9 @@ resource "google_alloydb_instance" "primary" { resource "google_alloydb_cluster" "secondary" { cluster_id = "alloydb-secondary-cluster" location = "us-east1" - network = google_compute_network.default.id + network_config { + network = data.google_compute_network.default.id + } cluster_type = "SECONDARY" continuous_backup_config { diff --git a/website/docs/r/alloydb_user.html.markdown b/website/docs/r/alloydb_user.html.markdown index b4397ef47b4..8a25afffe3d 100644 --- a/website/docs/r/alloydb_user.html.markdown +++ b/website/docs/r/alloydb_user.html.markdown @@ -43,8 +43,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "alloydb-cluster" location = "us-central1" - network = google_compute_network.default.id - + network_config { + network = data.google_compute_network.default.id + } initial_user { password = "cluster_secret" } @@ -95,7 +96,9 @@ resource "google_alloydb_instance" "default" { resource "google_alloydb_cluster" "default" { cluster_id = "alloydb-cluster" location = "us-central1" - network = google_compute_network.default.id + network_config { + network = google_compute_network.default.id + } initial_user { password = "cluster_secret" diff --git a/website/docs/r/apigee_envgroup_attachment.html.markdown b/website/docs/r/apigee_envgroup_attachment.html.markdown index 75dd392a9f5..3e9cb6f45f4 100644 --- a/website/docs/r/apigee_envgroup_attachment.html.markdown +++ b/website/docs/r/apigee_envgroup_attachment.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "project" { name = "my-project" org_id = "" billing_account = "" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/website/docs/r/apigee_instance_attachment.html.markdown b/website/docs/r/apigee_instance_attachment.html.markdown index 28ddf33f1c0..43ec313c298 100644 --- a/website/docs/r/apigee_instance_attachment.html.markdown +++ b/website/docs/r/apigee_instance_attachment.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "project" { name = "my-project" org_id = "" billing_account = "" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown b/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown index e5c209d8382..270dde67ec4 100644 --- a/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown +++ b/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "project" { name = "my-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/website/docs/r/apigee_sync_authorization.html.markdown b/website/docs/r/apigee_sync_authorization.html.markdown index 9b259d189af..4f822f0b5b9 100644 --- a/website/docs/r/apigee_sync_authorization.html.markdown +++ b/website/docs/r/apigee_sync_authorization.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "project" { name = "my-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/website/docs/r/apigee_target_server.html.markdown b/website/docs/r/apigee_target_server.html.markdown index 0f65d473750..de712558da4 100644 --- a/website/docs/r/apigee_target_server.html.markdown +++ b/website/docs/r/apigee_target_server.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "project" { name = "my-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_project_service" "apigee" { diff --git a/website/docs/r/apikeys_key.html.markdown b/website/docs/r/apikeys_key.html.markdown index 21d1282f5e9..6ef6daf7dd6 100644 --- a/website/docs/r/apikeys_key.html.markdown +++ b/website/docs/r/apikeys_key.html.markdown @@ -28,7 +28,6 @@ A basic example of a android api keys key resource "google_apikeys_key" "primary" { name = "key" display_name = "sample-key" - project = google_project.basic.name restrictions { android_key_restrictions { @@ -45,12 +44,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "app" - name = "app" - org_id = "123456789" -} - ``` ## Example Usage - basic_key @@ -59,7 +52,6 @@ A basic example of a api keys key resource "google_apikeys_key" "primary" { name = "key" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -73,12 +65,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "app" - name = "app" - org_id = "123456789" -} - ``` ## Example Usage - ios_key @@ -87,7 +73,6 @@ A basic example of a ios api keys key resource "google_apikeys_key" "primary" { name = "key" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -101,12 +86,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "app" - name = "app" - org_id = "123456789" -} - ``` ## Example Usage - minimal_key @@ -115,13 +94,6 @@ A minimal example of a api keys key resource "google_apikeys_key" "primary" { name = "key" display_name = "sample-key" - project = google_project.basic.name -} - -resource "google_project" "basic" { - project_id = "app" - name = "app" - org_id = "123456789" } @@ -132,7 +104,6 @@ A basic example of a server api keys key resource "google_apikeys_key" "primary" { name = "key" display_name = "sample-key" - project = google_project.basic.name restrictions { api_targets { @@ -146,12 +117,6 @@ resource "google_apikeys_key" "primary" { } } -resource "google_project" "basic" { - project_id = "app" - name = "app" - org_id = "123456789" -} - ``` diff --git a/website/docs/r/app_engine_firewall_rule.html.markdown b/website/docs/r/app_engine_firewall_rule.html.markdown index 2fba359b068..9802626ff56 100644 --- a/website/docs/r/app_engine_firewall_rule.html.markdown +++ b/website/docs/r/app_engine_firewall_rule.html.markdown @@ -39,6 +39,7 @@ resource "google_project" "my_project" { project_id = "ae-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_app_engine_application" "app" { diff --git a/website/docs/r/app_engine_flexible_app_version.html.markdown b/website/docs/r/app_engine_flexible_app_version.html.markdown index 31e6189d97a..ab54b615de0 100644 --- a/website/docs/r/app_engine_flexible_app_version.html.markdown +++ b/website/docs/r/app_engine_flexible_app_version.html.markdown @@ -43,6 +43,7 @@ resource "google_project" "my_project" { project_id = "appeng-flex" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_app_engine_application" "app" { diff --git a/website/docs/r/apphub_service.html.markdown b/website/docs/r/apphub_service.html.markdown index 0a30a4f840f..7ea672c9868 100644 --- a/website/docs/r/apphub_service.html.markdown +++ b/website/docs/r/apphub_service.html.markdown @@ -40,6 +40,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } # Enable Compute API @@ -153,6 +154,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/website/docs/r/apphub_service_project_attachment.html.markdown b/website/docs/r/apphub_service_project_attachment.html.markdown index 0f1a83d6a79..cbb29da0722 100644 --- a/website/docs/r/apphub_service_project_attachment.html.markdown +++ b/website/docs/r/apphub_service_project_attachment.html.markdown @@ -36,6 +36,7 @@ resource "google_project" "service_project" { project_id ="project-1" name = "Service Project" org_id = "123456789" + deletion_policy = "DELETE" } resource "time_sleep" "wait_120s" { @@ -58,6 +59,7 @@ resource "google_project" "service_project_full" { project_id ="project-1" name = "Service Project Full" org_id = "123456789" + deletion_policy = "DELETE" } resource "time_sleep" "wait_120s" { diff --git a/website/docs/r/apphub_workload.html.markdown b/website/docs/r/apphub_workload.html.markdown index 601f45e8126..3351c66f3db 100644 --- a/website/docs/r/apphub_workload.html.markdown +++ b/website/docs/r/apphub_workload.html.markdown @@ -40,6 +40,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } # Enable Compute API @@ -171,6 +172,7 @@ resource "google_project" "service_project" { name = "Service Project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } # Enable Compute API diff --git a/website/docs/r/bigquery_reservation.html.markdown b/website/docs/r/bigquery_reservation.html.markdown index 89af961cbf0..7fd23494599 100644 --- a/website/docs/r/bigquery_reservation.html.markdown +++ b/website/docs/r/bigquery_reservation.html.markdown @@ -80,13 +80,6 @@ The following arguments are supported: (Optional) Maximum number of queries that are allowed to run concurrently in this reservation. This is a soft limit due to asynchronous nature of the system and various optimizations for small queries. Default value is 0 which means that concurrency will be automatically set based on the reservation size. -* `multi_region_auxiliary` - - (Optional, Deprecated) - Applicable only for reservations located within one of the BigQuery multi-regions (US or EU). - If set to true, this reservation is placed in the organization's secondary region which is designated for disaster recovery purposes. If false, this reservation is placed in the organization's default region. - - ~> **Warning:** `multi_region_auxiliary` is deprecated and will be removed in a future major release. This field is no longer supported by the BigQuery Reservation API. - * `edition` - (Optional) The edition type. Valid values are STANDARD, ENTERPRISE, ENTERPRISE_PLUS diff --git a/website/docs/r/billing_project_info.html.markdown b/website/docs/r/billing_project_info.html.markdown index 45202b4ac17..707197f5a42 100644 --- a/website/docs/r/billing_project_info.html.markdown +++ b/website/docs/r/billing_project_info.html.markdown @@ -36,6 +36,7 @@ resource "google_project" "project" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "123456789" + deletion_policy = "DELETE" lifecycle { ignore_changes = [billing_account] } @@ -70,7 +71,7 @@ The following arguments are supported: In addition to the arguments listed above, the following computed attributes are exported: -* `id` - an identifier for the resource with format `projects/{{project}}/billingInfo` +* `id` - an identifier for the resource with format `projects/{{project}}` ## Timeouts diff --git a/website/docs/r/cloud_asset_folder_feed.html.markdown b/website/docs/r/cloud_asset_folder_feed.html.markdown index 7f27cb88ae1..51be2f28624 100644 --- a/website/docs/r/cloud_asset_folder_feed.html.markdown +++ b/website/docs/r/cloud_asset_folder_feed.html.markdown @@ -71,6 +71,7 @@ resource "google_pubsub_topic" "feed_output" { resource "google_folder" "my_folder" { display_name = "Networking" parent = "organizations/123456789" + deletion_protection = false } # Find the project number of the project whose identity will be used for sending diff --git a/website/docs/r/cloud_run_v2_job.html.markdown b/website/docs/r/cloud_run_v2_job.html.markdown index 42e3fe60407..8ad16dc5dd8 100644 --- a/website/docs/r/cloud_run_v2_job.html.markdown +++ b/website/docs/r/cloud_run_v2_job.html.markdown @@ -40,6 +40,7 @@ To get more information about Job, see: resource "google_cloud_run_v2_job" "default" { name = "cloudrun-job" location = "us-central1" + deletion_protection = false template { template { @@ -62,6 +63,7 @@ resource "google_cloud_run_v2_job" "default" { resource "google_cloud_run_v2_job" "default" { name = "cloudrun-job" location = "us-central1" + deletion_protection = false template { template { @@ -96,7 +98,7 @@ resource "google_cloud_run_v2_job" "default" { resource "google_cloud_run_v2_job" "default" { name = "cloudrun-job" location = "us-central1" - + deletion_protection = false template { template{ volumes { @@ -176,6 +178,7 @@ resource "google_sql_database_instance" "instance" { resource "google_cloud_run_v2_job" "default" { name = "cloudrun-job" location = "us-central1" + deletion_protection = false template { template{ @@ -223,6 +226,7 @@ resource "google_compute_network" "custom_test" { resource "google_cloud_run_v2_job" "default" { name = "cloudrun-job" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { template{ @@ -252,6 +256,7 @@ resource "google_cloud_run_v2_job" "default" { resource "google_cloud_run_v2_job" "default" { name = "cloudrun-job" location = "us-central1" + deletion_protection = false template { template { @@ -318,6 +323,7 @@ resource "google_cloud_run_v2_job" "default" { provider = google-beta name = "cloudrun-job" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -352,6 +358,7 @@ resource "google_cloud_run_v2_job" "default" { provider = google-beta name = "cloudrun-job" location = "us-central1" + deletion_protection = false start_execution_token = "start-once-created" template { template { @@ -750,6 +757,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the job. Defaults to true. +When a`terraform destroy` or `terraform apply` would delete the job, +the command will fail if this field is not set to false in Terraform state. +When the field is set to true or unset in Terraform state, a `terraform apply` +or `terraform destroy` that would delete the job will fail. +When the field is set to false, deleting the job is allowed. + The `binary_authorization` block supports: diff --git a/website/docs/r/cloud_run_v2_service.html.markdown b/website/docs/r/cloud_run_v2_service.html.markdown index 4ddc326b92b..d891048e3a8 100644 --- a/website/docs/r/cloud_run_v2_service.html.markdown +++ b/website/docs/r/cloud_run_v2_service.html.markdown @@ -40,6 +40,7 @@ To get more information about Service, see: resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -61,6 +62,7 @@ resource "google_cloud_run_v2_service" "default" { resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -88,6 +90,7 @@ resource "google_cloud_run_v2_service" "default" { resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -177,6 +180,7 @@ resource "google_sql_database_instance" "instance" { resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false template { containers { @@ -222,6 +226,7 @@ resource "google_compute_network" "custom_test" { resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false launch_stage = "GA" template { containers { @@ -249,6 +254,7 @@ resource "google_cloud_run_v2_service" "default" { resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false template { containers { @@ -283,6 +289,7 @@ resource "google_cloud_run_v2_service" "default" { resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" template { @@ -343,6 +350,7 @@ resource "google_cloud_run_v2_service" "default" { provider = google-beta name = "cloudrun-service" location = "us-central1" + deletion_protection = false launch_stage = "BETA" ingress = "INGRESS_TRAFFIC_ALL" template { @@ -394,6 +402,7 @@ resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { @@ -435,6 +444,7 @@ resource "google_cloud_run_v2_service" "default" { name = "cloudrun-service" location = "us-central1" + deletion_protection = false ingress = "INGRESS_TRAFFIC_ALL" launch_stage = "BETA" @@ -1080,6 +1090,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the service. Defaults to true. +When a`terraform destroy` or `terraform apply` would delete the service, +the command will fail if this field is not set to false in Terraform state. +When the field is set to true or unset in Terraform state, a `terraform apply` +or `terraform destroy` that would delete the service will fail. +When the field is set to false, deleting the service is allowed. + The `binary_authorization` block supports: diff --git a/website/docs/r/compute_backend_service.html.markdown b/website/docs/r/compute_backend_service.html.markdown index 17585c4af03..696a907a2a1 100644 --- a/website/docs/r/compute_backend_service.html.markdown +++ b/website/docs/r/compute_backend_service.html.markdown @@ -73,6 +73,7 @@ resource "google_compute_backend_service" "default" { protocol = "HTTP" load_balancing_scheme = "EXTERNAL" iap { + enabled = true oauth2_client_id = "abc" oauth2_client_secret = "xyz" } @@ -277,7 +278,15 @@ resource "google_compute_backend_service" "default" { } } outlier_detection { - consecutive_errors = 2 + consecutive_errors = 2 + consecutive_gateway_failure = 5 + enforcing_consecutive_errors = 100 + enforcing_consecutive_gateway_failure = 0 + enforcing_success_rate = 100 + max_ejection_percent = 10 + success_rate_minimum_hosts = 5 + success_rate_request_volume = 100 + success_rate_stdev_factor = 1900 } } @@ -520,8 +529,6 @@ The following arguments are supported: Settings controlling eviction of unhealthy hosts from the load balancing pool. Applicable backend service types can be a global backend service with the loadBalancingScheme set to INTERNAL_SELF_MANAGED or EXTERNAL_MANAGED. - From version 6.0.0 outlierDetection default terraform values will be removed to match default GCP value. - Default values are enforce by GCP without providing them. Structure is [documented below](#nested_outlier_detection). * `port_name` - @@ -593,7 +600,6 @@ The following arguments are supported: and CONNECTION (for TCP/SSL). See the [Backend Services Overview](https://cloud.google.com/load-balancing/docs/backend-service#balancing-mode) for an explanation of load balancing modes. - From version 6.0.0 default value will be UTILIZATION to match default GCP value. Default value is `UTILIZATION`. Possible values are: `UTILIZATION`, `RATE`, `CONNECTION`. @@ -908,12 +914,16 @@ The following arguments are supported: The `iap` block supports: -* `oauth2_client_id` - +* `enabled` - (Required) + Whether the serving infrastructure will authenticate and authorize all incoming requests. + +* `oauth2_client_id` - + (Optional) OAuth2 Client ID for IAP * `oauth2_client_secret` - - (Required) + (Optional) OAuth2 Client Secret for IAP **Note**: This property is sensitive and will not be displayed in the plan. diff --git a/website/docs/r/compute_firewall_policy_rule.html.markdown b/website/docs/r/compute_firewall_policy_rule.html.markdown index 75b0aa0ed50..ba83b035d7c 100644 --- a/website/docs/r/compute_firewall_policy_rule.html.markdown +++ b/website/docs/r/compute_firewall_policy_rule.html.markdown @@ -37,6 +37,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a resource "google_folder" "folder" { display_name = "policy" parent = "organizations/123456789" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { diff --git a/website/docs/r/compute_instance_template.html.markdown b/website/docs/r/compute_instance_template.html.markdown index 36f3392a992..cd97bf4405e 100644 --- a/website/docs/r/compute_instance_template.html.markdown +++ b/website/docs/r/compute_instance_template.html.markdown @@ -295,7 +295,14 @@ The following arguments are supported: this blank, Terraform will auto-generate a unique name. * `name_prefix` - (Optional) Creates a unique name beginning with the specified - prefix. Conflicts with `name`. + prefix. Conflicts with `name`. Max length is 54 characters. + Prefixes with lengths longer than 37 characters will use a shortened + UUID that will be more prone to collisions. + + Resulting name for a `name_prefix` <= 37 characters: + `name_prefix` + YYYYmmddHHSSssss + 8 digit incremental counter + Resulting name for a `name_prefix` 38 - 54 characters: + `name_prefix` + YYmmdd + 3 digit incremental counter * `can_ip_forward` - (Optional) Whether to allow sending and receiving of packets with non-matching source or destination IPs. This defaults to false. diff --git a/website/docs/r/compute_network_attachment.html.markdown b/website/docs/r/compute_network_attachment.html.markdown index c7628c8703d..51b26425534 100644 --- a/website/docs/r/compute_network_attachment.html.markdown +++ b/website/docs/r/compute_network_attachment.html.markdown @@ -69,6 +69,7 @@ resource "google_project" "rejected_producer_project" { name = "prj-rejected" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_project" "accepted_producer_project" { @@ -76,6 +77,7 @@ resource "google_project" "accepted_producer_project" { name = "prj-accepted" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } ```
diff --git a/website/docs/r/compute_network_endpoints.html.markdown b/website/docs/r/compute_network_endpoints.html.markdown index 615d6e1a59a..8245e507ffe 100644 --- a/website/docs/r/compute_network_endpoints.html.markdown +++ b/website/docs/r/compute_network_endpoints.html.markdown @@ -170,7 +170,7 @@ The following arguments are supported: In addition to the arguments listed above, the following computed attributes are exported: -* `id` - an identifier for the resource with format `{{project}}/{{zone}}/{{network_endpoint_group}}/endpoints` +* `id` - an identifier for the resource with format `{{project}}/{{zone}}/{{network_endpoint_group}}` ## Timeouts diff --git a/website/docs/r/compute_node_group.html.markdown b/website/docs/r/compute_node_group.html.markdown index 53085d3b0b0..9ea19105d39 100644 --- a/website/docs/r/compute_node_group.html.markdown +++ b/website/docs/r/compute_node_group.html.markdown @@ -120,6 +120,7 @@ resource "google_project" "guest_project" { project_id = "project-id" name = "project-name" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_compute_node_template" "soletenant-tmpl" { diff --git a/website/docs/r/compute_organization_security_policy_association.html.markdown b/website/docs/r/compute_organization_security_policy_association.html.markdown index b2c358e9c49..d4c50e4c09b 100644 --- a/website/docs/r/compute_organization_security_policy_association.html.markdown +++ b/website/docs/r/compute_organization_security_policy_association.html.markdown @@ -38,6 +38,7 @@ resource "google_folder" "security_policy_target" { provider = google-beta display_name = "tf-test-secpol-%{random_suffix}" parent = "organizations/123456789" + deletion_protection = false } resource "google_compute_organization_security_policy" "policy" { diff --git a/website/docs/r/compute_project_cloud_armor_tier.html.markdown b/website/docs/r/compute_project_cloud_armor_tier.html.markdown index 1e977a57707..92155f9b5d3 100644 --- a/website/docs/r/compute_project_cloud_armor_tier.html.markdown +++ b/website/docs/r/compute_project_cloud_armor_tier.html.markdown @@ -45,6 +45,7 @@ resource "google_project" "project" { name = "your_project_id" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { diff --git a/website/docs/r/compute_region_backend_service.html.markdown b/website/docs/r/compute_region_backend_service.html.markdown index de576b40df2..365f29f602c 100644 --- a/website/docs/r/compute_region_backend_service.html.markdown +++ b/website/docs/r/compute_region_backend_service.html.markdown @@ -76,6 +76,7 @@ resource "google_compute_region_backend_service" "default" { protocol = "HTTP" load_balancing_scheme = "EXTERNAL" iap { + enabled = true oauth2_client_id = "abc" oauth2_client_secret = "xyz" } @@ -423,7 +424,6 @@ The following arguments are supported: (Optional) Time for which instance will be drained (not accept new connections, but still work to finish started). - From version 6.0.0 ConnectionDrainingTimeoutSec default value will be 300 to match default GCP value. * `description` - (Optional) @@ -513,8 +513,6 @@ The following arguments are supported: Settings controlling eviction of unhealthy hosts from the load balancing pool. This field is applicable only when the `load_balancing_scheme` is set to INTERNAL_MANAGED and the `protocol` is set to HTTP, HTTPS, or HTTP2. - From version 6.0.0 outlierDetection default terraform values will be removed to match default GCP value. - Default values are enforce by GCP without providing them. Structure is [documented below](#nested_outlier_detection). * `port_name` - @@ -590,8 +588,7 @@ The following arguments are supported: Specifies the balancing mode for this backend. See the [Backend Services Overview](https://cloud.google.com/load-balancing/docs/backend-service#balancing-mode) for an explanation of load balancing modes. - From version 6.0.0 default value will be UTILIZATION to match default GCP value. - Default value is `CONNECTION`. + Default value is `UTILIZATION`. Possible values are: `UTILIZATION`, `RATE`, `CONNECTION`. * `capacity_scaler` - @@ -935,12 +932,16 @@ The following arguments are supported: The `iap` block supports: -* `oauth2_client_id` - +* `enabled` - (Required) + Whether the serving infrastructure will authenticate and authorize all incoming requests. + +* `oauth2_client_id` - + (Optional) OAuth2 Client ID for IAP * `oauth2_client_secret` - - (Required) + (Optional) OAuth2 Client Secret for IAP **Note**: This property is sensitive and will not be displayed in the plan. diff --git a/website/docs/r/compute_region_instance_template.html.markdown b/website/docs/r/compute_region_instance_template.html.markdown index 74384427c13..c7ebb9e0c3d 100644 --- a/website/docs/r/compute_region_instance_template.html.markdown +++ b/website/docs/r/compute_region_instance_template.html.markdown @@ -307,7 +307,14 @@ The following arguments are supported: this blank, Terraform will auto-generate a unique name. * `name_prefix` - (Optional) Creates a unique name beginning with the specified - prefix. Conflicts with `name`. + prefix. Conflicts with `name`. Max length is 54 characters. + Prefixes with lengths longer than 37 characters will use a shortened + UUID that will be more prone to collisions. + + Resulting name for a `name_prefix` <= 37 characters: + `name_prefix` + YYYYmmddHHSSssss + 8 digit incremental counter + Resulting name for a `name_prefix` 38 - 54 characters: + `name_prefix` + YYmmdd + 3 digit incremental counter * `can_ip_forward` - (Optional) Whether to allow sending and receiving of packets with non-matching source or destination IPs. This defaults to false. diff --git a/website/docs/r/compute_region_ssl_certificate.html.markdown b/website/docs/r/compute_region_ssl_certificate.html.markdown index 65210568883..02ae5444d55 100644 --- a/website/docs/r/compute_region_ssl_certificate.html.markdown +++ b/website/docs/r/compute_region_ssl_certificate.html.markdown @@ -214,7 +214,13 @@ The following arguments are supported: If it is not provided, the provider project is used. * `name_prefix` - (Optional) Creates a unique name beginning with the - specified prefix. Conflicts with `name`. + specified prefix. Conflicts with `name`. Max length is 54 characters. + Prefixes with lengths longer than 37 characters will use a shortened + UUID that will be more prone to collisions. + Resulting name for a `name_prefix` <= 37 characters: + `name_prefix` + YYYYmmddHHSSssss + 8 digit incremental counter + Resulting name for a `name_prefix` 38 - 54 characters: + `name_prefix` + YYmmdd + 3 digit incremental counter ## Attributes Reference diff --git a/website/docs/r/compute_ssl_certificate.html.markdown b/website/docs/r/compute_ssl_certificate.html.markdown index db3205a65ee..e96d17f09cd 100644 --- a/website/docs/r/compute_ssl_certificate.html.markdown +++ b/website/docs/r/compute_ssl_certificate.html.markdown @@ -201,7 +201,13 @@ The following arguments are supported: If it is not provided, the provider project is used. * `name_prefix` - (Optional) Creates a unique name beginning with the - specified prefix. Conflicts with `name`. + specified prefix. Conflicts with `name`. Max length is 54 characters. + Prefixes with lengths longer than 37 characters will use a shortened + UUID that will be more prone to collisions. + Resulting name for a `name_prefix` <= 37 characters: + `name_prefix` + YYYYmmddHHSSssss + 8 digit incremental counter + Resulting name for a `name_prefix` 38 - 54 characters: + `name_prefix` + YYmmdd + 3 digit incremental counter ## Attributes Reference diff --git a/website/docs/r/compute_subnetwork.html.markdown b/website/docs/r/compute_subnetwork.html.markdown index c9c8552acea..bbf57357397 100644 --- a/website/docs/r/compute_subnetwork.html.markdown +++ b/website/docs/r/compute_subnetwork.html.markdown @@ -235,19 +235,99 @@ resource "google_compute_network" "net-cidr-overlap" { auto_create_subnetworks = false } ``` + +## Example Usage - Subnetwork Reserved Internal Range + + +```hcl +resource "google_compute_subnetwork" "subnetwork-reserved-internal-range" { + provider = google-beta + name = "subnetwork-reserved-internal-range" + region = "us-central1" + network = google_compute_network.default.id + reserved_internal_range = "networkconnectivity.googleapis.com/${google_network_connectivity_internal_range.reserved.id}" +} + +resource "google_compute_network" "default" { + provider = google-beta + name = "network-reserved-internal-range" + auto_create_subnetworks = false +} + +resource "google_network_connectivity_internal_range" "reserved" { + provider = google-beta + name = "reserved" + network = google_compute_network.default.id + usage = "FOR_VPC" + peering = "FOR_SELF" + prefix_length = 24 + target_cidr_range = [ + "10.0.0.0/8" + ] +} +``` + +## Example Usage - Subnetwork Reserved Secondary Range + + +```hcl +resource "google_compute_subnetwork" "subnetwork-reserved-secondary-range" { + provider = google-beta + name = "subnetwork-reserved-secondary-range" + region = "us-central1" + network = google_compute_network.default.id + reserved_internal_range = "networkconnectivity.googleapis.com/${google_network_connectivity_internal_range.reserved.id}" + + secondary_ip_range { + range_name = "secondary" + reserved_internal_range = "networkconnectivity.googleapis.com/${google_network_connectivity_internal_range.reserved_secondary.id}" + } +} + +resource "google_compute_network" "default" { + provider = google-beta + name = "network-reserved-secondary-range" + auto_create_subnetworks = false +} + +resource "google_network_connectivity_internal_range" "reserved" { + provider = google-beta + name = "reserved" + network = google_compute_network.default.id + usage = "FOR_VPC" + peering = "FOR_SELF" + prefix_length = 24 + target_cidr_range = [ + "10.0.0.0/8" + ] +} + +resource "google_network_connectivity_internal_range" "reserved_secondary" { + provider = google-beta + name = "reserved-secondary" + network = google_compute_network.default.id + usage = "FOR_VPC" + peering = "FOR_SELF" + prefix_length = 16 + target_cidr_range = [ + "10.0.0.0/8" + ] +} +``` ## Argument Reference The following arguments are supported: -* `ip_cidr_range` - - (Required) - The range of internal addresses that are owned by this subnetwork. - Provide this property when you create the subnetwork. For example, - 10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and - non-overlapping within a network. Only IPv4 is supported. - * `name` - (Required) The name of the resource, provided by the client when initially @@ -273,6 +353,19 @@ The following arguments are supported: you create the resource. This field can be set only at resource creation time. +* `ip_cidr_range` - + (Optional) + The range of internal addresses that are owned by this subnetwork. + Provide this property when you create the subnetwork. For example, + 10.0.0.0/8 or 192.168.0.0/16. Ranges must be unique and + non-overlapping within a network. Only IPv4 is supported. + Field is optional when `reserved_internal_range` is defined, otherwise required. + +* `reserved_internal_range` - + (Optional) + The ID of the reserved internal range. Must be prefixed with `networkconnectivity.googleapis.com` + E.g. `networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}` + * `purpose` - (Optional) The purpose of the resource. This field can be either `PRIVATE_RFC_1918`, `REGIONAL_MANAGED_PROXY`, `GLOBAL_MANAGED_PROXY`, `PRIVATE_SERVICE_CONNECT` or `PRIVATE_NAT`([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). @@ -369,11 +462,17 @@ Defaults to false. must be unique within the subnetwork. * `ip_cidr_range` - - (Required) + (Optional) The range of IP addresses belonging to this subnetwork secondary range. Provide this property when you create the subnetwork. Ranges must be unique and non-overlapping with all primary and secondary IP ranges within a network. Only IPv4 is supported. + Field is optional when `reserved_internal_range` is defined, otherwise required. + +* `reserved_internal_range` - + (Optional) + The ID of the reserved internal range. Must be prefixed with `networkconnectivity.googleapis.com` + E.g. `networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}` The `log_config` block supports: diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 0554f7aa153..b11194f5992 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -328,6 +328,15 @@ channel. Structure is [documented below](#nested_release_channel). * `resource_labels` - (Optional) The GCE resource labels (a map of key/value pairs) to be applied to the cluster. + **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. + Please refer to the field 'effective_labels' for all of the labels present on the resource. + +* `terraform_labels` - + The combination of labels configured directly on the resource and default labels configured on the provider. + +* `effective_labels` - + All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. + * `cost_management_config` - (Optional) Configuration for the [Cost Allocation](https://cloud.google.com/kubernetes-engine/docs/how-to/cost-allocations) feature. Structure is [documented below](#nested_cost_management_config). @@ -645,8 +654,7 @@ This block also contains several computed attributes, documented below. The `advanced_datapath_observability_config` block supports: * `enable_metrics` - (Required) Whether or not to enable advanced datapath metrics. -* `enable_relay` - (Optional) Whether or not Relay is enabled. -* `relay_mode` - (Optional, Deprecated) Mode used to make Relay available. Deprecated in favor of `enable_relay` field. Remove this attribute's configuration as this field will be removed in the next major release and `enable_relay` will become a required field. +* `enable_relay` - (Required) Whether or not Relay is enabled. The `maintenance_policy` block supports: * `daily_maintenance_window` - (Optional) structure documented below. diff --git a/website/docs/r/datastore_index.html.markdown b/website/docs/r/datastore_index.html.markdown deleted file mode 100644 index 61adbb20bc8..00000000000 --- a/website/docs/r/datastore_index.html.markdown +++ /dev/null @@ -1,160 +0,0 @@ ---- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** Type: MMv1 *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file in -# .github/CONTRIBUTING.md. -# -# ---------------------------------------------------------------------------- -subcategory: "Datastore" -description: |- - Describes a composite index for Firestore in Datastore Mode. ---- - -# google_datastore_index -~> **Warning:** `datastore_index` is deprecated and will be removed in a future major release. Use `firestore_index` instead; this resource is deprecated because it only supports the (default) database. `firestore_index` supports both Firestore in Datastore Mode and Firestore Native indexes and supports both named and the (default) database. - -Describes a composite index for Firestore in Datastore Mode. - - -To get more information about Index, see: - -* [API documentation](https://cloud.google.com/datastore/docs/reference/admin/rest/v1/projects.indexes) -* How-to Guides - * [Official Documentation](https://cloud.google.com/datastore/docs/concepts/indexes) - -~> **Warning:** `datastore_index` is deprecated and will be removed in a future major release. -Use `firestore_index` instead; this resource is deprecated because it only supports the (default) database. -This resource creates a Datastore Index on a project that has already -enabled a Datastore-compatible database. If you haven't already created it, you may -create a `google_firestore_database` resource with `location_id` set -to your chosen location, and `type` set to `"DATASTORE_MODE"`. -If you wish to use App Engine, you may instead create a `google_app_engine_application` resource with -`database_type` set to `"CLOUD_DATASTORE_COMPATIBILITY"`. -Your Datastore location will be the same as the App Engine location specified. - -## Example Usage - Datastore Index - - -```hcl -resource "google_firestore_database" "database" { - project = "my-project-name" - # google_datastore_index resources only support the (default) database. - # However, google_firestore_index can express any Datastore Mode index - # and should be preferred in all cases. - name = "(default)" - location_id = "nam5" - type = "DATASTORE_MODE" - - delete_protection_state = "DELETE_PROTECTION_DISABLED" - deletion_policy = "DELETE" -} - -resource "google_datastore_index" "default" { - kind = "foo" - properties { - name = "property_a" - direction = "ASCENDING" - } - properties { - name = "property_b" - direction = "ASCENDING" - } - - depends_on = [google_firestore_database.database] -} -``` - -## Argument Reference - -The following arguments are supported: - - -* `kind` - - (Required) - The entity kind which the index applies to. - - -- - - - - -* `ancestor` - - (Optional) - Policy for including ancestors in the index. - Default value is `NONE`. - Possible values are: `NONE`, `ALL_ANCESTORS`. - -* `properties` - - (Optional) - An ordered list of properties to index on. - Structure is [documented below](#nested_properties). - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the provider project is used. - - -The `properties` block supports: - -* `name` - - (Required) - The property name to index. - -* `direction` - - (Required) - The direction the index should optimize for sorting. - Possible values are: `ASCENDING`, `DESCENDING`. - -## Attributes Reference - -In addition to the arguments listed above, the following computed attributes are exported: - -* `id` - an identifier for the resource with format `projects/{{project}}/indexes/{{index_id}}` - -* `index_id` - - The index id. - - -## Timeouts - -This resource provides the following -[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: - -- `create` - Default is 20 minutes. -- `delete` - Default is 20 minutes. - -## Import - - -Index can be imported using any of these accepted formats: - -* `projects/{{project}}/indexes/{{index_id}}` -* `{{project}}/{{index_id}}` -* `{{index_id}}` - - -In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Index using one of the formats above. For example: - -```tf -import { - id = "projects/{{project}}/indexes/{{index_id}}" - to = google_datastore_index.default -} -``` - -When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Index can be imported using one of the formats above. For example: - -``` -$ terraform import google_datastore_index.default projects/{{project}}/indexes/{{index_id}} -$ terraform import google_datastore_index.default {{project}}/{{index_id}} -$ terraform import google_datastore_index.default {{index_id}} -``` - -## User Project Overrides - -This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). diff --git a/website/docs/r/dialogflow_intent.html.markdown b/website/docs/r/dialogflow_intent.html.markdown index eb35acb0d0f..4032041b1ab 100644 --- a/website/docs/r/dialogflow_intent.html.markdown +++ b/website/docs/r/dialogflow_intent.html.markdown @@ -52,6 +52,7 @@ resource "google_project" "agent_project" { project_id = "my-project" name = "my-project" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_project_service" "agent_project" { diff --git a/website/docs/r/edgenetwork_network.html.markdown b/website/docs/r/edgenetwork_network.html.markdown index bfdefd7d3ed..cb3bc840b69 100644 --- a/website/docs/r/edgenetwork_network.html.markdown +++ b/website/docs/r/edgenetwork_network.html.markdown @@ -69,6 +69,9 @@ The following arguments are supported: (Optional) Labels associated with this resource. + **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. + Please refer to the field `effective_labels` for all of the labels present on the resource. + * `description` - (Optional) A free-text description of the resource. Max length 1024 characters. @@ -101,6 +104,13 @@ In addition to the arguments listed above, the following computed attributes are A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`. +* `terraform_labels` - + The combination of labels configured directly on the resource + and default labels configured on the provider. + +* `effective_labels` - + All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. + ## Timeouts @@ -108,6 +118,7 @@ This resource provides the following [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: - `create` - Default is 20 minutes. +- `update` - Default is 20 minutes. - `delete` - Default is 30 minutes. ## Import diff --git a/website/docs/r/edgenetwork_subnet.html.markdown b/website/docs/r/edgenetwork_subnet.html.markdown index 938d66e3d20..934099fb15b 100644 --- a/website/docs/r/edgenetwork_subnet.html.markdown +++ b/website/docs/r/edgenetwork_subnet.html.markdown @@ -110,6 +110,9 @@ The following arguments are supported: (Optional) Labels associated with this resource. + **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. + Please refer to the field `effective_labels` for all of the labels present on the resource. + * `description` - (Optional) A free-text description of the resource. Max length 1024 characters. @@ -153,6 +156,13 @@ In addition to the arguments listed above, the following computed attributes are * `state` - Current stage of the resource to the device by config push. +* `terraform_labels` - + The combination of labels configured directly on the resource + and default labels configured on the provider. + +* `effective_labels` - + All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. + ## Timeouts @@ -160,6 +170,7 @@ This resource provides the following [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: - `create` - Default is 20 minutes. +- `update` - Default is 20 minutes. - `delete` - Default is 30 minutes. ## Import diff --git a/website/docs/r/firebase_database_instance.html.markdown b/website/docs/r/firebase_database_instance.html.markdown index 92940b026e8..94f7ac8a27e 100644 --- a/website/docs/r/firebase_database_instance.html.markdown +++ b/website/docs/r/firebase_database_instance.html.markdown @@ -63,6 +63,7 @@ resource "google_project" "default" { project_id = "rtdb-project" name = "rtdb-project" org_id = "123456789" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" } diff --git a/website/docs/r/firebase_hosting_custom_domain.html.markdown b/website/docs/r/firebase_hosting_custom_domain.html.markdown index 35d8183b278..e39cadaa8d5 100644 --- a/website/docs/r/firebase_hosting_custom_domain.html.markdown +++ b/website/docs/r/firebase_hosting_custom_domain.html.markdown @@ -91,6 +91,8 @@ resource "google_cloud_run_v2_service" "default" { image = "us-docker.pkg.dev/cloudrun/container/hello" } } + + deletion_protection = "true" } resource "google_firebase_hosting_version" "default" { diff --git a/website/docs/r/firebase_hosting_version.html.markdown b/website/docs/r/firebase_hosting_version.html.markdown index 0107275d361..5907d4efddf 100644 --- a/website/docs/r/firebase_hosting_version.html.markdown +++ b/website/docs/r/firebase_hosting_version.html.markdown @@ -111,6 +111,8 @@ resource "google_cloud_run_v2_service" "default" { image = "us-docker.pkg.dev/cloudrun/container/hello" } } + + deletion_protection = "true" } resource "google_firebase_hosting_version" "default" { diff --git a/website/docs/r/firebase_project.html.markdown b/website/docs/r/firebase_project.html.markdown index 0c434dc17b2..ee2473892c8 100644 --- a/website/docs/r/firebase_project.html.markdown +++ b/website/docs/r/firebase_project.html.markdown @@ -47,6 +47,7 @@ resource "google_project" "default" { project_id = "my-project" name = "my-project" org_id = "123456789" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" diff --git a/website/docs/r/firestore_document.html.markdown b/website/docs/r/firestore_document.html.markdown index 5c250395a38..49c66a920ec 100644 --- a/website/docs/r/firestore_document.html.markdown +++ b/website/docs/r/firestore_document.html.markdown @@ -46,6 +46,7 @@ resource "google_project" "project" { project_id = "project-id" name = "project-id" org_id = "123456789" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { @@ -87,6 +88,7 @@ resource "google_project" "project" { project_id = "project-id" name = "project-id" org_id = "123456789" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/website/docs/r/folder_access_approval_settings.html.markdown b/website/docs/r/folder_access_approval_settings.html.markdown index 53f0bbcb814..45962194c6b 100644 --- a/website/docs/r/folder_access_approval_settings.html.markdown +++ b/website/docs/r/folder_access_approval_settings.html.markdown @@ -33,6 +33,7 @@ To get more information about FolderSettings, see: resource "google_folder" "my_folder" { display_name = "my-folder" parent = "organizations/123456789" + deletion_protection = false } resource "google_folder_access_approval_settings" "folder_access_approval" { @@ -51,12 +52,14 @@ resource "google_folder_access_approval_settings" "folder_access_approval" { resource "google_folder" "my_folder" { display_name = "my-folder" parent = "organizations/123456789" + deletion_protection = false } resource "google_project" "my_project" { name = "My Project" project_id = "your-project-id" folder_id = google_folder.my_folder.name + deletion_policy = "DELETE" } resource "google_kms_key_ring" "key_ring" { diff --git a/website/docs/r/google_project.html.markdown b/website/docs/r/google_project.html.markdown index fff53a4a887..6d45074bb2d 100644 --- a/website/docs/r/google_project.html.markdown +++ b/website/docs/r/google_project.html.markdown @@ -78,12 +78,6 @@ The following arguments are supported: See [Google Cloud Billing API Access Control](https://cloud.google.com/billing/docs/how-to/billing-access) for more details. -* `skip_delete` - (Optional) If true, the Terraform resource can be deleted without - deleting the Project via the Google API. `skip_delete` is deprecated and will be - removed in 6.0.0. Please use deletion_policy instead. A `skip_delete` value of `false` - can be changed to a `deletion_policy` value of `DELETE` and a `skip_delete` value of `true` - to a `deletion_policy` value of `ABANDON` for equivalent behavior. - * `labels` - (Optional) A set of key/value label pairs to assign to the project. **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field 'effective_labels' for all of the labels present on the resource. @@ -104,7 +98,7 @@ The following arguments are supported: * `deletion_policy` - (Optional) The deletion policy for the Project. Setting PREVENT will protect the project against any destroy actions caused by a terraform apply or terraform destroy. Setting ABANDON allows the resource to be abandoned rather than deleted, i.e., the Terraform resource can be deleted without deleting the Project via - the Google API. Possible values are: "PREVENT", "ABANDON", "DELETE". Default value is `DELETE`. + the Google API. Possible values are: "PREVENT", "ABANDON", "DELETE". Default value is `PREVENT`. ## Attributes Reference diff --git a/website/docs/r/iam_access_boundary_policy.html.markdown b/website/docs/r/iam_access_boundary_policy.html.markdown index 552ed7e440a..e9f8797de84 100644 --- a/website/docs/r/iam_access_boundary_policy.html.markdown +++ b/website/docs/r/iam_access_boundary_policy.html.markdown @@ -34,6 +34,7 @@ resource "google_project" "project" { name = "my-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_access_context_manager_access_level" "test-access" { diff --git a/website/docs/r/iam_deny_policy.html.markdown b/website/docs/r/iam_deny_policy.html.markdown index db7b821ccbe..b0a28ff6ef0 100644 --- a/website/docs/r/iam_deny_policy.html.markdown +++ b/website/docs/r/iam_deny_policy.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "project" { name = "my-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_iam_deny_policy" "example" { diff --git a/website/docs/r/iap_brand.html.markdown b/website/docs/r/iap_brand.html.markdown index 09a9588468b..8d1438ebb37 100644 --- a/website/docs/r/iap_brand.html.markdown +++ b/website/docs/r/iap_brand.html.markdown @@ -44,6 +44,7 @@ resource "google_project" "project" { project_id = "my-project" name = "my-project" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_project_service" "project_service" { diff --git a/website/docs/r/iap_client.html.markdown b/website/docs/r/iap_client.html.markdown index f2fa91014ae..96ac1127076 100644 --- a/website/docs/r/iap_client.html.markdown +++ b/website/docs/r/iap_client.html.markdown @@ -44,6 +44,7 @@ resource "google_project" "project" { project_id = "my-project" name = "my-project" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_project_service" "project_service" { diff --git a/website/docs/r/identity_platform_config.html.markdown b/website/docs/r/identity_platform_config.html.markdown index 4c7310ce82f..910f078afe1 100644 --- a/website/docs/r/identity_platform_config.html.markdown +++ b/website/docs/r/identity_platform_config.html.markdown @@ -47,6 +47,7 @@ resource "google_project" "default" { name = "my-project" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" labels = { firebase = "enabled" } diff --git a/website/docs/r/identity_platform_project_default_config.html.markdown b/website/docs/r/identity_platform_project_default_config.html.markdown deleted file mode 100644 index 552ddf3a93c..00000000000 --- a/website/docs/r/identity_platform_project_default_config.html.markdown +++ /dev/null @@ -1,203 +0,0 @@ ---- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** Type: MMv1 *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file in -# .github/CONTRIBUTING.md. -# -# ---------------------------------------------------------------------------- -subcategory: "Identity Platform" -description: |- - There is no persistent data associated with this resource. ---- - -# google_identity_platform_project_default_config -~> **Warning:** `google_identity_platform_config` is deprecated and will be removed in the next major release of the provider. Use the `google_identity_platform_config` resource instead. It contains a more comprehensive list of fields, and was created before `google_identity_platform_project_default_config` was added. - -There is no persistent data associated with this resource. - - - -~> **Warning:** If you are using User ADCs (Application Default Credentials) with this resource, -you must specify a `billing_project` and set `user_project_override` to true -in the provider configuration. Otherwise the ACM API will return a 403 error. -Your account must have the `serviceusage.services.use` permission on the -`billing_project` you defined. - -## Example Usage - Identity Platform Project Default Config - - -```hcl -resource "google_identity_platform_project_default_config" "default" { - sign_in { - allow_duplicate_emails = true - - anonymous { - enabled = true - } - - email { - enabled = true - password_required = false - } - - phone_number { - enabled = true - test_phone_numbers = { - "+11231231234" = "000000" - } - } - } -} -``` - -## Argument Reference - -The following arguments are supported: - - - -- - - - - -* `sign_in` - - (Optional) - Configuration related to local sign in methods. - Structure is [documented below](#nested_sign_in). - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the provider project is used. - - -The `sign_in` block supports: - -* `email` - - (Optional) - Configuration options related to authenticating a user by their email address. - Structure is [documented below](#nested_email). - -* `phone_number` - - (Optional) - Configuration options related to authenticated a user by their phone number. - Structure is [documented below](#nested_phone_number). - -* `anonymous` - - (Optional) - Configuration options related to authenticating an anonymous user. - Structure is [documented below](#nested_anonymous). - -* `allow_duplicate_emails` - - (Optional) - Whether to allow more than one account to have the same email. - -* `hash_config` - - (Output) - Output only. Hash config information. - Structure is [documented below](#nested_hash_config). - - -The `email` block supports: - -* `enabled` - - (Optional) - Whether email auth is enabled for the project or not. - -* `password_required` - - (Optional) - Whether a password is required for email auth or not. If true, both an email and - password must be provided to sign in. If false, a user may sign in via either - email/password or email link. - -The `phone_number` block supports: - -* `enabled` - - (Optional) - Whether phone number auth is enabled for the project or not. - -* `test_phone_numbers` - - (Optional) - A map of that can be used for phone auth testing. - -The `anonymous` block supports: - -* `enabled` - - (Required) - Whether anonymous user auth is enabled for the project or not. - -The `hash_config` block contains: - -* `algorithm` - - (Output) - Different password hash algorithms used in Identity Toolkit. - -* `signer_key` - - (Output) - Signer key in base64. - -* `salt_separator` - - (Output) - Non-printable character to be inserted between the salt and plain text password in base64. - -* `rounds` - - (Output) - How many rounds for hash calculation. Used by scrypt and other similar password derivation algorithms. - -* `memory_cost` - - (Output) - Memory cost for hash calculation. Used by scrypt and other similar password derivation algorithms. See https://tools.ietf.org/html/rfc7914 for explanation of field. - -## Attributes Reference - -In addition to the arguments listed above, the following computed attributes are exported: - -* `id` - an identifier for the resource with format `{{project}}` - -* `name` - - The name of the Config resource. Example: "projects/my-awesome-project/config" - - -## Timeouts - -This resource provides the following -[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: - -- `create` - Default is 20 minutes. -- `update` - Default is 20 minutes. -- `delete` - Default is 20 minutes. - -## Import - - -ProjectDefaultConfig can be imported using any of these accepted formats: - -* `projects/{{project}}/config/{{name}}` -* `{{project}}/{{name}}` -* `{{name}}` - - -In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import ProjectDefaultConfig using one of the formats above. For example: - -```tf -import { - id = "projects/{{project}}/config/{{name}}" - to = google_identity_platform_project_default_config.default -} -``` - -When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), ProjectDefaultConfig can be imported using one of the formats above. For example: - -``` -$ terraform import google_identity_platform_project_default_config.default projects/{{project}}/config/{{name}} -$ terraform import google_identity_platform_project_default_config.default {{project}}/{{name}} -$ terraform import google_identity_platform_project_default_config.default {{name}} -``` - -## User Project Overrides - -This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). diff --git a/website/docs/r/integration_connectors_managed_zone.html.markdown b/website/docs/r/integration_connectors_managed_zone.html.markdown index b318891e9ab..14a8df7df49 100644 --- a/website/docs/r/integration_connectors_managed_zone.html.markdown +++ b/website/docs/r/integration_connectors_managed_zone.html.markdown @@ -37,6 +37,7 @@ resource "google_project" "target_project" { name = "tf-test%{random_suffix}" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "google_project_iam_member" "dns_peer_binding" { diff --git a/website/docs/r/integrations_client.html.markdown b/website/docs/r/integrations_client.html.markdown index 1a40f672df3..fcb6c18aa5b 100644 --- a/website/docs/r/integrations_client.html.markdown +++ b/website/docs/r/integrations_client.html.markdown @@ -106,22 +106,10 @@ The following arguments are supported: Cloud KMS config for AuthModule to encrypt/decrypt credentials. Structure is [documented below](#nested_cloud_kms_config). -* `create_sample_workflows` - - (Optional, Deprecated) - Indicates if sample workflow should be created along with provisioning. - - ~> **Warning:** `create_sample_workflows` is deprecated and will be removed in a future major release. Use `create_sample_integrations` instead. - * `create_sample_integrations` - (Optional) Indicates if sample integrations should be created along with provisioning. -* `provision_gmek` - - (Optional, Deprecated) - Indicates provision with GMEK or CMEK. - - ~> **Warning:** `provision_gmek` is deprecated and will be removed in a future major release. Client would be provisioned as gmek if `cloud_kms_config` is not given. - * `run_as_service_account` - (Optional) User input run-as service account, if empty, will bring up a new default service account. diff --git a/website/docs/r/kms_autokey_config.html.markdown b/website/docs/r/kms_autokey_config.html.markdown index b23422f38da..5de4ee21c32 100644 --- a/website/docs/r/kms_autokey_config.html.markdown +++ b/website/docs/r/kms_autokey_config.html.markdown @@ -46,6 +46,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "my-folder" parent = "organizations/123456789" + deletion_protection = false } # Create the key project @@ -56,6 +57,7 @@ resource "google_project" "key_project" { folder_id = google_folder.autokms_folder.folder_id billing_account = "000000-0000000-0000000-000000" depends_on = [google_folder.autokms_folder] + deletion_policy = "DELETE" } # Enable the Cloud KMS API diff --git a/website/docs/r/kms_key_handle.html.markdown b/website/docs/r/kms_key_handle.html.markdown index a5b9d2ce2ef..3291ebadd20 100644 --- a/website/docs/r/kms_key_handle.html.markdown +++ b/website/docs/r/kms_key_handle.html.markdown @@ -44,6 +44,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "folder-example" parent = "organizations/123456789" + deletion_protection = false } # Create the key project @@ -54,6 +55,7 @@ resource "google_project" "key_project" { folder_id = google_folder.autokms_folder.folder_id billing_account = "000000-0000000-0000000-000000" depends_on = [google_folder.autokms_folder] + deletion_policy = "DELETE" } # Create the resource project @@ -64,6 +66,7 @@ resource "google_project" "resource_project" { folder_id = google_folder.autokms_folder.folder_id billing_account = "000000-0000000-0000000-000000" depends_on = [google_folder.autokms_folder] + deletion_policy = "DELETE" } # Enable the Cloud KMS API diff --git a/website/docs/r/logging_folder_settings.html.markdown b/website/docs/r/logging_folder_settings.html.markdown index 691a12aae72..10c276c108f 100644 --- a/website/docs/r/logging_folder_settings.html.markdown +++ b/website/docs/r/logging_folder_settings.html.markdown @@ -43,6 +43,7 @@ resource "google_logging_folder_settings" "example" { resource "google_folder" "my_folder" { display_name = "folder-name" parent = "organizations/123456789" + deletion_protection = false } data "google_logging_folder_settings" "settings" { diff --git a/website/docs/r/monitoring_monitored_project.html.markdown b/website/docs/r/monitoring_monitored_project.html.markdown index bc34d1b03eb..55a6eeb87bb 100644 --- a/website/docs/r/monitoring_monitored_project.html.markdown +++ b/website/docs/r/monitoring_monitored_project.html.markdown @@ -41,6 +41,7 @@ resource "google_project" "basic" { project_id = "m-id" name = "m-id-display" org_id = "123456789" + deletion_policy = "DELETE" } ``` diff --git a/website/docs/r/org_policy_policy.html.markdown b/website/docs/r/org_policy_policy.html.markdown index fc2e1347282..d96a57c1f03 100644 --- a/website/docs/r/org_policy_policy.html.markdown +++ b/website/docs/r/org_policy_policy.html.markdown @@ -48,6 +48,7 @@ resource "google_project" "basic" { project_id = "id" name = "id" org_id = "123456789" + deletion_policy = "DELETE" } ``` ## Example Usage - Org Policy Policy Folder @@ -70,6 +71,7 @@ resource "google_org_policy_policy" "primary" { resource "google_folder" "basic" { parent = "organizations/123456789" display_name = "folder" + deletion_protection = false } ``` ## Example Usage - Org Policy Policy Organization @@ -118,6 +120,7 @@ resource "google_project" "basic" { project_id = "id" name = "id" org_id = "123456789" + deletion_policy = "DELETE" } ``` ## Example Usage - Org Policy Policy Dry Run Spec diff --git a/website/docs/r/organization_access_approval_settings.html.markdown b/website/docs/r/organization_access_approval_settings.html.markdown index 48bec6a4bf0..6a02183a24b 100644 --- a/website/docs/r/organization_access_approval_settings.html.markdown +++ b/website/docs/r/organization_access_approval_settings.html.markdown @@ -52,6 +52,7 @@ resource "google_project" "my_project" { name = "My Project" project_id = "your-project-id" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_kms_key_ring" "key_ring" { diff --git a/website/docs/r/redis_cluster.html.markdown b/website/docs/r/redis_cluster.html.markdown index 16659ff5343..34567a89b6a 100644 --- a/website/docs/r/redis_cluster.html.markdown +++ b/website/docs/r/redis_cluster.html.markdown @@ -51,16 +51,14 @@ resource "google_redis_cluster" "cluster-ha" { redis_configs = { maxmemory-policy = "volatile-ttl" } + deletion_protection_enabled = true + zone_distribution_config { mode = "MULTI_ZONE" } depends_on = [ google_network_connectivity_service_connection_policy.default ] - - lifecycle { - prevent_destroy = true - } } resource "google_network_connectivity_service_connection_policy" "default" { @@ -106,13 +104,11 @@ resource "google_redis_cluster" "cluster-ha-single-zone" { mode = "SINGLE_ZONE" zone = "us-central1-f" } + deletion_protection_enabled = true depends_on = [ google_network_connectivity_service_connection_policy.default ] - lifecycle { - prevent_destroy = true - } } resource "google_network_connectivity_service_connection_policy" "default" { @@ -200,6 +196,12 @@ The following arguments are supported: (Optional) Optional. The number of replica nodes per shard. +* `deletion_protection_enabled` - + (Optional) + Optional. Indicates if the cluster is deletion protected or not. + If the value if set to true, any delete cluster operation will fail. + Default value is true. + * `redis_configs` - (Optional) Configure Redis Cluster behavior using a subset of native Redis configuration parameters. diff --git a/website/docs/r/resource_manager_lien.html.markdown b/website/docs/r/resource_manager_lien.html.markdown index de13dd0ac95..983bc96a937 100644 --- a/website/docs/r/resource_manager_lien.html.markdown +++ b/website/docs/r/resource_manager_lien.html.markdown @@ -37,6 +37,7 @@ resource "google_resource_manager_lien" "lien" { resource "google_project" "project" { project_id = "staging-project" name = "A very important project!" + deletion_policy = "DELETE" } ``` diff --git a/website/docs/r/scc_folder_custom_module.html.markdown b/website/docs/r/scc_folder_custom_module.html.markdown index 0bed3d390f0..f4d9ff81a99 100644 --- a/website/docs/r/scc_folder_custom_module.html.markdown +++ b/website/docs/r/scc_folder_custom_module.html.markdown @@ -40,6 +40,7 @@ To get more information about FolderCustomModule, see: resource "google_folder" "folder" { parent = "organizations/123456789" display_name = "folder-name" + deletion_protection = false } resource "google_scc_folder_custom_module" "example" { @@ -68,6 +69,7 @@ resource "google_scc_folder_custom_module" "example" { resource "google_folder" "folder" { parent = "organizations/123456789" display_name = "folder-name" + deletion_protection = false } resource "google_scc_folder_custom_module" "example" { diff --git a/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown b/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown index 1c823877481..eafc9d2123b 100644 --- a/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown +++ b/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown @@ -40,6 +40,7 @@ To get more information about FolderSecurityHealthAnalyticsCustomModule, see: resource "google_folder" "folder" { parent = "organizations/123456789" display_name = "folder-name" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "example" { @@ -69,6 +70,7 @@ resource "google_scc_management_folder_security_health_analytics_custom_module" resource "google_folder" "folder" { parent = "organizations/123456789" display_name = "folder-name" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "example" { diff --git a/website/docs/r/service_usage_consumer_quota_override.html.markdown b/website/docs/r/service_usage_consumer_quota_override.html.markdown index 7ff5ee2717b..2a26be005c6 100644 --- a/website/docs/r/service_usage_consumer_quota_override.html.markdown +++ b/website/docs/r/service_usage_consumer_quota_override.html.markdown @@ -41,6 +41,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { @@ -62,6 +63,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { @@ -86,6 +88,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { diff --git a/website/docs/r/sql_database_instance.html.markdown b/website/docs/r/sql_database_instance.html.markdown index 220bfc44f3f..e1248314c48 100644 --- a/website/docs/r/sql_database_instance.html.markdown +++ b/website/docs/r/sql_database_instance.html.markdown @@ -377,12 +377,9 @@ Specifying a network enables private IP. At least `ipv4_enabled` must be enabled or a `private_network` must be configured. This setting can be updated, but it cannot be removed after it is set. -* `require_ssl` - (Optional, Deprecated) Whether SSL connections over IP are enforced or not. To change this field, also set the corresponding value in `ssl_mode`. It will be fully deprecated in a future major release. For now, please use `ssl_mode` with a compatible `require_ssl` value instead. +* `ssl_mode` - (Optional) Specify how SSL connection should be enforced in DB connections. -* `ssl_mode` - (Optional) Specify how SSL connection should be enforced in DB connections. This field provides more SSL enforcement options compared to `require_ssl`. To change this field, also set the correspoding value in `require_ssl`. - * For PostgreSQL instances, the value pairs are listed in the [API reference doc](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances#ipconfiguration) for `ssl_mode` field. - * For MySQL instances, use the same value pairs as the PostgreSQL instances. - * For SQL Server instances, set it to `ALLOW_UNENCRYPTED_AND_ENCRYPTED` when `require_ssl=false` and `ENCRYPTED_ONLY` otherwise. +* `server_ca_mode` - (Optional) Specify how the server certificate's Certificate Authority is hosted. Supported value is `GOOGLE_MANAGED_INTERNAL_CA`. * `server_ca_mode` - (Optional) Specify how the server certificate's Certificate Authority is hosted. Supported value is `GOOGLE_MANAGED_INTERNAL_CA`. diff --git a/website/docs/r/storage_bucket.html.markdown b/website/docs/r/storage_bucket.html.markdown index 8304aba71fc..db1b5e7e8ae 100644 --- a/website/docs/r/storage_bucket.html.markdown +++ b/website/docs/r/storage_bucket.html.markdown @@ -171,9 +171,7 @@ The following arguments are supported: The `condition` block supports the following elements, and requires at least one to be defined. If you specify multiple conditions in a rule, an object has to match all of the conditions for the action to be taken: -* `age` - (Optional) Minimum age of an object in days to satisfy this condition. If not supplied alongside another condition and without setting `no_age` to `true`, a default `age` of 0 will be set. - -* `no_age` - (Optional, Deprecated) While set `true`, `age` value will be omitted from requests. This prevents a default age of `0` from being applied, and if you do not have an `age` value set, setting this to `true` is strongly recommended. When unset and other conditions are set to zero values, this can result in a rule that applies your action to all files in the bucket. `no_age` is deprecated and will be removed in a future major release. Use `send_age_if_zero` instead. +* `age` - (Optional) Minimum age of an object in days to satisfy this condition. **Note** To set `0` value of `age`, `send_age_if_zero` should be set `true` otherwise `0` value of `age` field will be ignored. * `created_before` - (Optional) A date in the RFC 3339 format YYYY-MM-DD. This condition is satisfied when an object is created before midnight of the specified date in UTC. @@ -193,7 +191,7 @@ The following arguments are supported: * `days_since_custom_time` - (Optional) Days since the date set in the `customTime` metadata for the object. This condition is satisfied when the current date and time is at least the specified number of days after the `customTime`. Due to a current bug you are unable to set this value to `0` within Terraform. When set to `0` it will be ignored, and your state will treat it as though you supplied no `days_since_custom_time` condition. -* `send_age_if_zero` - (Optional, Default: true) While set true, `age` value will be sent in the request even for zero value of the field. This field is only useful and required for setting 0 value to the `age` field. It can be used alone or together with `age` attribute. **NOTE** `age` attibute with `0` value will be ommitted from the API request if `send_age_if_zero` field is having `false` value. +* `send_age_if_zero` - (Optional) While set true, `age` value will be sent in the request even for zero value of the field. This field is only useful and required for setting 0 value to the `age` field. It can be used alone or together with `age` attribute. **NOTE** `age` attibute with `0` value will be ommitted from the API request if `send_age_if_zero` field is having `false` value. * `send_days_since_custom_time_if_zero` - (Optional) While set true, `days_since_custom_time` value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the `days_since_custom_time` field. It can be used alone or together with `days_since_custom_time`. diff --git a/website/docs/r/tags_tag_binding.html.markdown b/website/docs/r/tags_tag_binding.html.markdown index 4823380f294..ba74765a051 100644 --- a/website/docs/r/tags_tag_binding.html.markdown +++ b/website/docs/r/tags_tag_binding.html.markdown @@ -36,6 +36,7 @@ resource "google_project" "project" { project_id = "project_id" name = "project_id" org_id = "123456789" + deletion_policy = "DELETE" } resource "google_tags_tag_key" "key" { diff --git a/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown b/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown index 1e29fda7f40..86759b02103 100644 --- a/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown +++ b/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown @@ -221,6 +221,7 @@ resource "google_project" "project" { name = "tf-test%{random_suffix}" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/website/docs/r/vmwareengine_network.html.markdown b/website/docs/r/vmwareengine_network.html.markdown index 0404a63fadd..5fc5f5cd9b1 100644 --- a/website/docs/r/vmwareengine_network.html.markdown +++ b/website/docs/r/vmwareengine_network.html.markdown @@ -69,6 +69,7 @@ resource "google_project" "acceptance" { project_id = "vmw-proj" org_id = "123456789" billing_account = "000000-0000000-0000000-000000" + deletion_policy = "DELETE" } resource "time_sleep" "wait_60_seconds" { diff --git a/website/docs/r/vpc_access_connector.html.markdown b/website/docs/r/vpc_access_connector.html.markdown index 99b8055b416..461de7958fb 100644 --- a/website/docs/r/vpc_access_connector.html.markdown +++ b/website/docs/r/vpc_access_connector.html.markdown @@ -41,6 +41,8 @@ resource "google_vpc_access_connector" "connector" { name = "vpc-con" ip_cidr_range = "10.8.0.0/28" network = "default" + min_instances = 2 + max_instances = 3 } ```
@@ -58,6 +60,8 @@ resource "google_vpc_access_connector" "connector" { name = google_compute_subnetwork.custom_test.name } machine_type = "e2-standard-4" + min_instances = 2 + max_instances = 3 } resource "google_compute_subnetwork" "custom_test" {