diff --git a/.changelog/10274.txt b/.changelog/10274.txt new file mode 100644 index 0000000000..8b6a55cf91 --- /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 0000000000..4b9fd58567 --- /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 0000000000..dda2bce537 --- /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 0000000000..334b2db708 --- /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 0000000000..42b910df15 --- /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 0000000000..94e66dcafe --- /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 0000000000..42b910df15 --- /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 0000000000..33b6ad1f91 --- /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 0000000000..d0a342eba0 --- /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 0000000000..42b910df15 --- /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 0000000000..42b910df15 --- /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 0000000000..343341c2e0 --- /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 0000000000..42b910df15 --- /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 0000000000..5aba433b92 --- /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 0000000000..ba9fb5dacc --- /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 0000000000..42b910df15 --- /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 0000000000..d0f203bed9 --- /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 0000000000..b67c7d6f5d --- /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 0000000000..42b910df15 --- /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 0000000000..85f764cbe8 --- /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 0000000000..10fc5c94f3 --- /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 0000000000..989faa63fd --- /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 0000000000..abaa16417f --- /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 0000000000..60f9fff981 --- /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 0000000000..d174bd6122 --- /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 0000000000..4d74b7beb5 --- /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 0000000000..42b910df15 --- /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 0000000000..42954b529d --- /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 0000000000..8e02876c06 --- /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 0000000000..8db532fce0 --- /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 0000000000..42b910df15 --- /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 0000000000..485b1818cc --- /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 0000000000..42b910df15 --- /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 0000000000..af86b3811b --- /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 0000000000..1b0a49a3e8 --- /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 0000000000..ac2097348a --- /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 0000000000..d1fb1178ae --- /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 0000000000..beee0a118a --- /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 0000000000..42b910df15 --- /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 0000000000..42b910df15 --- /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 0000000000..42b910df15 --- /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 0000000000..42b910df15 --- /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 0000000000..f00608c337 --- /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 0000000000..42b910df15 --- /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 0000000000..13321089f7 --- /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/google-beta/acctest/test_utils.go b/google-beta/acctest/test_utils.go index fba03cfb97..3f10625b82 100644 --- a/google-beta/acctest/test_utils.go +++ b/google-beta/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-beta/acctest/vcr_utils.go b/google-beta/acctest/vcr_utils.go index 555e165d00..ca2fee518c 100644 --- a/google-beta/acctest/vcr_utils.go +++ b/google-beta/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-beta/fwmodels/provider_model.go b/google-beta/fwmodels/provider_model.go index 2512d64d6a..e2979236f6 100644 --- a/google-beta/fwmodels/provider_model.go +++ b/google-beta/fwmodels/provider_model.go @@ -79,7 +79,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-beta/fwprovider/framework_provider.go b/google-beta/fwprovider/framework_provider.go index 9761ebee0a..658b0524a7 100644 --- a/google-beta/fwprovider/framework_provider.go +++ b/google-beta/fwprovider/framework_provider.go @@ -451,12 +451,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-beta/fwtransport/framework_config.go b/google-beta/fwtransport/framework_config.go index 538eb2bb15..ff9cd54303 100644 --- a/google-beta/fwtransport/framework_config.go +++ b/google-beta/fwtransport/framework_config.go @@ -103,7 +103,6 @@ type FrameworkProviderConfig struct { DataplexBasePath string DataprocBasePath string DataprocMetastoreBasePath string - DatastoreBasePath string DatastreamBasePath string DeploymentManagerBasePath string DialogflowBasePath string @@ -278,7 +277,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() @@ -898,14 +896,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-beta/provider/provider.go b/google-beta/provider/provider.go index a9cbb421e1..e57ae1dad7 100644 --- a/google-beta/provider/provider.go +++ b/google-beta/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": { @@ -399,11 +400,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, @@ -996,7 +992,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 @@ -1068,7 +1063,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-beta/provider/provider_mmv1_resources.go b/google-beta/provider/provider_mmv1_resources.go index a8f8d3ecc9..fda841b786 100644 --- a/google-beta/provider/provider_mmv1_resources.go +++ b/google-beta/provider/provider_mmv1_resources.go @@ -56,7 +56,6 @@ import ( "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dataplex" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dataproc" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dataprocmetastore" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/datastore" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/datastream" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/deploymentmanager" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dialogflow" @@ -475,9 +474,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ } // Resources -// Generated resources: 509 +// Generated resources: 507 // Generated IAM resources: 288 -// Total generated resources: 797 +// Total generated resources: 795 var generatedResources = map[string]*schema.Resource{ "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), @@ -855,7 +854,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(), @@ -1003,7 +1001,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-beta/services/accessapproval/data_source_access_approval_folder_service_account_test.go b/google-beta/services/accessapproval/data_source_access_approval_folder_service_account_test.go index c58f55b025..69eccd07f4 100644 --- a/google-beta/services/accessapproval/data_source_access_approval_folder_service_account_test.go +++ b/google-beta/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-beta/services/accessapproval/resource_access_approval_folder_settings_test.go b/google-beta/services/accessapproval/resource_access_approval_folder_settings_test.go index 6156576a86..8f384e98f1 100644 --- a/google-beta/services/accessapproval/resource_access_approval_folder_settings_test.go +++ b/google-beta/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-beta/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go b/google-beta/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go index b564c7515b..ae1c2a239a 100644 --- a/google-beta/services/accesscontextmanager/resource_access_context_manager_access_policy_iam_test.go +++ b/google-beta/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-beta/services/activedirectory/resource_active_directory_domain.go b/google-beta/services/activedirectory/resource_active_directory_domain.go index 0746a8e3a1..4e7518f28c 100644 --- a/google-beta/services/activedirectory/resource_active_directory_domain.go +++ b/google-beta/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-beta/services/activedirectory/resource_active_directory_domain_sweeper.go b/google-beta/services/activedirectory/resource_active_directory_domain_sweeper.go deleted file mode 100644 index f6a56087f7..0000000000 --- a/google-beta/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-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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/v1beta1/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/v1beta1/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-beta/services/activedirectory/resource_active_directory_domain_trust_test.go b/google-beta/services/activedirectory/resource_active_directory_domain_trust_test.go index d092c5d713..bf0ccd5d43 100644 --- a/google-beta/services/activedirectory/resource_active_directory_domain_trust_test.go +++ b/google-beta/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-beta/services/activedirectory/resource_active_directory_domain_update_test.go b/google-beta/services/activedirectory/resource_active_directory_domain_update_test.go index 81348aa4c3..dce4318a72 100644 --- a/google-beta/services/activedirectory/resource_active_directory_domain_update_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_backup_generated_test.go b/google-beta/services/alloydb/resource_alloydb_backup_generated_test.go index 8ec93c7e2e..f862de06d0 100644 --- a/google-beta/services/alloydb/resource_alloydb_backup_generated_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_backup_test.go b/google-beta/services/alloydb/resource_alloydb_backup_test.go index b0db476ebf..fecf3b364e 100644 --- a/google-beta/services/alloydb/resource_alloydb_backup_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_cluster.go b/google-beta/services/alloydb/resource_alloydb_cluster.go index 6c03310671..b3dffcbabb 100644 --- a/google-beta/services/alloydb/resource_alloydb_cluster.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_cluster_generated_test.go b/google-beta/services/alloydb/resource_alloydb_cluster_generated_test.go index 84b42e8570..baaa70fff8 100644 --- a/google-beta/services/alloydb/resource_alloydb_cluster_generated_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_cluster_restore_test.go b/google-beta/services/alloydb/resource_alloydb_cluster_restore_test.go index c8c5347930..c89a9d4179 100644 --- a/google-beta/services/alloydb/resource_alloydb_cluster_restore_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_cluster_test.go b/google-beta/services/alloydb/resource_alloydb_cluster_test.go index 929ea9c7b7..1f280e2665 100644 --- a/google-beta/services/alloydb/resource_alloydb_cluster_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_instance_generated_test.go b/google-beta/services/alloydb/resource_alloydb_instance_generated_test.go index 8e0a810866..b26c94c72c 100644 --- a/google-beta/services/alloydb/resource_alloydb_instance_generated_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_instance_test.go b/google-beta/services/alloydb/resource_alloydb_instance_test.go index 2d691c8985..3ad3136ea1 100644 --- a/google-beta/services/alloydb/resource_alloydb_instance_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_secondary_cluster_test.go b/google-beta/services/alloydb/resource_alloydb_secondary_cluster_test.go index a939454678..c3612d097e 100644 --- a/google-beta/services/alloydb/resource_alloydb_secondary_cluster_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_secondary_instance_test.go b/google-beta/services/alloydb/resource_alloydb_secondary_instance_test.go index b47717dbd1..68064af18c 100644 --- a/google-beta/services/alloydb/resource_alloydb_secondary_instance_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_user_generated_test.go b/google-beta/services/alloydb/resource_alloydb_user_generated_test.go index cea8fc510e..5a24048076 100644 --- a/google-beta/services/alloydb/resource_alloydb_user_generated_test.go +++ b/google-beta/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-beta/services/alloydb/resource_alloydb_user_test.go b/google-beta/services/alloydb/resource_alloydb_user_test.go index f2c4d9bda7..b1e973ddba 100644 --- a/google-beta/services/alloydb/resource_alloydb_user_test.go +++ b/google-beta/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-beta/services/apigee/iam_apigee_environment_generated_test.go b/google-beta/services/apigee/iam_apigee_environment_generated_test.go index d9b76e1485..1c552b63a5 100644 --- a/google-beta/services/apigee/iam_apigee_environment_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_addons_config_generated_test.go b/google-beta/services/apigee/resource_apigee_addons_config_generated_test.go index 9c9cbfd54b..b77e08dc8b 100644 --- a/google-beta/services/apigee/resource_apigee_addons_config_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_endpoint_attachment_generated_test.go b/google-beta/services/apigee/resource_apigee_endpoint_attachment_generated_test.go index 09c6085ca6..aab3e13449 100644 --- a/google-beta/services/apigee/resource_apigee_endpoint_attachment_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go b/google-beta/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go index da7b55766b..5b58f55175 100644 --- a/google-beta/services/apigee/resource_apigee_env_keystore_alias_pkcs12_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_env_keystore_generated_test.go b/google-beta/services/apigee/resource_apigee_env_keystore_generated_test.go index 4856afd362..0dd3143856 100644 --- a/google-beta/services/apigee/resource_apigee_env_keystore_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_env_references_generated_test.go b/google-beta/services/apigee/resource_apigee_env_references_generated_test.go index dea81b3562..ab3b611491 100644 --- a/google-beta/services/apigee/resource_apigee_env_references_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_envgroup_attachment_generated_test.go b/google-beta/services/apigee/resource_apigee_envgroup_attachment_generated_test.go index 5798007e69..528a093767 100644 --- a/google-beta/services/apigee/resource_apigee_envgroup_attachment_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_envgroup_generated_test.go b/google-beta/services/apigee/resource_apigee_envgroup_generated_test.go index af8ab63a0a..1e6e20a65f 100644 --- a/google-beta/services/apigee/resource_apigee_envgroup_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_environment_generated_test.go b/google-beta/services/apigee/resource_apigee_environment_generated_test.go index 7be94ce89f..59e7e3c162 100644 --- a/google-beta/services/apigee/resource_apigee_environment_generated_test.go +++ b/google-beta/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" { @@ -260,6 +262,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-beta/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go b/google-beta/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go index dbc3a03319..b290756f67 100644 --- a/google-beta/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_test.go +++ b/google-beta/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" { @@ -209,6 +210,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-beta/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go b/google-beta/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go index b02e6d0499..d979e96aa3 100644 --- a/google-beta/services/apigee/resource_apigee_environment_keyvaluemaps_generated_test.go +++ b/google-beta/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" { @@ -195,6 +196,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-beta/services/apigee/resource_apigee_environment_type_test.go b/google-beta/services/apigee/resource_apigee_environment_type_test.go index adabb48222..c3f0ce3483 100644 --- a/google-beta/services/apigee/resource_apigee_environment_type_test.go +++ b/google-beta/services/apigee/resource_apigee_environment_type_test.go @@ -56,6 +56,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-beta/services/apigee/resource_apigee_flowhook_test.go b/google-beta/services/apigee/resource_apigee_flowhook_test.go index 039b35a1ab..2c927264cb 100644 --- a/google-beta/services/apigee/resource_apigee_flowhook_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_instance_attachment_generated_test.go b/google-beta/services/apigee/resource_apigee_instance_attachment_generated_test.go index 4bb9edc675..35e5674916 100644 --- a/google-beta/services/apigee/resource_apigee_instance_attachment_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_instance_generated_test.go b/google-beta/services/apigee/resource_apigee_instance_generated_test.go index 1173430c3f..dfea1115ba 100644 --- a/google-beta/services/apigee/resource_apigee_instance_generated_test.go +++ b/google-beta/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" { @@ -346,6 +349,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" { @@ -500,6 +504,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-beta/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go b/google-beta/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go index dbcab3b87f..1d52687b39 100644 --- a/google-beta/services/apigee/resource_apigee_keystores_aliases_key_cert_file_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go b/google-beta/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go index feeeaca0e5..9be4a5cef5 100644 --- a/google-beta/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_nat_address_generated_test.go b/google-beta/services/apigee/resource_apigee_nat_address_generated_test.go index 5d6dab84e6..6ffddcae2e 100644 --- a/google-beta/services/apigee/resource_apigee_nat_address_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_organization_generated_test.go b/google-beta/services/apigee/resource_apigee_organization_generated_test.go index 30a5ab0ad1..f4e5d08c2b 100644 --- a/google-beta/services/apigee/resource_apigee_organization_generated_test.go +++ b/google-beta/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" { @@ -208,6 +210,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" { @@ -364,6 +367,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" { @@ -484,6 +488,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" { @@ -634,6 +639,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-beta/services/apigee/resource_apigee_sharedflow_deployment_test.go b/google-beta/services/apigee/resource_apigee_sharedflow_deployment_test.go index f43fb78827..b58f02f1b8 100644 --- a/google-beta/services/apigee/resource_apigee_sharedflow_deployment_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_sharedflow_test.go b/google-beta/services/apigee/resource_apigee_sharedflow_test.go index d218dc4980..842dca1620 100644 --- a/google-beta/services/apigee/resource_apigee_sharedflow_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_sync_authorization_generated_test.go b/google-beta/services/apigee/resource_apigee_sync_authorization_generated_test.go index 07330f75c3..05c5edcfa3 100644 --- a/google-beta/services/apigee/resource_apigee_sync_authorization_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_sync_authorization_test.go b/google-beta/services/apigee/resource_apigee_sync_authorization_test.go index dd584857b3..9495406230 100644 --- a/google-beta/services/apigee/resource_apigee_sync_authorization_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_target_server_generated_test.go b/google-beta/services/apigee/resource_apigee_target_server_generated_test.go index 950e3cd4c8..155fbeb5b8 100644 --- a/google-beta/services/apigee/resource_apigee_target_server_generated_test.go +++ b/google-beta/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-beta/services/apigee/resource_apigee_target_server_test.go b/google-beta/services/apigee/resource_apigee_target_server_test.go index 55f4b2245f..f6ebcacdd3 100644 --- a/google-beta/services/apigee/resource_apigee_target_server_test.go +++ b/google-beta/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-beta/services/apikeys/resource_apikeys_key_generated_test.go b/google-beta/services/apikeys/resource_apikeys_key_generated_test.go index 1a59e99d62..7414bba242 100644 --- a/google-beta/services/apikeys/resource_apikeys_key_generated_test.go +++ b/google-beta/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-beta/services/appengine/resource_app_engine_application_test.go b/google-beta/services/appengine/resource_app_engine_application_test.go index 66f0cc5101..d16ca210a2 100644 --- a/google-beta/services/appengine/resource_app_engine_application_test.go +++ b/google-beta/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-beta/services/appengine/resource_app_engine_firewall_rule_generated_test.go b/google-beta/services/appengine/resource_app_engine_firewall_rule_generated_test.go index 174138620e..f60f9c8aeb 100644 --- a/google-beta/services/appengine/resource_app_engine_firewall_rule_generated_test.go +++ b/google-beta/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-beta/services/appengine/resource_app_engine_flexible_app_version_test.go b/google-beta/services/appengine/resource_app_engine_flexible_app_version_test.go index aa695ee2ed..062bc20b8d 100644 --- a/google-beta/services/appengine/resource_app_engine_flexible_app_version_test.go +++ b/google-beta/services/appengine/resource_app_engine_flexible_app_version_test.go @@ -58,6 +58,7 @@ resource "google_project" "my_project" { project_id = "tf-test-appeng-flex%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { @@ -244,6 +245,7 @@ resource "google_project" "my_project" { project_id = "tf-test-appeng-flex%{random_suffix}" org_id = "%{org_id}" billing_account = "%{billing_account}" + deletion_policy = "DELETE" } resource "google_project_service" "compute" { diff --git a/google-beta/services/appengine/resource_app_engine_standard_app_version_test.go b/google-beta/services/appengine/resource_app_engine_standard_app_version_test.go index 8befb62b4c..781fa990c4 100644 --- a/google-beta/services/appengine/resource_app_engine_standard_app_version_test.go +++ b/google-beta/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-beta/services/apphub/data_source_apphub_discovered_service_test.go b/google-beta/services/apphub/data_source_apphub_discovered_service_test.go index cc8b999223..30dc863322 100644 --- a/google-beta/services/apphub/data_source_apphub_discovered_service_test.go +++ b/google-beta/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-beta/services/apphub/data_source_apphub_discovered_workload_test.go b/google-beta/services/apphub/data_source_apphub_discovered_workload_test.go index 9a3c2d1d38..17db7a665f 100644 --- a/google-beta/services/apphub/data_source_apphub_discovered_workload_test.go +++ b/google-beta/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-beta/services/apphub/resource_apphub_service_generated_test.go b/google-beta/services/apphub/resource_apphub_service_generated_test.go index e9da328f2f..5881220a40 100644 --- a/google-beta/services/apphub/resource_apphub_service_generated_test.go +++ b/google-beta/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-beta/services/apphub/resource_apphub_service_project_attachment_generated_test.go b/google-beta/services/apphub/resource_apphub_service_project_attachment_generated_test.go index 07f9f11b3e..5aa5daa424 100644 --- a/google-beta/services/apphub/resource_apphub_service_project_attachment_generated_test.go +++ b/google-beta/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-beta/services/apphub/resource_apphub_service_test.go b/google-beta/services/apphub/resource_apphub_service_test.go index 42b0c1faec..36435b4d8b 100644 --- a/google-beta/services/apphub/resource_apphub_service_test.go +++ b/google-beta/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-beta/services/apphub/resource_apphub_workload_generated_test.go b/google-beta/services/apphub/resource_apphub_workload_generated_test.go index d836d5893e..746909f228 100644 --- a/google-beta/services/apphub/resource_apphub_workload_generated_test.go +++ b/google-beta/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-beta/services/apphub/resource_apphub_workload_test.go b/google-beta/services/apphub/resource_apphub_workload_test.go index 351092d55e..de374bc666 100644 --- a/google-beta/services/apphub/resource_apphub_workload_test.go +++ b/google-beta/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-beta/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go b/google-beta/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go index 4a0b225170..cbe3ddcb9f 100644 --- a/google-beta/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go +++ b/google-beta/services/assuredworkloads/resource_assured_workloads_workload_generated_test.go @@ -210,6 +210,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) } @@ -236,6 +237,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) } @@ -258,6 +260,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-beta/services/bigquery/resource_bigquery_dataset_test.go b/google-beta/services/bigquery/resource_bigquery_dataset_test.go index af920d8c6c..6412eeb018 100644 --- a/google-beta/services/bigquery/resource_bigquery_dataset_test.go +++ b/google-beta/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-beta/services/bigquery/resource_bigquery_table.go b/google-beta/services/bigquery/resource_bigquery_table.go index f5f930d14e..39a28955f7 100644 --- a/google-beta/services/bigquery/resource_bigquery_table.go +++ b/google-beta/services/bigquery/resource_bigquery_table.go @@ -1252,14 +1252,6 @@ func ResourceBigQueryTable() *schema.Resource { Description: `Whether Terraform will be prevented from destroying the instance. When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the table will fail. When the field is set to false, deleting the table is allowed.`, }, - "allow_resource_tags_on_deletion": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: `**Deprecated** Whether or not to allow table deletion when there are still resource tags attached.`, - Deprecated: `This field is deprecated and will be removed in a future major release. The default behavior will be allowing the presence of resource tags on deletion after the next major release.`, - }, - // TableConstraints: [Optional] Defines the primary key and foreign keys. "table_constraints": { Type: schema.TypeList, @@ -1594,6 +1586,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 +1924,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 +2536,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)} @@ -2937,9 +2930,6 @@ func resourceBigQueryTableImport(d *schema.ResourceData, meta interface{}) ([]*s if err := d.Set("deletion_protection", true); err != nil { return nil, fmt.Errorf("Error setting deletion_protection: %s", err) } - if err := d.Set("allow_resource_tags_on_deletion", false); err != nil { - return nil, fmt.Errorf("Error setting allow_resource_tags_on_deletion: %s", err) - } // Replace import id for the resource id id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}") diff --git a/google-beta/services/bigquery/resource_bigquery_table_test.go b/google-beta/services/bigquery/resource_bigquery_table_test.go index 1ca8d3e88c..a294680a34 100644 --- a/google-beta/services/bigquery/resource_bigquery_table_test.go +++ b/google-beta/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-beta/services/cloudrunv2/resource_cloud_run_v2_job_test.go b/google-beta/services/cloudrunv2/resource_cloud_run_v2_job_test.go index c29a758db4..5c6ef71afd 100644 --- a/google-beta/services/cloudrunv2/resource_cloud_run_v2_job_test.go +++ b/google-beta/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" @@ -306,6 +311,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithDirectVPCAndNamedBinAuthPolicyUpdate( } func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() jobName := fmt.Sprintf("tf-test-cloudrun-service%s", acctest.RandString(t, 10)) @@ -325,7 +331,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(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_cloudrunv2JobWithGcsVolume(context), @@ -334,7 +340,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithGcsUpdate(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"}, }, }, }) @@ -345,6 +351,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNoVolume(context map[string]interface resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" template { template { @@ -368,6 +375,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(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 { @@ -392,6 +400,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithGcsVolume(context map[string]interfac } func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() jobName := fmt.Sprintf("tf-test-cloudrun-service%s", acctest.RandString(t, 10)) @@ -411,7 +420,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(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_cloudrunv2JobWithNfsVolume(context), @@ -420,7 +429,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithNfsUpdate(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"}, }, }, }) @@ -431,6 +440,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithNfsVolume(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 { @@ -480,7 +490,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithStartExecutionTokenUpdate(t *testing. 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_cloudrunv2JobWithStartExecutionToken(context2), @@ -489,7 +499,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithStartExecutionTokenUpdate(t *testing. ResourceName: "google_cloud_run_v2_job.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"location", "launch_stage"}, + ImportStateVerifyIgnore: []string{"location", "launch_stage", "deletion_protection"}, }, }, }) @@ -500,6 +510,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithStartExecutionToken(context map[strin resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false start_execution_token = "%{token}" template { template { @@ -537,7 +548,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithRunExecutionTokenUpdate(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_cloudrunv2JobWithRunExecutionToken(context2), @@ -546,7 +557,7 @@ func TestAccCloudRunV2Job_cloudrunv2JobWithRunExecutionTokenUpdate(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"}, }, }, }) @@ -557,6 +568,7 @@ func testAccCloudRunV2Job_cloudrunv2JobWithRunExecutionToken(context map[string] resource "google_cloud_run_v2_job" "default" { name = "%{job_name}" location = "us-central1" + deletion_protection = false run_execution_token = "%{token}" template { template { diff --git a/google-beta/services/cloudrunv2/resource_cloud_run_v2_service.go b/google-beta/services/cloudrunv2/resource_cloud_run_v2_service.go index 8e47809e0a..26415cc80b 100644 --- a/google-beta/services/cloudrunv2/resource_cloud_run_v2_service.go +++ b/google-beta/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, @@ -1146,6 +1103,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, @@ -1157,6 +1125,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) @@ -1345,6 +1360,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) } @@ -1616,6 +1637,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{ @@ -1661,6 +1685,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 } @@ -2026,14 +2055,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), @@ -3596,6 +3625,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-beta/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go b/google-beta/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go index 5deaafb6a2..abc788d294 100644 --- a/google-beta/services/cloudrunv2/resource_cloud_run_v2_service_generated_test.go +++ b/google-beta/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 { @@ -492,7 +499,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceMulticontainerExample(t *testing. 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 +511,7 @@ resource "google_cloud_run_v2_service" "default" { provider = google-beta name = "tf-test-cloudrun-service%{random_suffix}" location = "us-central1" + deletion_protection = false launch_stage = "BETA" ingress = "INGRESS_TRAFFIC_ALL" template { @@ -545,6 +553,7 @@ resource "google_cloud_run_v2_service" "default" { } func TestAccCloudRunV2Service_cloudrunv2ServiceMountGcsExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -563,7 +572,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"}, }, }, }) @@ -575,6 +584,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 { @@ -606,6 +616,7 @@ resource "google_storage_bucket" "default" { } func TestAccCloudRunV2Service_cloudrunv2ServiceMountNfsExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -624,7 +635,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"}, }, }, }) @@ -636,6 +647,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-beta/services/cloudrunv2/resource_cloud_run_v2_service_sweeper.go b/google-beta/services/cloudrunv2/resource_cloud_run_v2_service_sweeper.go deleted file mode 100644 index 60fa774576..0000000000 --- a/google-beta/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-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/cloudrunv2/resource_cloud_run_v2_service_test.go b/google-beta/services/cloudrunv2/resource_cloud_run_v2_service_test.go index 502e2c2509..b4e5b6c861 100644 --- a/google-beta/services/cloudrunv2/resource_cloud_run_v2_service_test.go +++ b/google-beta/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" } @@ -210,6 +211,7 @@ resource "google_compute_network" "custom_test" { `, context) } func TestAccCloudRunV2Service_cloudrunv2ServiceGcsVolume(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -228,7 +230,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceGcsVolume(t *testing.T) { ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"}, }, }, }) @@ -240,6 +242,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description creating" location = "us-central1" + deletion_protection = false launch_stage = "BETA" annotations = { generated-by = "magic-modules" @@ -328,7 +331,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), @@ -337,7 +340,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"}, }, }, }) @@ -362,7 +365,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), @@ -371,7 +374,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"}, }, }, }) @@ -397,7 +400,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), @@ -406,7 +409,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 @@ -459,6 +462,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 { @@ -483,6 +487,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 { @@ -527,6 +532,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 { @@ -545,6 +551,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 { @@ -577,6 +584,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithEmptyGRPCLivenessProbe(co resource "google_cloud_run_v2_service" "default" { name ="%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -598,6 +606,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessProbe(context resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -622,6 +631,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithEmptyGRPCStartupProbe(con resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -643,6 +653,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCStartupProbe(context resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -667,6 +678,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithGRPCLivenessAndStartupPro resource "google_cloud_run_v2_service" "default" { name = "%{service_name}" location = "us-central1" + deletion_protection = false template { containers { @@ -713,7 +725,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), @@ -722,7 +734,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"}, }, }, }) @@ -733,6 +745,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 { @@ -753,6 +766,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" @@ -790,7 +804,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"), @@ -799,7 +813,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), @@ -808,7 +822,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"}, }, }, }) @@ -819,6 +833,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithoutCustomAudience(service resource "google_cloud_run_v2_service" "default" { name = "%s" location = "us-central1" + deletion_protection = false template { containers { @@ -837,6 +852,7 @@ func testAccCloudRunV2Service_cloudRunServiceUpdateWithCustomAudience(serviceNam resource "google_cloud_run_v2_service" "default" { name = "%s" location = "us-central1" + deletion_protection = false custom_audiences = ["%s"] template { @@ -909,6 +925,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" @@ -936,6 +953,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" @@ -970,7 +988,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithServiceMinInstances(t *testin ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"}, }, { Config: testAccCloudRunV2Service_cloudrunv2ServiceWithNoMinInstances(context), @@ -979,7 +997,7 @@ func TestAccCloudRunV2Service_cloudrunv2ServiceWithServiceMinInstances(t *testin ResourceName: "google_cloud_run_v2_service.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage"}, + ImportStateVerifyIgnore: []string{"name", "location", "annotations", "labels", "terraform_labels", "launch_stage", "deletion_protection"}, }, }, }) @@ -991,6 +1009,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description creating" location = "us-central1" + deletion_protection = false launch_stage = "BETA" annotations = { generated-by = "magic-modules" @@ -1022,6 +1041,7 @@ resource "google_cloud_run_v2_service" "default" { name = "tf-test-cloudrun-service%{random_suffix}" description = "description creating" location = "us-central1" + deletion_protection = false launch_stage = "BETA" annotations = { generated-by = "magic-modules" diff --git a/google-beta/services/composer/resource_composer_environment.go b/google-beta/services/composer/resource_composer_environment.go index 84bee700ba..8a5f3c1810 100644 --- a/google-beta/services/composer/resource_composer_environment.go +++ b/google-beta/services/composer/resource_composer_environment.go @@ -315,7 +315,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-beta/services/composer/resource_composer_environment_test.go b/google-beta/services/composer/resource_composer_environment_test.go index 4023209445..5d052f9b81 100644 --- a/google-beta/services/composer/resource_composer_environment_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_address_test.go b/google-beta/services/compute/resource_compute_address_test.go index 3cb2d34966..a757c933ed 100644 --- a/google-beta/services/compute/resource_compute_address_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_backend_service.go b/google-beta/services/compute/resource_compute_backend_service.go index cb95397d6a..411a694ff5 100644 --- a/google-beta/services/compute/resource_compute_backend_service.go +++ b/google-beta/services/compute/resource_compute_backend_service.go @@ -662,14 +662,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, }, @@ -884,10 +889,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{ @@ -923,7 +925,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": { @@ -932,7 +933,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": { @@ -941,7 +941,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": { @@ -950,7 +949,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": { @@ -959,7 +957,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": { @@ -992,7 +989,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": { @@ -1002,7 +998,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": { @@ -1013,7 +1008,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": { @@ -1025,7 +1019,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"}, }, }, @@ -1211,9 +1204,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": { @@ -2862,6 +2853,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"] = @@ -2870,6 +2863,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 } @@ -4049,6 +4046,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 @@ -4073,6 +4077,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 } @@ -4536,24 +4544,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 @@ -4612,18 +4602,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-beta/services/compute/resource_compute_backend_service_generated_test.go b/google-beta/services/compute/resource_compute_backend_service_generated_test.go index 7499d76ecc..4923a2bd62 100644 --- a/google-beta/services/compute/resource_compute_backend_service_generated_test.go +++ b/google-beta/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" } @@ -447,7 +448,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 } } diff --git a/google-beta/services/compute/resource_compute_backend_service_test.go b/google-beta/services/compute/resource_compute_backend_service_test.go index 8b43e2f9af..aa6af37a4e 100644 --- a/google-beta/services/compute/resource_compute_backend_service_test.go +++ b/google-beta/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"}, }, }, }) @@ -1321,6 +1321,7 @@ resource "google_compute_backend_service" "lipsum" { } iap { + enabled = true oauth2_client_id = "test" oauth2_client_secret = "test" } diff --git a/google-beta/services/compute/resource_compute_firewall_policy_association_test.go b/google-beta/services/compute/resource_compute_firewall_policy_association_test.go index 9bd487b9ac..1a47f0c58c 100644 --- a/google-beta/services/compute/resource_compute_firewall_policy_association_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_firewall_policy_rule_generated_test.go b/google-beta/services/compute/resource_compute_firewall_policy_rule_generated_test.go index bd053416e7..eb44c8efc9 100644 --- a/google-beta/services/compute/resource_compute_firewall_policy_rule_generated_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_firewall_policy_rule_test.go b/google-beta/services/compute/resource_compute_firewall_policy_rule_test.go index db352bc3c7..36decf5b61 100644 --- a/google-beta/services/compute/resource_compute_firewall_policy_rule_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_firewall_policy_test.go b/google-beta/services/compute/resource_compute_firewall_policy_test.go index dcd8663ab3..8db6177a18 100644 --- a/google-beta/services/compute/resource_compute_firewall_policy_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_forwarding_rule.go b/google-beta/services/compute/resource_compute_forwarding_rule.go index ccf837284b..b0e15e8dd9 100644 --- a/google-beta/services/compute/resource_compute_forwarding_rule.go +++ b/google-beta/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-beta/services/compute/resource_compute_global_forwarding_rule.go b/google-beta/services/compute/resource_compute_global_forwarding_rule.go index 9cf66a0138..a2fb882a32 100644 --- a/google-beta/services/compute/resource_compute_global_forwarding_rule.go +++ b/google-beta/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-beta/services/compute/resource_compute_instance.go b/google-beta/services/compute/resource_compute_instance.go index 772b087e3f..b62c28786d 100644 --- a/google-beta/services/compute/resource_compute_instance.go +++ b/google-beta/services/compute/resource_compute_instance.go @@ -655,7 +655,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-beta/services/compute/resource_compute_instance_from_machine_image.go b/google-beta/services/compute/resource_compute_instance_from_machine_image.go index 69e30ef6c4..9d3710b9cb 100644 --- a/google-beta/services/compute/resource_compute_instance_from_machine_image.go +++ b/google-beta/services/compute/resource_compute_instance_from_machine_image.go @@ -43,17 +43,6 @@ func computeInstanceFromMachineImageSchema() 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 - } - recurseOnSchema(s, func(field *schema.Schema) { // We don't want to accidentally use default values to override the instance // machine image, so remove defaults. diff --git a/google-beta/services/compute/resource_compute_instance_from_machine_image_test.go b/google-beta/services/compute/resource_compute_instance_from_machine_image_test.go index c538bc13b3..99b2f138b1 100644 --- a/google-beta/services/compute/resource_compute_instance_from_machine_image_test.go +++ b/google-beta/services/compute/resource_compute_instance_from_machine_image_test.go @@ -934,6 +934,7 @@ resource "google_project" "project" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "service" { diff --git a/google-beta/services/compute/resource_compute_instance_from_template.go b/google-beta/services/compute/resource_compute_instance_from_template.go index e2320d321b..f42467b476 100644 --- a/google-beta/services/compute/resource_compute_instance_from_template.go +++ b/google-beta/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-beta/services/compute/resource_compute_instance_from_template_test.go b/google-beta/services/compute/resource_compute_instance_from_template_test.go index 900fcf8921..6ee0dd02e8 100644 --- a/google-beta/services/compute/resource_compute_instance_from_template_test.go +++ b/google-beta/services/compute/resource_compute_instance_from_template_test.go @@ -365,49 +365,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)) @@ -1473,84 +1430,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-beta/services/compute/resource_compute_instance_template.go b/google-beta/services/compute/resource_compute_instance_template.go index e9eb6beb93..5c45436db8 100644 --- a/google-beta/services/compute/resource_compute_instance_template.go +++ b/google-beta/services/compute/resource_compute_instance_template.go @@ -90,14 +90,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 }, @@ -1414,7 +1414,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-beta/services/compute/resource_compute_instance_template_test.go b/google-beta/services/compute/resource_compute_instance_template_test.go index e15c0b3146..9c6726b429 100644 --- a/google-beta/services/compute/resource_compute_instance_template_test.go +++ b/google-beta/services/compute/resource_compute_instance_template_test.go @@ -861,6 +861,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() @@ -2573,6 +2612,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" { @@ -2827,6 +2888,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" { @@ -2843,6 +2905,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-beta/services/compute/resource_compute_instance_test.go b/google-beta/services/compute/resource_compute_instance_test.go index 4ab27687fc..c9ff1568ac 100644 --- a/google-beta/services/compute/resource_compute_instance_test.go +++ b/google-beta/services/compute/resource_compute_instance_test.go @@ -6745,6 +6745,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" { @@ -6761,6 +6762,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-beta/services/compute/resource_compute_managed_ssl_certificate.go b/google-beta/services/compute/resource_compute_managed_ssl_certificate.go index 8140130ca4..1ce28ec8e9 100644 --- a/google-beta/services/compute/resource_compute_managed_ssl_certificate.go +++ b/google-beta/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-beta/services/compute/resource_compute_network_attachment_generated_test.go b/google-beta/services/compute/resource_compute_network_attachment_generated_test.go index 39844b9d3b..85f7828f1e 100644 --- a/google-beta/services/compute/resource_compute_network_attachment_generated_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_network_endpoints.go b/google-beta/services/compute/resource_compute_network_endpoints.go index 792e477648..ccbf56eaa8 100644 --- a/google-beta/services/compute/resource_compute_network_endpoints.go +++ b/google-beta/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-beta/services/compute/resource_compute_network_peering_routes_config_generated_test.go b/google-beta/services/compute/resource_compute_network_peering_routes_config_generated_test.go index 73ae2951a8..86dcc3ae1f 100644 --- a/google-beta/services/compute/resource_compute_network_peering_routes_config_generated_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_node_group_generated_test.go b/google-beta/services/compute/resource_compute_node_group_generated_test.go index 65b50acb52..8129f04f99 100644 --- a/google-beta/services/compute/resource_compute_node_group_generated_test.go +++ b/google-beta/services/compute/resource_compute_node_group_generated_test.go @@ -207,6 +207,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-beta/services/compute/resource_compute_organization_security_policy_association_generated_test.go b/google-beta/services/compute/resource_compute_organization_security_policy_association_generated_test.go index 0791a9870e..4c915a05d4 100644 --- a/google-beta/services/compute/resource_compute_organization_security_policy_association_generated_test.go +++ b/google-beta/services/compute/resource_compute_organization_security_policy_association_generated_test.go @@ -61,6 +61,7 @@ resource "google_folder" "security_policy_target" { provider = google-beta display_name = "tf-test-secpol-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } resource "google_compute_organization_security_policy" "policy" { diff --git a/google-beta/services/compute/resource_compute_organization_security_policy_rule_test.go b/google-beta/services/compute/resource_compute_organization_security_policy_rule_test.go index 74272005bf..dfa39cee6e 100644 --- a/google-beta/services/compute/resource_compute_organization_security_policy_rule_test.go +++ b/google-beta/services/compute/resource_compute_organization_security_policy_rule_test.go @@ -48,6 +48,7 @@ func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRule resource "google_folder" "security_policy_target" { display_name = "tf-test-secpol-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } resource "google_compute_organization_security_policy" "policy" { @@ -82,6 +83,7 @@ func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRule resource "google_folder" "security_policy_target" { display_name = "tf-test-secpol-%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } resource "google_compute_organization_security_policy" "policy" { diff --git a/google-beta/services/compute/resource_compute_project_cloud_armor_tier_test.go b/google-beta/services/compute/resource_compute_project_cloud_armor_tier_test.go index 832053cd86..25a1ac5aa1 100644 --- a/google-beta/services/compute/resource_compute_project_cloud_armor_tier_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_project_default_network_tier_test.go b/google-beta/services/compute/resource_compute_project_default_network_tier_test.go index 4e4bfbc89f..8250a9a511 100644 --- a/google-beta/services/compute/resource_compute_project_default_network_tier_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_project_metadata_test.go b/google-beta/services/compute/resource_compute_project_metadata_test.go index 583fa6e663..a1b0b0e51e 100644 --- a/google-beta/services/compute/resource_compute_project_metadata_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_region_backend_service.go b/google-beta/services/compute/resource_compute_region_backend_service.go index 6ac71974b6..9fd2d13d8d 100644 --- a/google-beta/services/compute/resource_compute_region_backend_service.go +++ b/google-beta/services/compute/resource_compute_region_backend_service.go @@ -422,10 +422,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, }, "connection_tracking_policy": { @@ -659,14 +657,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, }, @@ -791,10 +794,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{ @@ -830,7 +830,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": { @@ -839,7 +838,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": { @@ -848,7 +846,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": { @@ -857,7 +854,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": { @@ -866,7 +862,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": { @@ -899,7 +894,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": { @@ -909,7 +903,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": { @@ -920,7 +913,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": { @@ -932,7 +924,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"}, }, }, @@ -1072,10 +1063,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, @@ -2693,6 +2682,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"] = @@ -2701,6 +2692,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 } @@ -3827,6 +3822,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 @@ -3851,6 +3853,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 } @@ -4218,23 +4224,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 @@ -4287,21 +4276,10 @@ 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") - } // Since we add in a NONE subsetting policy, we need to remove it in some // cases for backwards compatibility with the config - v, ok = res["subsetting"] + v, ok := res["subsetting"] if ok && v != nil { subsetting := v.(map[string]interface{}) policy, ok := subsetting["policy"] diff --git a/google-beta/services/compute/resource_compute_region_backend_service_generated_test.go b/google-beta/services/compute/resource_compute_region_backend_service_generated_test.go index add9181b87..fda5ac1e6f 100644 --- a/google-beta/services/compute/resource_compute_region_backend_service_generated_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_region_backend_service_test.go b/google-beta/services/compute/resource_compute_region_backend_service_test.go index c49c32f19f..bbc2b0710a 100644 --- a/google-beta/services/compute/resource_compute_region_backend_service_test.go +++ b/google-beta/services/compute/resource_compute_region_backend_service_test.go @@ -262,6 +262,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), }, @@ -271,14 +279,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, - }, }, }) } @@ -583,7 +583,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" @@ -609,7 +610,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" @@ -696,6 +698,7 @@ resource "google_compute_region_backend_service" "lipsum" { backend { group = google_compute_instance_group_manager.foobar.instance_group + balancing_mode = "CONNECTION" failover = true } @@ -763,6 +766,7 @@ resource "google_compute_region_backend_service" "lipsum" { backend { group = google_compute_instance_group_manager.foobar.instance_group + balancing_mode = "CONNECTION" failover = true } @@ -863,6 +867,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] @@ -1031,6 +1036,7 @@ resource "google_compute_region_backend_service" "foobar" { } iap { + enabled = true oauth2_client_id = "test" oauth2_client_secret = "test" } diff --git a/google-beta/services/compute/resource_compute_region_instance_template.go b/google-beta/services/compute/resource_compute_region_instance_template.go index 2c469c6122..e1d305463b 100644 --- a/google-beta/services/compute/resource_compute_region_instance_template.go +++ b/google-beta/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 }, @@ -1115,7 +1115,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-beta/services/compute/resource_compute_region_instance_template_test.go b/google-beta/services/compute/resource_compute_region_instance_template_test.go index 6898223f97..fd9e940367 100644 --- a/google-beta/services/compute/resource_compute_region_instance_template_test.go +++ b/google-beta/services/compute/resource_compute_region_instance_template_test.go @@ -2344,6 +2344,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" { @@ -2360,6 +2361,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-beta/services/compute/resource_compute_region_ssl_certificate.go b/google-beta/services/compute/resource_compute_region_ssl_certificate.go index dcd3f3cf5c..df7c261d97 100644 --- a/google-beta/services/compute/resource_compute_region_ssl_certificate.go +++ b/google-beta/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-beta/services/compute/resource_compute_reservation_generated_test.go b/google-beta/services/compute/resource_compute_reservation_generated_test.go index 17230b52e0..5472aa7af3 100644 --- a/google-beta/services/compute/resource_compute_reservation_generated_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_shared_reservation_update_test.go b/google-beta/services/compute/resource_compute_shared_reservation_update_test.go index dc5f67192b..4cb2b9c9ff 100644 --- a/google-beta/services/compute/resource_compute_shared_reservation_update_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_shared_vpc_test.go b/google-beta/services/compute/resource_compute_shared_vpc_test.go index 7f48690277..d36859b118 100644 --- a/google-beta/services/compute/resource_compute_shared_vpc_test.go +++ b/google-beta/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-beta/services/compute/resource_compute_ssl_certificate.go b/google-beta/services/compute/resource_compute_ssl_certificate.go index 70fa6e06eb..efc5fd6d63 100644 --- a/google-beta/services/compute/resource_compute_ssl_certificate.go +++ b/google-beta/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-beta/services/compute/resource_compute_subnetwork.go b/google-beta/services/compute/resource_compute_subnetwork.go index dbde728a5b..b7b7f2bd66 100644 --- a/google-beta/services/compute/resource_compute_subnetwork.go +++ b/google-beta/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, @@ -165,6 +156,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, @@ -271,6 +273,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, @@ -282,10 +292,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 @@ -296,15 +305,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, @@ -314,6 +314,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}'`, + }, }, }, }, @@ -439,6 +457,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 @@ -629,6 +653,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) } @@ -1251,6 +1278,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 } @@ -1283,8 +1317,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 @@ -1297,6 +1332,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 } @@ -1377,6 +1419,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 } @@ -1421,6 +1467,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 @@ -1434,6 +1487,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-beta/services/compute/resource_compute_subnetwork_generated_test.go b/google-beta/services/compute/resource_compute_subnetwork_generated_test.go index c673966f51..bdb6d3cfc0 100644 --- a/google-beta/services/compute/resource_compute_subnetwork_generated_test.go +++ b/google-beta/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_subnetworkInternalL7lbExample(t *testing.T) { ResourceName: "google_compute_subnetwork.network-for-l7lb", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) @@ -188,7 +188,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"}, }, }, }) @@ -234,7 +234,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"}, }, }, }) @@ -281,7 +281,7 @@ func TestAccComputeSubnetwork_subnetworkPurposePrivateNatExample(t *testing.T) { ResourceName: "google_compute_subnetwork.subnetwork-purpose-private-nat", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) @@ -327,7 +327,7 @@ func TestAccComputeSubnetwork_subnetworkCidrOverlapExample(t *testing.T) { ResourceName: "google_compute_subnetwork.subnetwork-cidr-overlap", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region"}, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, }, }, }) @@ -354,6 +354,133 @@ resource "google_compute_network" "net-cidr-overlap" { `, context) } +func TestAccComputeSubnetwork_subnetworkReservedInternalRangeExample(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.ProtoV5ProviderBetaFactories(t), + CheckDestroy: testAccCheckComputeSubnetworkDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeSubnetwork_subnetworkReservedInternalRangeExample(context), + }, + { + ResourceName: "google_compute_subnetwork.subnetwork-reserved-internal-range", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, + }, + }, + }) +} + +func testAccComputeSubnetwork_subnetworkReservedInternalRangeExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_compute_subnetwork" "subnetwork-reserved-internal-range" { + provider = google-beta + name = "tf-test-subnetwork-reserved-internal-range%{random_suffix}" + 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 = "tf-test-network-reserved-internal-range%{random_suffix}" + 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" + ] +} +`, context) +} + +func TestAccComputeSubnetwork_subnetworkReservedSecondaryRangeExample(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.ProtoV5ProviderBetaFactories(t), + CheckDestroy: testAccCheckComputeSubnetworkDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeSubnetwork_subnetworkReservedSecondaryRangeExample(context), + }, + { + ResourceName: "google_compute_subnetwork.subnetwork-reserved-secondary-range", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"network", "region", "reserved_internal_range"}, + }, + }, + }) +} + +func testAccComputeSubnetwork_subnetworkReservedSecondaryRangeExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_compute_subnetwork" "subnetwork-reserved-secondary-range" { + provider = google-beta + name = "tf-test-subnetwork-reserved-secondary-range%{random_suffix}" + 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 = "tf-test-network-reserved-secondary-range%{random_suffix}" + 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" + ] +} +`, context) +} + func testAccCheckComputeSubnetworkDestroyProducer(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-beta/services/compute/resource_compute_subnetwork_test.go b/google-beta/services/compute/resource_compute_subnetwork_test.go index 961d742f35..dc0b912635 100644 --- a/google-beta/services/compute/resource_compute_subnetwork_test.go +++ b/google-beta/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-beta/services/compute/resource_usage_export_bucket_test.go b/google-beta/services/compute/resource_usage_export_bucket_test.go index 356009330e..fad026e5d9 100644 --- a/google-beta/services/compute/resource_usage_export_bucket_test.go +++ b/google-beta/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-beta/services/container/data_source_google_container_cluster.go b/google-beta/services/container/data_source_google_container_cluster.go index 15e83c416f..088a026cf1 100644 --- a/google-beta/services/container/data_source_google_container_cluster.go +++ b/google-beta/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-beta/services/container/data_source_google_container_cluster_test.go b/google-beta/services/container/data_source_google_container_cluster_test.go index 97ed901336..87da147519 100644 --- a/google-beta/services/container/data_source_google_container_cluster_test.go +++ b/google-beta/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-beta/services/container/node_config.go b/google-beta/services/container/node_config.go index b0c44e9808..df8d550234 100644 --- a/google-beta/services/container/node_config.go +++ b/google-beta/services/container/node_config.go @@ -130,13 +130,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{ @@ -159,7 +156,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{ @@ -184,7 +180,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-beta/services/container/resource_container_cluster.go b/google-beta/services/container/resource_container_cluster.go index 1a8fd17241..0b62892d2c 100644 --- a/google-beta/services/container/resource_container_cluster.go +++ b/google-beta/services/container/resource_container_cluster.go @@ -209,6 +209,7 @@ func ResourceContainerCluster() *schema.Resource { containerClusterSurgeSettingsCustomizeDiff, containerClusterEnableK8sBetaApisCustomizeDiff, containerClusterNodeVersionCustomizeDiff, + tpgresource.SetDiffForLabelsWithCustomizedName("resource_labels"), ), Timeouts: &schema.ResourceTimeout{ @@ -1267,20 +1268,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.`, }, }, }, @@ -1790,10 +1780,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": { @@ -2202,12 +2207,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{}) @@ -2343,7 +2342,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")), ProtectConfig: expandProtectConfig(d.Get("protect_config")), CostManagementConfig: expandCostManagementConfig(d.Get("cost_management_config")), @@ -2951,8 +2950,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) @@ -4034,8 +4039,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), @@ -5503,21 +5508,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"}, } } @@ -6394,29 +6388,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-beta/services/container/resource_container_cluster_test.go b/google-beta/services/container/resource_container_cluster_test.go index 79e322f151..9ca23f27ba 100644 --- a/google-beta/services/container/resource_container_cluster_test.go +++ b/google-beta/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"}, }, }, }) @@ -3403,24 +3403,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"}, - }, }, }) } @@ -8534,6 +8516,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" { @@ -8550,6 +8533,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" { @@ -9670,56 +9654,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" { @@ -9770,56 +9704,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" { @@ -10871,6 +10755,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)) @@ -11151,3 +11036,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-beta/services/container/resource_container_node_pool_test.go b/google-beta/services/container/resource_container_node_pool_test.go index e694c9788b..eb0cec9d44 100644 --- a/google-beta/services/container/resource_container_node_pool_test.go +++ b/google-beta/services/container/resource_container_node_pool_test.go @@ -1288,45 +1288,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() @@ -3743,59 +3704,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" { @@ -4863,6 +4771,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-beta/services/corebilling/resource_billing_project_info.go b/google-beta/services/corebilling/resource_billing_project_info.go index 83b76b2b13..4c0ceccd6a 100644 --- a/google-beta/services/corebilling/resource_billing_project_info.go +++ b/google-beta/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-beta/services/corebilling/resource_billing_project_info_generated_test.go b/google-beta/services/corebilling/resource_billing_project_info_generated_test.go index bc3e8340dc..6d7e4dbe47 100644 --- a/google-beta/services/corebilling/resource_billing_project_info_generated_test.go +++ b/google-beta/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-beta/services/corebilling/resource_google_billing_project_info_test.go b/google-beta/services/corebilling/resource_google_billing_project_info_test.go index 25f3dd3d76..a54c6321d6 100644 --- a/google-beta/services/corebilling/resource_google_billing_project_info_test.go +++ b/google-beta/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-beta/services/dataplex/resource_dataplex_datascan.go b/google-beta/services/dataplex/resource_dataplex_datascan.go index f9fc8e585a..d38a8c8091 100644 --- a/google-beta/services/dataplex/resource_dataplex_datascan.go +++ b/google-beta/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-beta/services/dataplex/resource_dataplex_task.go b/google-beta/services/dataplex/resource_dataplex_task.go index 08f51ceca7..f8e5ebdc59 100644 --- a/google-beta/services/dataplex/resource_dataplex_task.go +++ b/google-beta/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-beta/services/dataproc/resource_dataproc_cluster.go b/google-beta/services/dataproc/resource_dataproc_cluster.go index 000c31917b..43520a371a 100644 --- a/google-beta/services/dataproc/resource_dataproc_cluster.go +++ b/google-beta/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-beta/services/datastore/datastore_operation.go b/google-beta/services/datastore/datastore_operation.go deleted file mode 100644 index efbdad9e79..0000000000 --- a/google-beta/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-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/datastore/resource_datastore_index.go b/google-beta/services/datastore/resource_datastore_index.go deleted file mode 100644 index afd1170810..0000000000 --- a/google-beta/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-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/datastore/resource_datastore_index_generated_test.go b/google-beta/services/datastore/resource_datastore_index_generated_test.go deleted file mode 100644 index 59d8ac50f1..0000000000 --- a/google-beta/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-beta/google-beta/acctest" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/datastore/resource_datastore_index_sweeper.go b/google-beta/services/datastore/resource_datastore_index_sweeper.go deleted file mode 100644 index 086abeca36..0000000000 --- a/google-beta/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-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/dialogflow/resource_dialogflow_agent_test.go b/google-beta/services/dialogflow/resource_dialogflow_agent_test.go index ca32f12206..21645d38f7 100644 --- a/google-beta/services/dialogflow/resource_dialogflow_agent_test.go +++ b/google-beta/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-beta/services/dialogflow/resource_dialogflow_entity_type_test.go b/google-beta/services/dialogflow/resource_dialogflow_entity_type_test.go index ddd30d9886..d509b6da03 100644 --- a/google-beta/services/dialogflow/resource_dialogflow_entity_type_test.go +++ b/google-beta/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-beta/services/dialogflow/resource_dialogflow_fulfillment_test.go b/google-beta/services/dialogflow/resource_dialogflow_fulfillment_test.go index af471c8f7a..6f92e0c0d9 100644 --- a/google-beta/services/dialogflow/resource_dialogflow_fulfillment_test.go +++ b/google-beta/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-beta/services/dialogflow/resource_dialogflow_intent_generated_test.go b/google-beta/services/dialogflow/resource_dialogflow_intent_generated_test.go index e6bc825b83..6f1a9a7029 100644 --- a/google-beta/services/dialogflow/resource_dialogflow_intent_generated_test.go +++ b/google-beta/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-beta/services/dialogflow/resource_dialogflow_intent_test.go b/google-beta/services/dialogflow/resource_dialogflow_intent_test.go index f870816781..0c7e5f0d6c 100644 --- a/google-beta/services/dialogflow/resource_dialogflow_intent_test.go +++ b/google-beta/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-beta/services/dns/resource_dns_managed_zone_generated_test.go b/google-beta/services/dns/resource_dns_managed_zone_generated_test.go index 108bd2b8f1..851ec7737e 100644 --- a/google-beta/services/dns/resource_dns_managed_zone_generated_test.go +++ b/google-beta/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-beta/services/dns/resource_dns_policy_generated_test.go b/google-beta/services/dns/resource_dns_policy_generated_test.go index 51884d3950..5b8eae9dd9 100644 --- a/google-beta/services/dns/resource_dns_policy_generated_test.go +++ b/google-beta/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-beta/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go b/google-beta/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go index 3e521d6bae..d5ca5ea155 100644 --- a/google-beta/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_test.go +++ b/google-beta/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-beta/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go b/google-beta/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go index 773407676e..fe0e8ecd25 100644 --- a/google-beta/services/edgecontainer/resource_edgecontainer_cluster_generated_test.go +++ b/google-beta/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-beta/services/edgenetwork/resource_edgenetwork_network.go b/google-beta/services/edgenetwork/resource_edgenetwork_network.go index 9d68dde89b..c7654bf69f 100644 --- a/google-beta/services/edgenetwork/resource_edgenetwork_network.go +++ b/google-beta/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-beta/services/edgenetwork/resource_edgenetwork_subnet.go b/google-beta/services/edgenetwork/resource_edgenetwork_subnet.go index ae38712a15..7ec29a21ec 100644 --- a/google-beta/services/edgenetwork/resource_edgenetwork_subnet.go +++ b/google-beta/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-beta/services/firebase/resource_firebase_project_generated_test.go b/google-beta/services/firebase/resource_firebase_project_generated_test.go index 87634e7eb3..f452adeee9 100644 --- a/google-beta/services/firebase/resource_firebase_project_generated_test.go +++ b/google-beta/services/firebase/resource_firebase_project_generated_test.go @@ -58,6 +58,7 @@ resource "google_project" "default" { project_id = "tf-test-my-project%{random_suffix}" name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" diff --git a/google-beta/services/firebase/resource_firebase_project_test.go b/google-beta/services/firebase/resource_firebase_project_test.go index a5530bd836..6bf7adebdf 100644 --- a/google-beta/services/firebase/resource_firebase_project_test.go +++ b/google-beta/services/firebase/resource_firebase_project_test.go @@ -48,6 +48,7 @@ resource "google_project" "default" { project_id = "tf-test-my-project%{random_suffix}" name = "tf-test-my-project%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" diff --git a/google-beta/services/firebase/resource_firebase_web_app_test.go b/google-beta/services/firebase/resource_firebase_web_app_test.go index 3a7f438dc6..513c00052a 100644 --- a/google-beta/services/firebase/resource_firebase_web_app_test.go +++ b/google-beta/services/firebase/resource_firebase_web_app_test.go @@ -126,6 +126,7 @@ resource "google_project" "default" { project_id = "tf-test%{random_suffix}" name = "tf-test%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" } diff --git a/google-beta/services/firebaseappcheck/resource_firebase_app_check_service_config_test.go b/google-beta/services/firebaseappcheck/resource_firebase_app_check_service_config_test.go index 82e138fa0a..3e484c87ef 100644 --- a/google-beta/services/firebaseappcheck/resource_firebase_app_check_service_config_test.go +++ b/google-beta/services/firebaseappcheck/resource_firebase_app_check_service_config_test.go @@ -68,6 +68,7 @@ resource "google_project" "default" { project_id = "tf-test-appcheck%{random_suffix}" name = "tf-test-appcheck%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" } diff --git a/google-beta/services/firebasedatabase/resource_firebase_database_instance_generated_test.go b/google-beta/services/firebasedatabase/resource_firebase_database_instance_generated_test.go index 4aaa57866b..fe01deb918 100644 --- a/google-beta/services/firebasedatabase/resource_firebase_database_instance_generated_test.go +++ b/google-beta/services/firebasedatabase/resource_firebase_database_instance_generated_test.go @@ -140,6 +140,7 @@ resource "google_project" "default" { project_id = "tf-test-rtdb-project%{random_suffix}" name = "tf-test-rtdb-project%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" labels = { "firebase" = "enabled" } diff --git a/google-beta/services/firebasehosting/resource_firebase_hosting_custom_domain_generated_test.go b/google-beta/services/firebasehosting/resource_firebase_hosting_custom_domain_generated_test.go index 7c111959fb..b911614fea 100644 --- a/google-beta/services/firebasehosting/resource_firebase_hosting_custom_domain_generated_test.go +++ b/google-beta/services/firebasehosting/resource_firebase_hosting_custom_domain_generated_test.go @@ -126,9 +126,10 @@ func TestAccFirebaseHostingCustomDomain_firebasehostingCustomdomainCloudRunExamp t.Parallel() context := map[string]interface{}{ - "project_id": envvar.GetTestProjectFromEnv(), - "custom_domain": "run.custom.domain.com", - "random_suffix": acctest.RandString(t, 10), + "project_id": envvar.GetTestProjectFromEnv(), + "custom_domain": "run.custom.domain.com", + "deletion_protection": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -143,7 +144,7 @@ func TestAccFirebaseHostingCustomDomain_firebasehostingCustomdomainCloudRunExamp ResourceName: "google_firebase_hosting_custom_domain.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"custom_domain", "site_id"}, + ImportStateVerifyIgnore: []string{"custom_domain", "deletion_protection", "site_id"}, }, }, }) @@ -171,6 +172,8 @@ resource "google_cloud_run_v2_service" "default" { image = "us-docker.pkg.dev/cloudrun/container/hello" } } + + deletion_protection = "%{deletion_protection}" } resource "google_firebase_hosting_version" "default" { diff --git a/google-beta/services/firebasehosting/resource_firebase_hosting_version_generated_test.go b/google-beta/services/firebasehosting/resource_firebase_hosting_version_generated_test.go index e3fd79e7f0..f6446e8217 100644 --- a/google-beta/services/firebasehosting/resource_firebase_hosting_version_generated_test.go +++ b/google-beta/services/firebasehosting/resource_firebase_hosting_version_generated_test.go @@ -137,8 +137,9 @@ func TestAccFirebaseHostingVersion_firebasehostingVersionCloudRunExample(t *test t.Parallel() context := map[string]interface{}{ - "project_id": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), + "project_id": envvar.GetTestProjectFromEnv(), + "deletion_protection": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -152,7 +153,7 @@ func TestAccFirebaseHostingVersion_firebasehostingVersionCloudRunExample(t *test ResourceName: "google_firebase_hosting_version.default", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"site_id", "version_id"}, + ImportStateVerifyIgnore: []string{"deletion_protection", "site_id", "version_id"}, }, }, }) @@ -180,6 +181,8 @@ resource "google_cloud_run_v2_service" "default" { image = "us-docker.pkg.dev/cloudrun/container/hello" } } + + deletion_protection = "%{deletion_protection}" } resource "google_firebase_hosting_version" "default" { diff --git a/google-beta/services/firestore/resource_firestore_document_generated_test.go b/google-beta/services/firestore/resource_firestore_document_generated_test.go index 11beeb6430..704080ef01 100644 --- a/google-beta/services/firestore/resource_firestore_document_generated_test.go +++ b/google-beta/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-beta/services/firestore/resource_firestore_document_test.go b/google-beta/services/firestore/resource_firestore_document_test.go index 69fb36f877..dce739a17d 100644 --- a/google-beta/services/firestore/resource_firestore_document_test.go +++ b/google-beta/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-beta/services/firestore/resource_firestore_field_test.go b/google-beta/services/firestore/resource_firestore_field_test.go index 3a55491881..0243424113 100644 --- a/google-beta/services/firestore/resource_firestore_field_test.go +++ b/google-beta/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-beta/services/gkehub/resource_gke_hub_feature_membership_test.go b/google-beta/services/gkehub/resource_gke_hub_feature_membership_test.go index 9dfbc0e28a..3299b54e0e 100644 --- a/google-beta/services/gkehub/resource_gke_hub_feature_membership_test.go +++ b/google-beta/services/gkehub/resource_gke_hub_feature_membership_test.go @@ -1326,6 +1326,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-beta/services/gkehub2/iam_gke_hub_feature_test.go b/google-beta/services/gkehub2/iam_gke_hub_feature_test.go index a8307eaa75..94d53af822 100644 --- a/google-beta/services/gkehub2/iam_gke_hub_feature_test.go +++ b/google-beta/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-beta/services/gkehub2/resource_gke_hub_feature_test.go b/google-beta/services/gkehub2/resource_gke_hub_feature_test.go index ffa165d151..74c1fc3e66 100644 --- a/google-beta/services/gkehub2/resource_gke_hub_feature_test.go +++ b/google-beta/services/gkehub2/resource_gke_hub_feature_test.go @@ -149,6 +149,7 @@ resource "google_project" "project" { org_id = "%{org_id}" billing_account = "%{billing_account}" provider = google-beta + deletion_policy = "DELETE" } resource "google_project_service" "mesh" { @@ -984,6 +985,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" { @@ -1039,6 +1041,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-beta/services/gkehub2/resource_gke_hub_fleet_test.go b/google-beta/services/gkehub2/resource_gke_hub_fleet_test.go index 0bb6b340ef..d5d14fe568 100755 --- a/google-beta/services/gkehub2/resource_gke_hub_fleet_test.go +++ b/google-beta/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-beta/services/iam2/resource_iam_access_boundary_policy_test.go b/google-beta/services/iam2/resource_iam_access_boundary_policy_test.go index e50ca9d42f..d52da843b8 100644 --- a/google-beta/services/iam2/resource_iam_access_boundary_policy_test.go +++ b/google-beta/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-beta/services/iam2/resource_iam_deny_policy_generated_test.go b/google-beta/services/iam2/resource_iam_deny_policy_generated_test.go index 484505a8b3..07e571d07d 100644 --- a/google-beta/services/iam2/resource_iam_deny_policy_generated_test.go +++ b/google-beta/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-beta/services/iam2/resource_iam_deny_policy_test.go b/google-beta/services/iam2/resource_iam_deny_policy_test.go index be57312aca..d91a3a4be5 100644 --- a/google-beta/services/iam2/resource_iam_deny_policy_test.go +++ b/google-beta/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-beta/services/iap/data_source_iap_client_test.go b/google-beta/services/iap/data_source_iap_client_test.go index bb48f5078c..90801e25dc 100644 --- a/google-beta/services/iap/data_source_iap_client_test.go +++ b/google-beta/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-beta/services/iap/iam_iap_tunnel_generated_test.go b/google-beta/services/iap/iam_iap_tunnel_generated_test.go index 2fb4e555b4..b846dab54b 100644 --- a/google-beta/services/iap/iam_iap_tunnel_generated_test.go +++ b/google-beta/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-beta/services/iap/iam_iap_web_generated_test.go b/google-beta/services/iap/iam_iap_web_generated_test.go index 8b6d20ac66..ae65051046 100644 --- a/google-beta/services/iap/iam_iap_web_generated_test.go +++ b/google-beta/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-beta/services/iap/iam_iap_web_type_app_engine_generated_test.go b/google-beta/services/iap/iam_iap_web_type_app_engine_generated_test.go index b822e8ea9a..cb951b25ca 100644 --- a/google-beta/services/iap/iam_iap_web_type_app_engine_generated_test.go +++ b/google-beta/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-beta/services/iap/iam_iap_web_type_compute_generated_test.go b/google-beta/services/iap/iam_iap_web_type_compute_generated_test.go index 293c29afdd..c3e3bfc257 100644 --- a/google-beta/services/iap/iam_iap_web_type_compute_generated_test.go +++ b/google-beta/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-beta/services/iap/resource_iap_brand_test.go b/google-beta/services/iap/resource_iap_brand_test.go index fbda5a2d85..49a97b2d1d 100644 --- a/google-beta/services/iap/resource_iap_brand_test.go +++ b/google-beta/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-beta/services/iap/resource_iap_client_generated_test.go b/google-beta/services/iap/resource_iap_client_generated_test.go index f552bef25e..28ad3699f1 100644 --- a/google-beta/services/iap/resource_iap_client_generated_test.go +++ b/google-beta/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-beta/services/identityplatform/resource_identity_platform_config_generated_test.go b/google-beta/services/identityplatform/resource_identity_platform_config_generated_test.go index 5e4dca706b..1e84354c6f 100644 --- a/google-beta/services/identityplatform/resource_identity_platform_config_generated_test.go +++ b/google-beta/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-beta/services/identityplatform/resource_identity_platform_config_test.go b/google-beta/services/identityplatform/resource_identity_platform_config_test.go index 23208ac330..871b4a2a88 100644 --- a/google-beta/services/identityplatform/resource_identity_platform_config_test.go +++ b/google-beta/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-beta/services/identityplatform/resource_identity_platform_project_default_config.go b/google-beta/services/identityplatform/resource_identity_platform_project_default_config.go deleted file mode 100644 index 7e316d2607..0000000000 --- a/google-beta/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-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/identityplatform/resource_identity_platform_project_default_config_sweeper.go b/google-beta/services/identityplatform/resource_identity_platform_project_default_config_sweeper.go deleted file mode 100644 index 719736ab34..0000000000 --- a/google-beta/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-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go b/google-beta/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go index 670e9734cb..6b41e09d2e 100644 --- a/google-beta/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_test.go +++ b/google-beta/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-beta/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go b/google-beta/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go index 694c8a426d..611172452a 100644 --- a/google-beta/services/integrationconnectors/resource_integration_connectors_managed_zone_test.go +++ b/google-beta/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-beta/services/integrations/resource_integrations_auth_config_test.go b/google-beta/services/integrations/resource_integrations_auth_config_test.go index cc249b4570..d18221e963 100644 --- a/google-beta/services/integrations/resource_integrations_auth_config_test.go +++ b/google-beta/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-beta/services/integrations/resource_integrations_client.go b/google-beta/services/integrations/resource_integrations_client.go index 03485d36ec..8e8555bf60 100644 --- a/google-beta/services/integrations/resource_integrations_client.go +++ b/google-beta/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-beta/services/integrations/resource_integrations_client_generated_test.go b/google-beta/services/integrations/resource_integrations_client_generated_test.go index 6e12e55c84..da5e3ee145 100644 --- a/google-beta/services/integrations/resource_integrations_client_generated_test.go +++ b/google-beta/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-beta/services/kms/data_source_google_kms_secret_asymmetric_test.go b/google-beta/services/kms/data_source_google_kms_secret_asymmetric_test.go index 9578db1d74..a513649344 100644 --- a/google-beta/services/kms/data_source_google_kms_secret_asymmetric_test.go +++ b/google-beta/services/kms/data_source_google_kms_secret_asymmetric_test.go @@ -127,6 +127,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-beta/services/kms/iam_kms_crypto_key_test.go b/google-beta/services/kms/iam_kms_crypto_key_test.go index 5793b178d9..1f40421818 100644 --- a/google-beta/services/kms/iam_kms_crypto_key_test.go +++ b/google-beta/services/kms/iam_kms_crypto_key_test.go @@ -365,6 +365,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -409,6 +410,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -462,6 +464,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -511,6 +514,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -555,6 +559,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -604,6 +609,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -658,6 +664,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-beta/services/kms/iam_kms_key_ring_test.go b/google-beta/services/kms/iam_kms_key_ring_test.go index c146fce6ae..a9f1ee6ab2 100644 --- a/google-beta/services/kms/iam_kms_key_ring_test.go +++ b/google-beta/services/kms/iam_kms_key_ring_test.go @@ -278,6 +278,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -317,6 +318,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -365,6 +367,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -409,6 +412,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -448,6 +452,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -492,6 +497,7 @@ resource "google_project" "test_project" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "kms" { @@ -538,6 +544,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-beta/services/kms/resource_kms_autokey_config_generated_test.go b/google-beta/services/kms/resource_kms_autokey_config_generated_test.go index b44d22a76d..18f0e45853 100644 --- a/google-beta/services/kms/resource_kms_autokey_config_generated_test.go +++ b/google-beta/services/kms/resource_kms_autokey_config_generated_test.go @@ -32,6 +32,7 @@ import ( ) func TestAccKMSAutokeyConfig_kmsAutokeyConfigAllExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -69,6 +70,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "tf-test-my-folder%{random_suffix}" parent = "organizations/%{org_id}" + deletion_protection = false } # Create the key project @@ -79,6 +81,7 @@ resource "google_project" "key_project" { folder_id = google_folder.autokms_folder.folder_id billing_account = "%{billing_account}" depends_on = [google_folder.autokms_folder] + deletion_policy = "DELETE" } # Enable the Cloud KMS API diff --git a/google-beta/services/kms/resource_kms_crypto_key_test.go b/google-beta/services/kms/resource_kms_crypto_key_test.go index becc4f65ab..6cf7f8be00 100644 --- a/google-beta/services/kms/resource_kms_crypto_key_test.go +++ b/google-beta/services/kms/resource_kms_crypto_key_test.go @@ -675,6 +675,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -705,6 +706,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -733,6 +735,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -760,6 +763,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -792,6 +796,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -839,6 +844,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -871,6 +877,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -907,6 +914,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -939,6 +947,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -973,6 +982,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1011,6 +1021,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1041,6 +1052,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1075,6 +1087,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1113,6 +1126,7 @@ resource "google_project" "acceptance" { project_id = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "acceptance" { @@ -1151,6 +1165,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-beta/services/kms/resource_kms_key_handle_generated_test.go b/google-beta/services/kms/resource_kms_key_handle_generated_test.go index 01d07fade0..a64ce59f54 100644 --- a/google-beta/services/kms/resource_kms_key_handle_generated_test.go +++ b/google-beta/services/kms/resource_kms_key_handle_generated_test.go @@ -27,6 +27,7 @@ import ( ) func TestAccKMSKeyHandle_kmsKeyHandleBasicExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -63,6 +64,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "folder-example" parent = "organizations/%{org_id}" + deletion_protection = false } # Create the key project @@ -73,6 +75,7 @@ resource "google_project" "key_project" { folder_id = google_folder.autokms_folder.folder_id billing_account = "%{billing_account}" depends_on = [google_folder.autokms_folder] + deletion_policy = "DELETE" } # Create the resource project @@ -83,6 +86,7 @@ resource "google_project" "resource_project" { folder_id = google_folder.autokms_folder.folder_id billing_account = "%{billing_account}" depends_on = [google_folder.autokms_folder] + deletion_policy = "DELETE" } # Enable the Cloud KMS API diff --git a/google-beta/services/kms/resource_kms_key_ring_test.go b/google-beta/services/kms/resource_kms_key_ring_test.go index 035e343f57..29a8f18c15 100644 --- a/google-beta/services/kms/resource_kms_key_ring_test.go +++ b/google-beta/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-beta/services/logging/data_source_google_logging_folder_settings_test.go b/google-beta/services/logging/data_source_google_logging_folder_settings_test.go index e58bda30c2..19ace397b0 100644 --- a/google-beta/services/logging/data_source_google_logging_folder_settings_test.go +++ b/google-beta/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-beta/services/logging/data_source_google_logging_project_cmek_settings_test.go b/google-beta/services/logging/data_source_google_logging_project_cmek_settings_test.go index 3ef1b832c0..f0556ff539 100644 --- a/google-beta/services/logging/data_source_google_logging_project_cmek_settings_test.go +++ b/google-beta/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-beta/services/logging/data_source_google_logging_project_settings_test.go b/google-beta/services/logging/data_source_google_logging_project_settings_test.go index fd4edb6972..d6212c039e 100644 --- a/google-beta/services/logging/data_source_google_logging_project_settings_test.go +++ b/google-beta/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-beta/services/logging/resource_logging_bucket_config_test.go b/google-beta/services/logging/resource_logging_bucket_config_test.go index b7bb3535ba..397deadd1e 100644 --- a/google-beta/services/logging/resource_logging_bucket_config_test.go +++ b/google-beta/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-beta/services/logging/resource_logging_folder_exclusion_test.go b/google-beta/services/logging/resource_logging_folder_exclusion_test.go index 9f544a6ca7..57b453d88f 100644 --- a/google-beta/services/logging/resource_logging_folder_exclusion_test.go +++ b/google-beta/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-beta/services/logging/resource_logging_folder_settings_generated_test.go b/google-beta/services/logging/resource_logging_folder_settings_generated_test.go index 9f3a77354f..e391e3e403 100644 --- a/google-beta/services/logging/resource_logging_folder_settings_generated_test.go +++ b/google-beta/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-beta/services/logging/resource_logging_folder_settings_test.go b/google-beta/services/logging/resource_logging_folder_settings_test.go index e997f062e5..e6c4e70241 100644 --- a/google-beta/services/logging/resource_logging_folder_settings_test.go +++ b/google-beta/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-beta/services/logging/resource_logging_folder_sink_test.go b/google-beta/services/logging/resource_logging_folder_sink_test.go index 9cd5b9b12e..16695d24c2 100644 --- a/google-beta/services/logging/resource_logging_folder_sink_test.go +++ b/google-beta/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-beta/services/logging/resource_logging_project_sink_test.go b/google-beta/services/logging/resource_logging_project_sink_test.go index 8c0a345265..bcaaa57e70 100644 --- a/google-beta/services/logging/resource_logging_project_sink_test.go +++ b/google-beta/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-beta/services/monitoring/resource_monitoring_monitored_project_generated_test.go b/google-beta/services/monitoring/resource_monitoring_monitored_project_generated_test.go index 330f4cd613..4f84898a70 100644 --- a/google-beta/services/monitoring/resource_monitoring_monitored_project_generated_test.go +++ b/google-beta/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-beta/services/monitoring/resource_monitoring_monitored_project_test.go b/google-beta/services/monitoring/resource_monitoring_monitored_project_test.go index eed05bb2fb..ba21712fc7 100644 --- a/google-beta/services/monitoring/resource_monitoring_monitored_project_test.go +++ b/google-beta/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-beta/services/networksecurity/resource_network_security_client_tls_policy_generated_test.go b/google-beta/services/networksecurity/resource_network_security_client_tls_policy_generated_test.go index 0c346ccde8..64bd0a4888 100644 --- a/google-beta/services/networksecurity/resource_network_security_client_tls_policy_generated_test.go +++ b/google-beta/services/networksecurity/resource_network_security_client_tls_policy_generated_test.go @@ -31,6 +31,7 @@ import ( ) func TestAccNetworkSecurityClientTlsPolicy_networkSecurityClientTlsPolicyBasicExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -70,6 +71,7 @@ resource "google_network_security_client_tls_policy" "default" { } func TestAccNetworkSecurityClientTlsPolicy_networkSecurityClientTlsPolicyAdvancedExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/google-beta/services/networksecurity/resource_network_security_client_tls_policy_test.go b/google-beta/services/networksecurity/resource_network_security_client_tls_policy_test.go index 9b5cb2f215..92f67c0635 100644 --- a/google-beta/services/networksecurity/resource_network_security_client_tls_policy_test.go +++ b/google-beta/services/networksecurity/resource_network_security_client_tls_policy_test.go @@ -11,6 +11,7 @@ import ( ) func TestAccNetworkSecurityClientTlsPolicy_update(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() clientTlsPolicyName := fmt.Sprintf("tf-test-client-tls-policy-%s", acctest.RandString(t, 10)) diff --git a/google-beta/services/orgpolicy/resource_org_policy_policy_test.go b/google-beta/services/orgpolicy/resource_org_policy_policy_test.go index a2deb56590..dc11046590 100644 --- a/google-beta/services/orgpolicy/resource_org_policy_policy_test.go +++ b/google-beta/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-beta/services/oslogin/resource_os_login_ssh_public_key_test.go b/google-beta/services/oslogin/resource_os_login_ssh_public_key_test.go index e08bf2ac7c..06cfcd3841 100644 --- a/google-beta/services/oslogin/resource_os_login_ssh_public_key_test.go +++ b/google-beta/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-beta/services/pubsub/resource_pubsub_topic.go b/google-beta/services/pubsub/resource_pubsub_topic.go index 7b4ca56c04..9ce33bf1c4 100644 --- a/google-beta/services/pubsub/resource_pubsub_topic.go +++ b/google-beta/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-beta/services/pubsub/resource_pubsub_topic_test.go b/google-beta/services/pubsub/resource_pubsub_topic_test.go index aecd6b9de8..05615c789f 100644 --- a/google-beta/services/pubsub/resource_pubsub_topic_test.go +++ b/google-beta/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-beta/services/redis/resource_redis_cluster.go b/google-beta/services/redis/resource_redis_cluster.go index 4d2a4d4ebc..13d6eb1290 100644 --- a/google-beta/services/redis/resource_redis_cluster.go +++ b/google-beta/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-beta/services/redis/resource_redis_cluster_generated_test.go b/google-beta/services/redis/resource_redis_cluster_generated_test.go index 6fe407fa32..30e8d9bcd7 100644 --- a/google-beta/services/redis/resource_redis_cluster_generated_test.go +++ b/google-beta/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-beta/services/redis/resource_redis_cluster_test.go b/google-beta/services/redis/resource_redis_cluster_test.go index f63f080dcf..0dd39943c6 100644 --- a/google-beta/services/redis/resource_redis_cluster_test.go +++ b/google-beta/services/redis/resource_redis_cluster_test.go @@ -12,6 +12,7 @@ import ( ) func TestAccRedisCluster_createClusterWithNodeType(t *testing.T) { + t.Parallel() name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) @@ -23,7 +24,7 @@ func TestAccRedisCluster_createClusterWithNodeType(t *testing.T) { Steps: []resource.TestStep{ { // create cluster with replica count 1 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, nodeType: "REDIS_STANDARD_SMALL", zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, deletionProtectionEnabled: true, nodeType: "REDIS_STANDARD_SMALL", zoneDistributionMode: "MULTI_ZONE"}), }, { ResourceName: "google_redis_cluster.test", @@ -33,7 +34,7 @@ func TestAccRedisCluster_createClusterWithNodeType(t *testing.T) { }, { // clean up the resource - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: false, nodeType: "REDIS_STANDARD_SMALL", zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, deletionProtectionEnabled: false, nodeType: "REDIS_STANDARD_SMALL", zoneDistributionMode: "MULTI_ZONE"}), }, }, }) @@ -52,7 +53,7 @@ func TestAccRedisCluster_createClusterWithZoneDistribution(t *testing.T) { Steps: []resource.TestStep{ { // create cluster with replica count 1 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: false, zoneDistributionMode: "SINGLE_ZONE", zone: "us-central1-b"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: false, zoneDistributionMode: "SINGLE_ZONE", zone: "us-central1-b"}), }, { ResourceName: "google_redis_cluster.test", @@ -62,7 +63,7 @@ func TestAccRedisCluster_createClusterWithZoneDistribution(t *testing.T) { }, { // clean up the resource - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: false, zoneDistributionMode: "SINGLE_ZONE", zone: "us-central1-b"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: false, zoneDistributionMode: "SINGLE_ZONE", zone: "us-central1-b"}), }, }, }) @@ -81,7 +82,7 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { Steps: []resource.TestStep{ { // create cluster with replica count 1 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, deletionProtectionEnabled: true, zoneDistributionMode: "MULTI_ZONE"}), }, { ResourceName: "google_redis_cluster.test", @@ -91,7 +92,7 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { }, { // update replica count to 2 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 2, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 2, shardCount: 3, deletionProtectionEnabled: true, zoneDistributionMode: "MULTI_ZONE"}), }, { ResourceName: "google_redis_cluster.test", @@ -99,13 +100,9 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"psc_configs"}, }, - { - // clean up the resource - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE"}), - }, { // update replica count to 0 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: true, zoneDistributionMode: "MULTI_ZONE"}), }, { ResourceName: "google_redis_cluster.test", @@ -115,7 +112,7 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { }, { // clean up the resource - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: false, zoneDistributionMode: "MULTI_ZONE"}), }, }, }) @@ -134,7 +131,7 @@ func TestAccRedisCluster_updateShardCount(t *testing.T) { Steps: []resource.TestStep{ { // create cluster with shard count 3 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 3, deletionProtectionEnabled: true, zoneDistributionMode: "MULTI_ZONE"}), }, { ResourceName: "google_redis_cluster.test", @@ -144,7 +141,7 @@ func TestAccRedisCluster_updateShardCount(t *testing.T) { }, { // update shard count to 5 - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 5, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 5, deletionProtectionEnabled: true, zoneDistributionMode: "MULTI_ZONE"}), }, { ResourceName: "google_redis_cluster.test", @@ -154,7 +151,7 @@ func TestAccRedisCluster_updateShardCount(t *testing.T) { }, { // clean up the resource - Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 5, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE"}), + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 1, shardCount: 5, deletionProtectionEnabled: false, zoneDistributionMode: "MULTI_ZONE"}), }, }, }) @@ -212,25 +209,57 @@ func TestAccRedisCluster_updateRedisConfigs(t *testing.T) { }) } +// Validate that deletion protection enabled/disabled cluster is created updated +func TestAccRedisCluster_createUpdateDeletionProtection(t *testing.T) { + t.Parallel() + + name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), + CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), + Steps: []resource.TestStep{ + { + // create cluster with deletion protection set to false + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: false, zoneDistributionMode: "MULTI_ZONE"}), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"psc_configs"}, + }, + { + // update deletion protection to true + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: true, zoneDistributionMode: "MULTI_ZONE"}), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"psc_configs"}, + }, + { + // update deletion protection to false and delete the cluster + Config: createOrUpdateRedisCluster(&ClusterParams{name: name, replicaCount: 0, shardCount: 3, deletionProtectionEnabled: false, zoneDistributionMode: "MULTI_ZONE"}), + }, + }, + }) +} + type ClusterParams struct { - name string - replicaCount int - shardCount int - preventDestroy bool - nodeType string - redisConfigs map[string]string - zoneDistributionMode string - zone string + name string + replicaCount int + shardCount int + deletionProtectionEnabled bool + nodeType string + redisConfigs map[string]string + zoneDistributionMode string + zone string } func createOrUpdateRedisCluster(params *ClusterParams) string { - lifecycleBlock := "" - if params.preventDestroy { - lifecycleBlock = ` - lifecycle { - prevent_destroy = true - }` - } var strBuilder strings.Builder for key, value := range params.redisConfigs { strBuilder.WriteString(fmt.Sprintf("%s = \"%s\"\n", key, value)) @@ -253,6 +282,7 @@ resource "google_redis_cluster" "test" { replica_count = %d shard_count = %d node_type = "%s" + deletion_protection_enabled = %v region = "us-central1" psc_configs { network = google_compute_network.producer_net.id @@ -262,9 +292,8 @@ resource "google_redis_cluster" "test" { } %s depends_on = [ - google_network_connectivity_service_connection_policy.default - ] - %s + google_network_connectivity_service_connection_policy.default + ] } resource "google_network_connectivity_service_connection_policy" "default" { @@ -292,5 +321,5 @@ resource "google_compute_network" "producer_net" { name = "%s" auto_create_subnetworks = false } -`, params.name, params.replicaCount, params.shardCount, params.nodeType, strBuilder.String(), zoneDistributionConfigBlock, lifecycleBlock, params.name, params.name, params.name) +`, params.name, params.replicaCount, params.shardCount, params.nodeType, params.deletionProtectionEnabled, strBuilder.String(), zoneDistributionConfigBlock, params.name, params.name, params.name) } diff --git a/google-beta/services/resourcemanager/data_source_google_active_folder_test.go b/google-beta/services/resourcemanager/data_source_google_active_folder_test.go index 1aea905530..67266e88aa 100644 --- a/google-beta/services/resourcemanager/data_source_google_active_folder_test.go +++ b/google-beta/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-beta/services/resourcemanager/data_source_google_folder.go b/google-beta/services/resourcemanager/data_source_google_folder.go index 018a9a9ac1..5316cc062f 100644 --- a/google-beta/services/resourcemanager/data_source_google_folder.go +++ b/google-beta/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-beta/services/resourcemanager/data_source_google_folder_organization_policy_test.go b/google-beta/services/resourcemanager/data_source_google_folder_organization_policy_test.go index 12397ca8ce..88a58c73e6 100644 --- a/google-beta/services/resourcemanager/data_source_google_folder_organization_policy_test.go +++ b/google-beta/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-beta/services/resourcemanager/data_source_google_folder_test.go b/google-beta/services/resourcemanager/data_source_google_folder_test.go index 192c745f1d..e5bbfe8b8e 100644 --- a/google-beta/services/resourcemanager/data_source_google_folder_test.go +++ b/google-beta/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-beta/services/resourcemanager/data_source_google_folders_test.go b/google-beta/services/resourcemanager/data_source_google_folders_test.go index 3b8cf44db4..32743bfe74 100644 --- a/google-beta/services/resourcemanager/data_source_google_folders_test.go +++ b/google-beta/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-beta/services/resourcemanager/data_source_google_project_service_test.go b/google-beta/services/resourcemanager/data_source_google_project_service_test.go index 925cf2b10f..fc40157222 100644 --- a/google-beta/services/resourcemanager/data_source_google_project_service_test.go +++ b/google-beta/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-beta/services/resourcemanager/data_source_google_project_test.go b/google-beta/services/resourcemanager/data_source_google_project_test.go index 340021d30c..39e231cae3 100644 --- a/google-beta/services/resourcemanager/data_source_google_project_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder.go b/google-beta/services/resourcemanager/resource_google_folder.go index 54e41c532d..3a5d11785e 100644 --- a/google-beta/services/resourcemanager/resource_google_folder.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder_iam_audit_config_test.go b/google-beta/services/resourcemanager/resource_google_folder_iam_audit_config_test.go index d42a0fbb59..33ddf82010 100644 --- a/google-beta/services/resourcemanager/resource_google_folder_iam_audit_config_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder_iam_binding_test.go b/google-beta/services/resourcemanager/resource_google_folder_iam_binding_test.go index a373efdf54..e031f7ab3e 100644 --- a/google-beta/services/resourcemanager/resource_google_folder_iam_binding_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder_iam_member_test.go b/google-beta/services/resourcemanager/resource_google_folder_iam_member_test.go index c676691a11..e413c9b133 100644 --- a/google-beta/services/resourcemanager/resource_google_folder_iam_member_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder_iam_policy_test.go b/google-beta/services/resourcemanager/resource_google_folder_iam_policy_test.go index 986fc1192c..619bfd1280 100644 --- a/google-beta/services/resourcemanager/resource_google_folder_iam_policy_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder_organization_policy_test.go b/google-beta/services/resourcemanager/resource_google_folder_organization_policy_test.go index 965abb0e0e..c2f9ae08be 100644 --- a/google-beta/services/resourcemanager/resource_google_folder_organization_policy_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_folder_test.go b/google-beta/services/resourcemanager/resource_google_folder_test.go index e7e7f15d77..b4c9eb3dac 100644 --- a/google-beta/services/resourcemanager/resource_google_folder_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project.go b/google-beta/services/resourcemanager/resource_google_project.go index 559f84d5c8..ee3a92b8f3 100644 --- a/google-beta/services/resourcemanager/resource_google_project.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_default_service_accounts_test.go b/google-beta/services/resourcemanager/resource_google_project_default_service_accounts_test.go index 389ab055e9..5eb484c36d 100644 --- a/google-beta/services/resourcemanager/resource_google_project_default_service_accounts_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_iam_audit_config_test.go b/google-beta/services/resourcemanager/resource_google_project_iam_audit_config_test.go index 3d37691be4..155f7585ac 100644 --- a/google-beta/services/resourcemanager/resource_google_project_iam_audit_config_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_iam_binding_test.go b/google-beta/services/resourcemanager/resource_google_project_iam_binding_test.go index ea12cc2891..eca9dcee11 100644 --- a/google-beta/services/resourcemanager/resource_google_project_iam_binding_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_iam_member_remove_test.go b/google-beta/services/resourcemanager/resource_google_project_iam_member_remove_test.go index bcca8b68cb..a6b5de9d9d 100644 --- a/google-beta/services/resourcemanager/resource_google_project_iam_member_remove_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_iam_member_test.go b/google-beta/services/resourcemanager/resource_google_project_iam_member_test.go index 18d626a565..ff0ccda8b1 100644 --- a/google-beta/services/resourcemanager/resource_google_project_iam_member_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_iam_policy_test.go b/google-beta/services/resourcemanager/resource_google_project_iam_policy_test.go index 5c25f8c129..2fbc67ba77 100644 --- a/google-beta/services/resourcemanager/resource_google_project_iam_policy_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_google_project_service_test.go b/google-beta/services/resourcemanager/resource_google_project_service_test.go index 114a10f9bc..b73bc41b4e 100644 --- a/google-beta/services/resourcemanager/resource_google_project_service_test.go +++ b/google-beta/services/resourcemanager/resource_google_project_service_test.go @@ -232,6 +232,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -253,6 +254,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -275,6 +277,7 @@ resource "google_project" "acceptance" { name = "%s" org_id = "%s" billing_account = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -290,6 +293,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -312,6 +316,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 @@ -342,6 +347,7 @@ resource "google_project" "acceptance" { project_id = "%s" name = "%s" org_id = "%s" + deletion_policy = "DELETE" } resource "google_project_service" "test" { @@ -360,6 +366,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-beta/services/resourcemanager/resource_google_project_test.go b/google-beta/services/resourcemanager/resource_google_project_test.go index 2070125147..1ae141d904 100644 --- a/google-beta/services/resourcemanager/resource_google_project_test.go +++ b/google-beta/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-beta/services/resourcemanager/resource_resourcemanager_lien_test.go b/google-beta/services/resourcemanager/resource_resourcemanager_lien_test.go index 674415185d..f8deae2724 100644 --- a/google-beta/services/resourcemanager/resource_resourcemanager_lien_test.go +++ b/google-beta/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-beta/services/secretmanager/data_source_secret_manager_secrets_test.go b/google-beta/services/secretmanager/data_source_secret_manager_secrets_test.go index a17f259c1c..76df596326 100644 --- a/google-beta/services/secretmanager/data_source_secret_manager_secrets_test.go +++ b/google-beta/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-beta/services/securitycenter/resource_scc_folder_custom_module_test.go b/google-beta/services/securitycenter/resource_scc_folder_custom_module_test.go index dfdf15d5d9..ebf947fcc2 100644 --- a/google-beta/services/securitycenter/resource_scc_folder_custom_module_test.go +++ b/google-beta/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-beta/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go b/google-beta/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go index e2b4aceca4..23479f09f0 100644 --- a/google-beta/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go +++ b/google-beta/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-beta/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go b/google-beta/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go index 508a790daf..4b625e0608 100644 --- a/google-beta/services/securitycenterv2/resource_scc_v2_folder_mute_config_test.go +++ b/google-beta/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-beta/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go b/google-beta/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go index b40d5967aa..ebff6daa53 100644 --- a/google-beta/services/servicenetworking/data_source_google_service_networking_peered_dns_domain_test.go +++ b/google-beta/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-beta/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go b/google-beta/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go index 6005a3b2fe..3733dd417d 100644 --- a/google-beta/services/servicenetworking/resource_google_service_networking_peered_dns_domain_test.go +++ b/google-beta/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-beta/services/servicenetworking/resource_service_networking_connection_test.go b/google-beta/services/servicenetworking/resource_service_networking_connection_test.go index 97cb0b8e5a..e42a1fffa3 100644 --- a/google-beta/services/servicenetworking/resource_service_networking_connection_test.go +++ b/google-beta/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-beta/services/serviceusage/resource_service_usage_consumer_quota_override_generated_test.go b/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_generated_test.go index cbf679aea9..c078740d47 100644 --- a/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_generated_test.go +++ b/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_generated_test.go @@ -64,6 +64,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { @@ -111,6 +112,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { @@ -158,6 +160,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { @@ -208,6 +211,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { diff --git a/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_test.go b/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_test.go index cce9074c70..8e19100efd 100644 --- a/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_test.go +++ b/google-beta/services/serviceusage/resource_service_usage_consumer_quota_override_test.go @@ -40,6 +40,7 @@ resource "google_project" "my_project" { name = "tf-test-project" project_id = "quota%{random_suffix}" org_id = "%{org_id}" + deletion_policy = "DELETE" } resource "google_service_usage_consumer_quota_override" "override" { diff --git a/google-beta/services/sql/resource_sql_database_instance.go b/google-beta/services/sql/resource_sql_database_instance.go index f3d7f548ec..8a9552f921 100644 --- a/google-beta/services/sql/resource_sql_database_instance.go +++ b/google-beta/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-beta/services/sql/resource_sql_database_instance_test.go b/google-beta/services/sql/resource_sql_database_instance_test.go index 7a7fdf69c6..5fc90d563c 100644 --- a/google-beta/services/sql/resource_sql_database_instance_test.go +++ b/google-beta/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-beta/services/storage/data_source_google_storage_buckets_test.go b/google-beta/services/storage/data_source_google_storage_buckets_test.go index 32f455036d..86f518d2e1 100644 --- a/google-beta/services/storage/data_source_google_storage_buckets_test.go +++ b/google-beta/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-beta/services/storage/resource_storage_bucket.go b/google-beta/services/storage/resource_storage_bucket.go index c32bc97c0b..e4be7399d3 100644 --- a/google-beta/services/storage/resource_storage_bucket.go +++ b/google-beta/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-beta/services/storage/resource_storage_bucket_600_migration.go b/google-beta/services/storage/resource_storage_bucket_600_migration.go index 3c4662c735..6350b05dfa 100644 --- a/google-beta/services/storage/resource_storage_bucket_600_migration.go +++ b/google-beta/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-beta/services/storage/resource_storage_bucket_test.go b/google-beta/services/storage/resource_storage_bucket_test.go index 21129ae971..7f6d949c2d 100644 --- a/google-beta/services/storage/resource_storage_bucket_test.go +++ b/google-beta/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-beta/services/tags/resource_tags_test.go b/google-beta/services/tags/resource_tags_test.go index 72bc983673..f4f3409415 100644 --- a/google-beta/services/tags/resource_tags_test.go +++ b/google-beta/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-beta/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go b/google-beta/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go index 9ac556f35d..c331d14471 100644 --- a/google-beta/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_test.go +++ b/google-beta/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" { @@ -428,6 +429,7 @@ resource "google_vertex_ai_feature_online_store_featureview" "cross_project_feat } func TestAccVertexAIFeatureOnlineStoreFeatureview_vertexAiFeatureonlinestoreFeatureviewWithVectorSearchExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/google-beta/services/vertexai/resource_vertex_ai_feature_online_store_generated_test.go b/google-beta/services/vertexai/resource_vertex_ai_feature_online_store_generated_test.go index 25571805f9..24d78b430e 100644 --- a/google-beta/services/vertexai/resource_vertex_ai_feature_online_store_generated_test.go +++ b/google-beta/services/vertexai/resource_vertex_ai_feature_online_store_generated_test.go @@ -124,6 +124,7 @@ data "google_project" "project" { } func TestAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBetaFieldsBigtableExample(t *testing.T) { + acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ diff --git a/google-beta/services/vertexai/resource_vertex_ai_index_endpoint_test.go b/google-beta/services/vertexai/resource_vertex_ai_index_endpoint_test.go index 628dedfcd5..4f7b8022fe 100644 --- a/google-beta/services/vertexai/resource_vertex_ai_index_endpoint_test.go +++ b/google-beta/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-beta/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go b/google-beta/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go index b3d7319775..4b30fadb1a 100644 --- a/google-beta/services/vmwareengine/data_source_google_vmwareengine_network_peering_test.go +++ b/google-beta/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-beta/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go b/google-beta/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go index af9081964d..2fd945e7ba 100644 --- a/google-beta/services/vmwareengine/data_source_google_vmwareengine_network_policy_test.go +++ b/google-beta/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-beta/services/vmwareengine/data_source_google_vmwareengine_network_test.go b/google-beta/services/vmwareengine/data_source_google_vmwareengine_network_test.go index 75b1401ab9..c4af7c2e65 100644 --- a/google-beta/services/vmwareengine/data_source_google_vmwareengine_network_test.go +++ b/google-beta/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-beta/services/vmwareengine/resource_vmwareengine_network_test.go b/google-beta/services/vmwareengine/resource_vmwareengine_network_test.go index 4d4f28a234..d06e28a160 100644 --- a/google-beta/services/vmwareengine/resource_vmwareengine_network_test.go +++ b/google-beta/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-beta/services/vpcaccess/data_source_vpc_access_connector_test.go b/google-beta/services/vpcaccess/data_source_vpc_access_connector_test.go index c3800d15b6..847a5154be 100644 --- a/google-beta/services/vpcaccess/data_source_vpc_access_connector_test.go +++ b/google-beta/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-beta/services/vpcaccess/resource_vpc_access_connector.go b/google-beta/services/vpcaccess/resource_vpc_access_connector.go index f5996898cb..6974ddde15 100644 --- a/google-beta/services/vpcaccess/resource_vpc_access_connector.go +++ b/google-beta/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-beta/services/vpcaccess/resource_vpc_access_connector_generated_test.go b/google-beta/services/vpcaccess/resource_vpc_access_connector_generated_test.go index 5dd706b35a..28463aaab0 100644 --- a/google-beta/services/vpcaccess/resource_vpc_access_connector_generated_test.go +++ b/google-beta/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-beta/services/vpcaccess/resource_vpc_access_connector_test.go b/google-beta/services/vpcaccess/resource_vpc_access_connector_test.go index 58ff548d85..481d87fe97 100644 --- a/google-beta/services/vpcaccess/resource_vpc_access_connector_test.go +++ b/google-beta/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-beta/services/workflows/resource_workflows_workflow.go b/google-beta/services/workflows/resource_workflows_workflow.go index c3c97aaaf3..dabee3934c 100644 --- a/google-beta/services/workflows/resource_workflows_workflow.go +++ b/google-beta/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-beta/services/workstations/resource_workstations_workstation_config.go b/google-beta/services/workstations/resource_workstations_workstation_config.go index a11182d354..4e4036ff94 100644 --- a/google-beta/services/workstations/resource_workstations_workstation_config.go +++ b/google-beta/services/workstations/resource_workstations_workstation_config.go @@ -355,6 +355,7 @@ See https://cloud.google.com/workstations/docs/reference/rest/v1beta/projects.lo Type: schema.TypeBool, Optional: true, Description: `Whether to disable SSH access to the VM.`, + Default: true, }, "enable_nested_virtualization": { Type: schema.TypeBool, @@ -2008,7 +2009,7 @@ func expandWorkstationsWorkstationConfigHostGceInstance(v interface{}, d tpgreso transformedDisableSsh, err := expandWorkstationsWorkstationConfigHostGceInstanceDisableSsh(original["disable_ssh"], d, config) if err != nil { return nil, err - } else if val := reflect.ValueOf(transformedDisableSsh); val.IsValid() && !tpgresource.IsEmptyValue(val) { + } else { transformed["disableSsh"] = transformedDisableSsh } diff --git a/google-beta/sweeper/gcp_sweeper_test.go b/google-beta/sweeper/gcp_sweeper_test.go index 508240d38d..929f84190e 100644 --- a/google-beta/sweeper/gcp_sweeper_test.go +++ b/google-beta/sweeper/gcp_sweeper_test.go @@ -58,7 +58,6 @@ import ( _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dataplex" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dataproc" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dataprocmetastore" - _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/datastore" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/datastream" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/deploymentmanager" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dialogflow" diff --git a/google-beta/tpgresource/labels.go b/google-beta/tpgresource/labels.go index 969c134946..ffb1515cf1 100644 --- a/google-beta/tpgresource/labels.go +++ b/google-beta/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-beta/tpgresource/utils.go b/google-beta/tpgresource/utils.go index 6b7e8d32b1..efb8b30a29 100644 --- a/google-beta/tpgresource/utils.go +++ b/google-beta/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-beta/transport/config.go b/google-beta/transport/config.go index a41d3def96..2c93a76fb0 100644 --- a/google-beta/transport/config.go +++ b/google-beta/transport/config.go @@ -239,7 +239,6 @@ type Config struct { DataplexBasePath string DataprocBasePath string DataprocMetastoreBasePath string - DatastoreBasePath string DatastreamBasePath string DeploymentManagerBasePath string DialogflowBasePath string @@ -394,7 +393,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" @@ -543,7 +541,6 @@ var DefaultBasePaths = map[string]string{ DataplexBasePathKey: "https://dataplex.googleapis.com/v1/", DataprocBasePathKey: "https://dataproc.googleapis.com/v1beta2/", DataprocMetastoreBasePathKey: "https://metastore.googleapis.com/v1beta/", - 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/", @@ -967,11 +964,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", @@ -2356,7 +2348,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 b107af9a6a..a44818a7a1 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 8b03ef4350..9adb671d0a 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 d056ec29af..8b9dfcbcdb 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 bb457d7ef2..962ce0c627 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 c7fcdfe20f..c5a22c4aec 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 dbbcdf5d0c..6c17ed2b25 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 7154372a6f..1dff7f730e 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 718a4d8e28..e1a3a0d3cd 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 8c75317527..11c0fde863 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 b4397ef47b..8a25afffe3 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 75dd392a9f..3e9cb6f45f 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 28ddf33f1c..43ec313c29 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 e5c209d838..270dde67ec 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 9b259d189a..4f822f0b5b 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 0f65d47375..de712558da 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 21d1282f5e..6ef6daf7dd 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 2fba359b06..9802626ff5 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 31e6189d97..ab54b615de 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 0a30a4f840..7ea672c986 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 0f1a83d6a7..cbb29da072 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 601f45e812..3351c66f3d 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 89af961cbf..7fd2349459 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 45202b4ac1..707197f5a4 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 7f27cb88ae..51be2f2862 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 42e3fe6040..8ad16dc5dd 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 4ddc326b92..d891048e3a 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 17585c4af0..696a907a2a 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 75b0aa0ed5..ba83b035d7 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 36f3392a99..cd97bf4405 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 c7628c8703..51b2642553 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 615d6e1a59..8245e507ff 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 53085d3b0b..9ea19105d3 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 b2c358e9c4..d4c50e4c09 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 1e977a5770..92155f9b5d 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 de576b40df..365f29f602 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 74384427c1..c7ebb9e0c3 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 6521056888..02ae5444d5 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 db3205a65e..e96d17f09c 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 c9c8552ace..bbf5735739 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 0554f7aa15..b11194f599 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 61adbb20bc..0000000000 --- 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 eb35acb0d0..4032041b1a 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 bfdefd7d3e..cb3bc840b6 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 938d66e3d2..934099fb15 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 92940b026e..94f7ac8a27 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 35d8183b27..e39cadaa8d 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 0107275d36..5907d4efdd 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 0c434dc17b..ee2473892c 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 5c250395a3..49c66a920e 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 53f0bbcb81..45962194c6 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 fff53a4a88..6d45074bb2 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 552ed7e440..e9f8797de8 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 db7b821ccb..b0a28ff6ef 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 09a9588468..8d1438ebb3 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 f2fa91014a..96ac112707 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 4c7310ce82..910f078afe 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 552ddf3a93..0000000000 --- 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 b318891e9a..14a8df7df4 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 1a40f672df..fcb6c18aa5 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 b23422f38d..5de4ee21c3 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 a5b9d2ce2e..3291ebadd2 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 691a12aae7..10c276c108 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 bc34d1b03e..55a6eeb87b 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 fc2e134728..d96a57c1f0 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 48bec6a4bf..6a02183a24 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 16659ff534..34567a89b6 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 de13dd0ac9..983bc96a93 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 0bed3d390f..f4d9ff81a9 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 1c82387748..eafc9d2123 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 7ff5ee2717..2a26be005c 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 220bfc44f3..e1248314c4 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 8304aba71f..db1b5e7e8a 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 4823380f29..ba74765a05 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 1e29fda7f4..86759b0210 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 0404a63fad..5fc5f5cd9b 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 99b8055b41..461de7958f 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" {