From 13bb0dd36b9eba17f2eaee475927f915efe40da3 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 4 Aug 2020 13:58:49 -0700 Subject: [PATCH] Org Security Policies (Hierarchical Firewalls) (#3626) (#2333) Co-authored-by: Dana Hoffman Signed-off-by: Modular Magician Co-authored-by: Dana Hoffman --- .changelog/3626.txt | 9 + google-beta/compute_operation.go | 44 +- google-beta/deployment_manager_operation.go | 8 +- google-beta/provider.go | 7 +- ...rce_access_context_manager_access_level.go | 2 + ...ce_access_context_manager_access_policy.go | 2 + ...ccess_context_manager_service_perimeter.go | 2 + .../resource_active_directory_domain.go | 2 + ...p_engine_application_url_dispatch_rules.go | 2 + .../resource_app_engine_domain_mapping.go | 2 + .../resource_app_engine_firewall_rule.go | 4 +- ...esource_app_engine_flexible_app_version.go | 2 + ...source_app_engine_service_split_traffic.go | 2 + ...esource_app_engine_standard_app_version.go | 2 + .../resource_artifact_registry_repository.go | 2 + google-beta/resource_big_query_dataset.go | 4 +- ...resource_bigquery_connection_connection.go | 4 +- .../resource_bigquery_data_transfer_config.go | 4 +- ...source_bigquery_reservation_reservation.go | 4 +- google-beta/resource_bigtable_app_profile.go | 4 +- google-beta/resource_billing_budget.go | 4 +- .../resource_binary_authorization_attestor.go | 4 +- .../resource_binary_authorization_policy.go | 4 +- .../resource_cloud_asset_folder_feed.go | 4 +- .../resource_cloud_asset_organization_feed.go | 4 +- .../resource_cloud_asset_project_feed.go | 4 +- google-beta/resource_cloud_build_trigger.go | 4 +- google-beta/resource_cloud_identity_group.go | 4 +- ...esource_cloud_identity_group_membership.go | 4 +- google-beta/resource_cloud_iot_device.go | 4 +- .../resource_cloud_iot_device_registry.go | 4 +- google-beta/resource_cloud_run_service.go | 4 +- google-beta/resource_cloud_tasks_queue.go | 4 +- google-beta/resource_compute_address.go | 2 + google-beta/resource_compute_autoscaler.go | 2 + .../resource_compute_backend_bucket.go | 2 + .../resource_compute_backend_service.go | 2 + google-beta/resource_compute_disk.go | 4 + google-beta/resource_compute_firewall.go | 2 + .../resource_compute_forwarding_rule.go | 6 + .../resource_compute_global_address.go | 2 + ...resource_compute_global_forwarding_rule.go | 4 + google-beta/resource_compute_health_check.go | 2 + .../resource_compute_http_health_check.go | 2 + .../resource_compute_https_health_check.go | 2 + google-beta/resource_compute_image.go | 2 + ...esource_compute_interconnect_attachment.go | 2 + google-beta/resource_compute_machine_image.go | 4 +- google-beta/resource_compute_network.go | 2 + ...e_compute_network_peering_routes_config.go | 2 + google-beta/resource_compute_node_group.go | 2 + ...ce_compute_organization_security_policy.go | 342 ++++++++ ...rganization_security_policy_association.go | 242 ++++++ ...urity_policy_association_generated_test.go | 103 +++ ...nization_security_policy_generated_test.go | 72 ++ ...mpute_organization_security_policy_rule.go | 795 ++++++++++++++++++ ...ion_security_policy_rule_generated_test.go | 95 +++ ..._organization_security_policy_rule_test.go | 100 +++ ...mpute_organization_security_policy_test.go | 59 ++ .../resource_compute_packet_mirroring.go | 2 + .../resource_compute_per_instance_config.go | 2 + .../resource_compute_region_autoscaler.go | 2 + ...resource_compute_region_backend_service.go | 2 + google-beta/resource_compute_region_disk.go | 4 + .../resource_compute_region_health_check.go | 2 + ...urce_compute_region_per_instance_config.go | 2 + ...source_compute_region_target_http_proxy.go | 2 + ...ource_compute_region_target_https_proxy.go | 4 + .../resource_compute_region_url_map.go | 2 + google-beta/resource_compute_reservation.go | 2 + google-beta/resource_compute_router.go | 2 + .../resource_compute_router_bgp_peer.go | 2 + google-beta/resource_compute_router_nat.go | 2 + google-beta/resource_compute_snapshot.go | 2 + google-beta/resource_compute_ssl_policy.go | 2 + google-beta/resource_compute_subnetwork.go | 10 + .../resource_compute_target_http_proxy.go | 2 + .../resource_compute_target_https_proxy.go | 8 + .../resource_compute_target_ssl_proxy.go | 8 + .../resource_compute_target_tcp_proxy.go | 4 + google-beta/resource_compute_url_map.go | 2 + google-beta/resource_compute_vpn_tunnel.go | 2 + .../resource_container_analysis_note.go | 4 +- .../resource_container_analysis_occurrence.go | 4 +- google-beta/resource_data_catalog_entry.go | 4 +- .../resource_data_catalog_entry_group.go | 4 +- google-beta/resource_data_catalog_tag.go | 4 +- .../resource_data_catalog_tag_template.go | 4 +- google-beta/resource_data_fusion_instance.go | 2 + .../resource_dataproc_autoscaling_policy.go | 4 +- .../resource_deployment_manager_deployment.go | 4 + google-beta/resource_dialogflow_agent.go | 4 +- .../resource_dialogflow_entity_type.go | 4 +- google-beta/resource_dialogflow_intent.go | 4 +- google-beta/resource_dns_managed_zone.go | 4 +- google-beta/resource_dns_policy.go | 4 +- google-beta/resource_filestore_instance.go | 2 + google-beta/resource_firebase_web_app.go | 4 +- ...ource_game_services_game_server_cluster.go | 2 + ...ce_game_services_game_server_deployment.go | 2 + ...services_game_server_deployment_rollout.go | 2 + google-beta/resource_game_services_realm.go | 2 + google-beta/resource_healthcare_dataset.go | 4 +- .../resource_healthcare_dicom_store.go | 4 +- google-beta/resource_healthcare_fhir_store.go | 4 +- .../resource_healthcare_hl7_v2_store.go | 4 +- ...y_platform_default_supported_idp_config.go | 4 +- ...e_identity_platform_inbound_saml_config.go | 4 +- ...urce_identity_platform_oauth_idp_config.go | 4 +- .../resource_identity_platform_tenant.go | 4 +- ...orm_tenant_default_supported_idp_config.go | 4 +- ...ity_platform_tenant_inbound_saml_config.go | 4 +- ...entity_platform_tenant_oauth_idp_config.go | 4 +- google-beta/resource_kms_crypto_key.go | 4 +- google-beta/resource_logging_metric.go | 4 +- google-beta/resource_memcache_instance.go | 2 + .../resource_monitoring_alert_policy.go | 4 +- google-beta/resource_monitoring_group.go | 4 +- .../resource_monitoring_metric_descriptor.go | 4 +- ...esource_monitoring_notification_channel.go | 4 +- google-beta/resource_monitoring_service.go | 4 +- google-beta/resource_monitoring_slo.go | 4 +- ...resource_monitoring_uptime_check_config.go | 4 +- ...k_management_connectivity_test_resource.go | 2 + google-beta/resource_notebooks_environment.go | 2 + google-beta/resource_notebooks_instance.go | 2 + google-beta/resource_notebooks_location.go | 2 + .../resource_os_config_guest_policies.go | 4 +- .../resource_os_login_ssh_public_key.go | 4 +- google-beta/resource_pubsub_subscription.go | 4 +- google-beta/resource_pubsub_topic.go | 4 +- google-beta/resource_redis_instance.go | 2 + google-beta/resource_secret_manager_secret.go | 4 +- .../resource_security_center_source.go | 4 +- .../resource_security_scanner_scan_config.go | 4 +- .../resource_service_directory_endpoint.go | 4 +- .../resource_service_directory_namespace.go | 4 +- .../resource_service_directory_service.go | 4 +- ...e_service_usage_consumer_quota_override.go | 2 + .../resource_source_repo_repository.go | 4 +- google-beta/resource_spanner_instance.go | 2 + google-beta/resource_sql_database.go | 2 + .../resource_storage_bucket_access_control.go | 4 +- ...e_storage_default_object_access_control.go | 4 +- google-beta/resource_storage_hmac_key.go | 4 +- .../resource_storage_object_access_control.go | 4 +- google-beta/resource_tpu_node.go | 2 + ...organization_security_policy.html.markdown | 117 +++ ..._security_policy_association.html.markdown | 134 +++ ...ization_security_policy_rule.html.markdown | 219 +++++ website/google.erb | 12 + 151 files changed, 2719 insertions(+), 81 deletions(-) create mode 100644 .changelog/3626.txt create mode 100644 google-beta/resource_compute_organization_security_policy.go create mode 100644 google-beta/resource_compute_organization_security_policy_association.go create mode 100644 google-beta/resource_compute_organization_security_policy_association_generated_test.go create mode 100644 google-beta/resource_compute_organization_security_policy_generated_test.go create mode 100644 google-beta/resource_compute_organization_security_policy_rule.go create mode 100644 google-beta/resource_compute_organization_security_policy_rule_generated_test.go create mode 100644 google-beta/resource_compute_organization_security_policy_rule_test.go create mode 100644 google-beta/resource_compute_organization_security_policy_test.go create mode 100644 website/docs/r/compute_organization_security_policy.html.markdown create mode 100644 website/docs/r/compute_organization_security_policy_association.html.markdown create mode 100644 website/docs/r/compute_organization_security_policy_rule.html.markdown diff --git a/.changelog/3626.txt b/.changelog/3626.txt new file mode 100644 index 0000000000..4dfcf6a834 --- /dev/null +++ b/.changelog/3626.txt @@ -0,0 +1,9 @@ +```release-note:new-resource +`google_compute_compute_organization_security_policy` (beta-only) +``` +```release-note:new-resource +`google_compute_compute_organization_security_policy_association` (beta-only) +``` +```release-note:new-resource +`google_compute_compute_organization_security_policy_rule` (beta-only) +``` diff --git a/google-beta/compute_operation.go b/google-beta/compute_operation.go index 78544c473c..38a2a6bd87 100644 --- a/google-beta/compute_operation.go +++ b/google-beta/compute_operation.go @@ -2,16 +2,18 @@ package google import ( "bytes" + "encoding/json" "fmt" "time" - "google.golang.org/api/compute/v1" + computeBeta "google.golang.org/api/compute/v0.beta" ) type ComputeOperationWaiter struct { - Service *compute.Service - Op *compute.Operation + Service *computeBeta.Service + Op *computeBeta.Operation Project string + Parent string } func (w *ComputeOperationWaiter) State() string { @@ -42,7 +44,7 @@ func (w *ComputeOperationWaiter) IsRetryable(err error) bool { func (w *ComputeOperationWaiter) SetOp(op interface{}) error { var ok bool - w.Op, ok = op.(*compute.Operation) + w.Op, ok = op.(*computeBeta.Operation) if !ok { return fmt.Errorf("Unable to set operation. Bad type!") } @@ -59,6 +61,8 @@ func (w *ComputeOperationWaiter) QueryOp() (interface{}, error) { } else if w.Op.Region != "" { region := GetResourceNameFromSelfLink(w.Op.Region) return w.Service.RegionOperations.Get(w.Project, region, w.Op.Name).Do() + } else if w.Parent != "" { + return w.Service.GlobalOrganizationOperations.Get(w.Op.Name).ParentId(w.Parent).Do() } return w.Service.GlobalOperations.Get(w.Project, w.Op.Name).Do() } @@ -80,14 +84,14 @@ func (w *ComputeOperationWaiter) TargetStates() []string { } func computeOperationWaitTime(config *Config, res interface{}, project, activity string, timeout time.Duration) error { - op := &compute.Operation{} + op := &computeBeta.Operation{} err := Convert(res, op) if err != nil { return err } w := &ComputeOperationWaiter{ - Service: config.clientCompute, + Service: config.clientComputeBeta, Op: op, Project: project, } @@ -98,9 +102,35 @@ func computeOperationWaitTime(config *Config, res interface{}, project, activity return OperationWait(w, activity, timeout, config.PollInterval) } +func computeOrgOperationWaitTimeWithResponse(config *Config, res interface{}, response *map[string]interface{}, parent, activity string, timeout time.Duration) error { + op := &computeBeta.Operation{} + err := Convert(res, op) + if err != nil { + return err + } + + w := &ComputeOperationWaiter{ + Service: config.clientComputeBeta, + Op: op, + Parent: parent, + } + + if err := w.SetOp(op); err != nil { + return err + } + if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil { + return err + } + e, err := json.Marshal(w.Op) + if err != nil { + return err + } + return json.Unmarshal(e, response) +} + // ComputeOperationError wraps compute.OperationError and implements the // error interface so it can be returned. -type ComputeOperationError compute.OperationError +type ComputeOperationError computeBeta.OperationError func (e ComputeOperationError) Error() string { var buf bytes.Buffer diff --git a/google-beta/deployment_manager_operation.go b/google-beta/deployment_manager_operation.go index 721f0d0096..7ba139d04c 100644 --- a/google-beta/deployment_manager_operation.go +++ b/google-beta/deployment_manager_operation.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "google.golang.org/api/compute/v1" + computeBeta "google.golang.org/api/compute/v0.beta" ) type DeploymentManagerOperationWaiter struct { @@ -27,7 +27,7 @@ func (w *DeploymentManagerOperationWaiter) QueryOp() (interface{}, error) { if err != nil { return nil, err } - op := &compute.Operation{} + op := &computeBeta.Operation{} if err := Convert(resp, op); err != nil { return nil, fmt.Errorf("could not convert response to operation: %v", err) } @@ -35,7 +35,7 @@ func (w *DeploymentManagerOperationWaiter) QueryOp() (interface{}, error) { } func deploymentManagerOperationWaitTime(config *Config, resp interface{}, project, activity string, timeout time.Duration) error { - op := &compute.Operation{} + op := &computeBeta.Operation{} err := Convert(resp, op) if err != nil { return err @@ -71,7 +71,7 @@ func (w *DeploymentManagerOperationWaiter) Error() error { type DeploymentManagerOperationError struct { HTTPStatusCode int64 HTTPMessage string - compute.OperationError + computeBeta.OperationError } func (e DeploymentManagerOperationError) Error() string { diff --git a/google-beta/provider.go b/google-beta/provider.go index 9e7baf96e7..75b54f7eca 100644 --- a/google-beta/provider.go +++ b/google-beta/provider.go @@ -700,9 +700,9 @@ func Provider() terraform.ResourceProvider { return provider } -// Generated resources: 176 +// Generated resources: 179 // Generated IAM resources: 66 -// Total generated resources: 242 +// Total generated resources: 245 func ResourceMap() map[string]*schema.Resource { resourceMap, _ := ResourceMapWithErrors() return resourceMap @@ -789,6 +789,9 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) { "google_compute_node_group": resourceComputeNodeGroup(), "google_compute_network_peering_routes_config": resourceComputeNetworkPeeringRoutesConfig(), "google_compute_node_template": resourceComputeNodeTemplate(), + "google_compute_organization_security_policy": resourceComputeOrganizationSecurityPolicy(), + "google_compute_organization_security_policy_association": resourceComputeOrganizationSecurityPolicyAssociation(), + "google_compute_organization_security_policy_rule": resourceComputeOrganizationSecurityPolicyRule(), "google_compute_packet_mirroring": resourceComputePacketMirroring(), "google_compute_per_instance_config": resourceComputePerInstanceConfig(), "google_compute_region_per_instance_config": resourceComputeRegionPerInstanceConfig(), diff --git a/google-beta/resource_access_context_manager_access_level.go b/google-beta/resource_access_context_manager_access_level.go index 6fabeff895..697cf8fdb2 100644 --- a/google-beta/resource_access_context_manager_access_level.go +++ b/google-beta/resource_access_context_manager_access_level.go @@ -469,6 +469,8 @@ func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta if err != nil { return fmt.Errorf("Error updating AccessLevel %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating AccessLevel %q: %#v", d.Id(), res) } err = accessContextManagerOperationWaitTime( diff --git a/google-beta/resource_access_context_manager_access_policy.go b/google-beta/resource_access_context_manager_access_policy.go index a5ba9e150d..18bdb9610e 100644 --- a/google-beta/resource_access_context_manager_access_policy.go +++ b/google-beta/resource_access_context_manager_access_policy.go @@ -210,6 +210,8 @@ func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta if err != nil { return fmt.Errorf("Error updating AccessPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating AccessPolicy %q: %#v", d.Id(), res) } err = accessContextManagerOperationWaitTime( diff --git a/google-beta/resource_access_context_manager_service_perimeter.go b/google-beta/resource_access_context_manager_service_perimeter.go index 87f9053b25..96b6743fea 100644 --- a/google-beta/resource_access_context_manager_service_perimeter.go +++ b/google-beta/resource_access_context_manager_service_perimeter.go @@ -521,6 +521,8 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, if err != nil { return fmt.Errorf("Error updating ServicePerimeter %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ServicePerimeter %q: %#v", d.Id(), res) } err = accessContextManagerOperationWaitTime( diff --git a/google-beta/resource_active_directory_domain.go b/google-beta/resource_active_directory_domain.go index ded7de8e10..7e9a6c34d0 100644 --- a/google-beta/resource_active_directory_domain.go +++ b/google-beta/resource_active_directory_domain.go @@ -299,6 +299,8 @@ func resourceActiveDirectoryDomainUpdate(d *schema.ResourceData, meta interface{ if err != nil { return fmt.Errorf("Error updating Domain %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Domain %q: %#v", d.Id(), res) } err = activeDirectoryOperationWaitTime( diff --git a/google-beta/resource_app_engine_application_url_dispatch_rules.go b/google-beta/resource_app_engine_application_url_dispatch_rules.go index fc4456ddd4..3c90f9a4af 100644 --- a/google-beta/resource_app_engine_application_url_dispatch_rules.go +++ b/google-beta/resource_app_engine_application_url_dispatch_rules.go @@ -195,6 +195,8 @@ func resourceAppEngineApplicationUrlDispatchRulesUpdate(d *schema.ResourceData, if err != nil { return fmt.Errorf("Error updating ApplicationUrlDispatchRules %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ApplicationUrlDispatchRules %q: %#v", d.Id(), res) } err = appEngineOperationWaitTime( diff --git a/google-beta/resource_app_engine_domain_mapping.go b/google-beta/resource_app_engine_domain_mapping.go index 78d605c1ec..055ec64769 100644 --- a/google-beta/resource_app_engine_domain_mapping.go +++ b/google-beta/resource_app_engine_domain_mapping.go @@ -306,6 +306,8 @@ func resourceAppEngineDomainMappingUpdate(d *schema.ResourceData, meta interface if err != nil { return fmt.Errorf("Error updating DomainMapping %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating DomainMapping %q: %#v", d.Id(), res) } err = appEngineOperationWaitTime( diff --git a/google-beta/resource_app_engine_firewall_rule.go b/google-beta/resource_app_engine_firewall_rule.go index e90029b5f9..e41f14475c 100644 --- a/google-beta/resource_app_engine_firewall_rule.go +++ b/google-beta/resource_app_engine_firewall_rule.go @@ -276,10 +276,12 @@ func resourceAppEngineFirewallRuleUpdate(d *schema.ResourceData, meta interface{ if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating FirewallRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating FirewallRule %q: %#v", d.Id(), res) } return resourceAppEngineFirewallRuleRead(d, meta) diff --git a/google-beta/resource_app_engine_flexible_app_version.go b/google-beta/resource_app_engine_flexible_app_version.go index bc24550326..2cfe686e6d 100644 --- a/google-beta/resource_app_engine_flexible_app_version.go +++ b/google-beta/resource_app_engine_flexible_app_version.go @@ -1323,6 +1323,8 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte if err != nil { return fmt.Errorf("Error updating FlexibleAppVersion %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating FlexibleAppVersion %q: %#v", d.Id(), res) } err = appEngineOperationWaitTime( diff --git a/google-beta/resource_app_engine_service_split_traffic.go b/google-beta/resource_app_engine_service_split_traffic.go index eea7b07034..998826032d 100644 --- a/google-beta/resource_app_engine_service_split_traffic.go +++ b/google-beta/resource_app_engine_service_split_traffic.go @@ -228,6 +228,8 @@ func resourceAppEngineServiceSplitTrafficUpdate(d *schema.ResourceData, meta int if err != nil { return fmt.Errorf("Error updating ServiceSplitTraffic %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ServiceSplitTraffic %q: %#v", d.Id(), res) } err = appEngineOperationWaitTime( diff --git a/google-beta/resource_app_engine_standard_app_version.go b/google-beta/resource_app_engine_standard_app_version.go index 0fcb3503ea..cbc32aece6 100644 --- a/google-beta/resource_app_engine_standard_app_version.go +++ b/google-beta/resource_app_engine_standard_app_version.go @@ -739,6 +739,8 @@ func resourceAppEngineStandardAppVersionUpdate(d *schema.ResourceData, meta inte if err != nil { return fmt.Errorf("Error updating StandardAppVersion %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating StandardAppVersion %q: %#v", d.Id(), res) } err = appEngineOperationWaitTime( diff --git a/google-beta/resource_artifact_registry_repository.go b/google-beta/resource_artifact_registry_repository.go index 7171c37103..814af5ed8c 100644 --- a/google-beta/resource_artifact_registry_repository.go +++ b/google-beta/resource_artifact_registry_repository.go @@ -282,6 +282,8 @@ func resourceArtifactRegistryRepositoryUpdate(d *schema.ResourceData, meta inter if err != nil { return fmt.Errorf("Error updating Repository %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Repository %q: %#v", d.Id(), res) } err = artifactRegistryOperationWaitTime( diff --git a/google-beta/resource_big_query_dataset.go b/google-beta/resource_big_query_dataset.go index 36537f21a7..870ef74f61 100644 --- a/google-beta/resource_big_query_dataset.go +++ b/google-beta/resource_big_query_dataset.go @@ -538,10 +538,12 @@ func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Dataset %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Dataset %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Dataset %q: %#v", d.Id(), res) } return resourceBigQueryDatasetRead(d, meta) diff --git a/google-beta/resource_bigquery_connection_connection.go b/google-beta/resource_bigquery_connection_connection.go index c249b27d45..1930844d63 100644 --- a/google-beta/resource_bigquery_connection_connection.go +++ b/google-beta/resource_bigquery_connection_connection.go @@ -283,10 +283,12 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Connection %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Connection %q: %#v", d.Id(), res) } return resourceBigqueryConnectionConnectionRead(d, meta) diff --git a/google-beta/resource_bigquery_data_transfer_config.go b/google-beta/resource_bigquery_data_transfer_config.go index 53d973b8e9..df619a2210 100644 --- a/google-beta/resource_bigquery_data_transfer_config.go +++ b/google-beta/resource_bigquery_data_transfer_config.go @@ -342,10 +342,12 @@ func resourceBigqueryDataTransferConfigUpdate(d *schema.ResourceData, meta inter if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), iamMemberMissing) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), iamMemberMissing) if err != nil { return fmt.Errorf("Error updating Config %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Config %q: %#v", d.Id(), res) } return resourceBigqueryDataTransferConfigRead(d, meta) diff --git a/google-beta/resource_bigquery_reservation_reservation.go b/google-beta/resource_bigquery_reservation_reservation.go index 7d3384426a..ac71a6a64f 100644 --- a/google-beta/resource_bigquery_reservation_reservation.go +++ b/google-beta/resource_bigquery_reservation_reservation.go @@ -199,10 +199,12 @@ func resourceBigqueryReservationReservationUpdate(d *schema.ResourceData, meta i if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Reservation %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Reservation %q: %#v", d.Id(), res) } return resourceBigqueryReservationReservationRead(d, meta) diff --git a/google-beta/resource_bigtable_app_profile.go b/google-beta/resource_bigtable_app_profile.go index 0f2475abc2..4e534d27e5 100644 --- a/google-beta/resource_bigtable_app_profile.go +++ b/google-beta/resource_bigtable_app_profile.go @@ -247,10 +247,12 @@ func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating AppProfile %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating AppProfile %q: %#v", d.Id(), res) } return resourceBigtableAppProfileRead(d, meta) diff --git a/google-beta/resource_billing_budget.go b/google-beta/resource_billing_budget.go index e47fb52e63..690b2bf776 100644 --- a/google-beta/resource_billing_budget.go +++ b/google-beta/resource_billing_budget.go @@ -313,10 +313,12 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Budget %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Budget %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Budget %q: %#v", d.Id(), res) } return resourceBillingBudgetRead(d, meta) diff --git a/google-beta/resource_binary_authorization_attestor.go b/google-beta/resource_binary_authorization_attestor.go index 47967370b5..b36f338c65 100644 --- a/google-beta/resource_binary_authorization_attestor.go +++ b/google-beta/resource_binary_authorization_attestor.go @@ -292,10 +292,12 @@ func resourceBinaryAuthorizationAttestorUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating Attestor %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Attestor %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Attestor %q: %#v", d.Id(), res) } return resourceBinaryAuthorizationAttestorRead(d, meta) diff --git a/google-beta/resource_binary_authorization_policy.go b/google-beta/resource_binary_authorization_policy.go index 4cc3ff2a48..b751cb7551 100644 --- a/google-beta/resource_binary_authorization_policy.go +++ b/google-beta/resource_binary_authorization_policy.go @@ -367,10 +367,12 @@ func resourceBinaryAuthorizationPolicyUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating Policy %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Policy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Policy %q: %#v", d.Id(), res) } return resourceBinaryAuthorizationPolicyRead(d, meta) diff --git a/google-beta/resource_cloud_asset_folder_feed.go b/google-beta/resource_cloud_asset_folder_feed.go index 4d4204c9fc..f62f30e139 100644 --- a/google-beta/resource_cloud_asset_folder_feed.go +++ b/google-beta/resource_cloud_asset_folder_feed.go @@ -322,10 +322,12 @@ func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{} if parts := regexp.MustCompile(`projects\/([^\/]+)\/`).FindStringSubmatch(url); parts != nil { project = parts[1] } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating FolderFeed %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating FolderFeed %q: %#v", d.Id(), res) } return resourceCloudAssetFolderFeedRead(d, meta) diff --git a/google-beta/resource_cloud_asset_organization_feed.go b/google-beta/resource_cloud_asset_organization_feed.go index b80a75fb98..b529fef2b7 100644 --- a/google-beta/resource_cloud_asset_organization_feed.go +++ b/google-beta/resource_cloud_asset_organization_feed.go @@ -313,10 +313,12 @@ func resourceCloudAssetOrganizationFeedUpdate(d *schema.ResourceData, meta inter if parts := regexp.MustCompile(`projects\/([^\/]+)\/`).FindStringSubmatch(url); parts != nil { project = parts[1] } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating OrganizationFeed %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating OrganizationFeed %q: %#v", d.Id(), res) } return resourceCloudAssetOrganizationFeedRead(d, meta) diff --git a/google-beta/resource_cloud_asset_project_feed.go b/google-beta/resource_cloud_asset_project_feed.go index 828b130068..7c3279a29b 100644 --- a/google-beta/resource_cloud_asset_project_feed.go +++ b/google-beta/resource_cloud_asset_project_feed.go @@ -318,10 +318,12 @@ func resourceCloudAssetProjectFeedUpdate(d *schema.ResourceData, meta interface{ if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ProjectFeed %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ProjectFeed %q: %#v", d.Id(), res) } return resourceCloudAssetProjectFeedRead(d, meta) diff --git a/google-beta/resource_cloud_build_trigger.go b/google-beta/resource_cloud_build_trigger.go index 47a93e9eb1..cc8156bea9 100644 --- a/google-beta/resource_cloud_build_trigger.go +++ b/google-beta/resource_cloud_build_trigger.go @@ -743,10 +743,12 @@ func resourceCloudBuildTriggerUpdate(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Updating Trigger %q: %#v", d.Id(), obj) obj["id"] = d.Get("trigger_id") - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Trigger %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Trigger %q: %#v", d.Id(), res) } return resourceCloudBuildTriggerRead(d, meta) diff --git a/google-beta/resource_cloud_identity_group.go b/google-beta/resource_cloud_identity_group.go index 48ec6ce242..be456b45c3 100644 --- a/google-beta/resource_cloud_identity_group.go +++ b/google-beta/resource_cloud_identity_group.go @@ -288,10 +288,12 @@ func resourceCloudIdentityGroupUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Group %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Group %q: %#v", d.Id(), res) } return resourceCloudIdentityGroupRead(d, meta) diff --git a/google-beta/resource_cloud_identity_group_membership.go b/google-beta/resource_cloud_identity_group_membership.go index 0246ab1873..65feb41ed8 100644 --- a/google-beta/resource_cloud_identity_group_membership.go +++ b/google-beta/resource_cloud_identity_group_membership.go @@ -301,10 +301,12 @@ func resourceCloudIdentityGroupMembershipUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating GroupMembership %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating GroupMembership %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GroupMembership %q: %#v", d.Id(), res) } return resourceCloudIdentityGroupMembershipRead(d, meta) diff --git a/google-beta/resource_cloud_iot_device.go b/google-beta/resource_cloud_iot_device.go index 85ded1fd9b..f96da26b89 100644 --- a/google-beta/resource_cloud_iot_device.go +++ b/google-beta/resource_cloud_iot_device.go @@ -460,10 +460,12 @@ func resourceCloudIotDeviceUpdate(d *schema.ResourceData, meta interface{}) erro if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Device %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Device %q: %#v", d.Id(), res) } return resourceCloudIotDeviceRead(d, meta) diff --git a/google-beta/resource_cloud_iot_device_registry.go b/google-beta/resource_cloud_iot_device_registry.go index cbcdb974ac..48d15c4deb 100644 --- a/google-beta/resource_cloud_iot_device_registry.go +++ b/google-beta/resource_cloud_iot_device_registry.go @@ -622,10 +622,12 @@ func resourceCloudIotDeviceRegistryUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Update URL %q: %v", d.Id(), url) - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating DeviceRegistry %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating DeviceRegistry %q: %#v", d.Id(), res) } return resourceCloudIotDeviceRegistryRead(d, meta) diff --git a/google-beta/resource_cloud_run_service.go b/google-beta/resource_cloud_run_service.go index b0127df848..f2f51ea582 100644 --- a/google-beta/resource_cloud_run_service.go +++ b/google-beta/resource_cloud_run_service.go @@ -806,10 +806,12 @@ func resourceCloudRunServiceUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Service %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Service %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Service %q: %#v", d.Id(), res) } err = PollingWaitTime(resourceCloudRunServicePollRead(d, meta), PollCheckKnativeStatus, "Updating Service", d.Timeout(schema.TimeoutUpdate), 1) diff --git a/google-beta/resource_cloud_tasks_queue.go b/google-beta/resource_cloud_tasks_queue.go index 121a0c8d45..9c2b9c01ec 100644 --- a/google-beta/resource_cloud_tasks_queue.go +++ b/google-beta/resource_cloud_tasks_queue.go @@ -358,10 +358,12 @@ func resourceCloudTasksQueueUpdate(d *schema.ResourceData, meta interface{}) err if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Queue %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Queue %q: %#v", d.Id(), res) } return resourceCloudTasksQueueRead(d, meta) diff --git a/google-beta/resource_compute_address.go b/google-beta/resource_compute_address.go index eaaeccbe0f..6e9b106aa9 100644 --- a/google-beta/resource_compute_address.go +++ b/google-beta/resource_compute_address.go @@ -392,6 +392,8 @@ func resourceComputeAddressUpdate(d *schema.ResourceData, meta interface{}) erro res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Address %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Address %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_autoscaler.go b/google-beta/resource_compute_autoscaler.go index 21a8d36c8e..8ceb318fc7 100644 --- a/google-beta/resource_compute_autoscaler.go +++ b/google-beta/resource_compute_autoscaler.go @@ -495,6 +495,8 @@ func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return fmt.Errorf("Error updating Autoscaler %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Autoscaler %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_backend_bucket.go b/google-beta/resource_compute_backend_bucket.go index 1d617c0660..77618436ff 100644 --- a/google-beta/resource_compute_backend_bucket.go +++ b/google-beta/resource_compute_backend_bucket.go @@ -281,6 +281,8 @@ func resourceComputeBackendBucketUpdate(d *schema.ResourceData, meta interface{} if err != nil { return fmt.Errorf("Error updating BackendBucket %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating BackendBucket %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_backend_service.go b/google-beta/resource_compute_backend_service.go index 0ae2086d43..ccbe73cb07 100644 --- a/google-beta/resource_compute_backend_service.go +++ b/google-beta/resource_compute_backend_service.go @@ -1403,6 +1403,8 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ if err != nil { return fmt.Errorf("Error updating BackendService %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating BackendService %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_disk.go b/google-beta/resource_compute_disk.go index 322946a57b..fe6dcc19f0 100644 --- a/google-beta/resource_compute_disk.go +++ b/google-beta/resource_compute_disk.go @@ -800,6 +800,8 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Disk %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Disk %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -829,6 +831,8 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Disk %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Disk %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_firewall.go b/google-beta/resource_compute_firewall.go index 14bbba9db2..940a732c99 100644 --- a/google-beta/resource_compute_firewall.go +++ b/google-beta/resource_compute_firewall.go @@ -682,6 +682,8 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err if err != nil { return fmt.Errorf("Error updating Firewall %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Firewall %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_forwarding_rule.go b/google-beta/resource_compute_forwarding_rule.go index 95ccc34cfc..c276867705 100644 --- a/google-beta/resource_compute_forwarding_rule.go +++ b/google-beta/resource_compute_forwarding_rule.go @@ -620,6 +620,8 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ForwardingRule %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -648,6 +650,8 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ForwardingRule %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -682,6 +686,8 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ForwardingRule %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_global_address.go b/google-beta/resource_compute_global_address.go index f5311382b0..7d427c48f1 100644 --- a/google-beta/resource_compute_global_address.go +++ b/google-beta/resource_compute_global_address.go @@ -384,6 +384,8 @@ func resourceComputeGlobalAddressUpdate(d *schema.ResourceData, meta interface{} res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating GlobalAddress %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GlobalAddress %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_global_forwarding_rule.go b/google-beta/resource_compute_global_forwarding_rule.go index 262d9029cf..4bac656c9f 100644 --- a/google-beta/resource_compute_global_forwarding_rule.go +++ b/google-beta/resource_compute_global_forwarding_rule.go @@ -511,6 +511,8 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating GlobalForwardingRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GlobalForwardingRule %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -540,6 +542,8 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating GlobalForwardingRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GlobalForwardingRule %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_health_check.go b/google-beta/resource_compute_health_check.go index e8e65744d0..9c651cc3ad 100644 --- a/google-beta/resource_compute_health_check.go +++ b/google-beta/resource_compute_health_check.go @@ -883,6 +883,8 @@ func resourceComputeHealthCheckUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return fmt.Errorf("Error updating HealthCheck %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating HealthCheck %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_http_health_check.go b/google-beta/resource_compute_http_health_check.go index 0c1bd439a6..dcb80db0fe 100644 --- a/google-beta/resource_compute_http_health_check.go +++ b/google-beta/resource_compute_http_health_check.go @@ -357,6 +357,8 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface if err != nil { return fmt.Errorf("Error updating HttpHealthCheck %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating HttpHealthCheck %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_https_health_check.go b/google-beta/resource_compute_https_health_check.go index 6dcfab71b6..7e852d4d71 100644 --- a/google-beta/resource_compute_https_health_check.go +++ b/google-beta/resource_compute_https_health_check.go @@ -357,6 +357,8 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac if err != nil { return fmt.Errorf("Error updating HttpsHealthCheck %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating HttpsHealthCheck %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_image.go b/google-beta/resource_compute_image.go index 5681fab2fc..89b9e7bca8 100644 --- a/google-beta/resource_compute_image.go +++ b/google-beta/resource_compute_image.go @@ -393,6 +393,8 @@ func resourceComputeImageUpdate(d *schema.ResourceData, meta interface{}) error res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Image %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Image %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_interconnect_attachment.go b/google-beta/resource_compute_interconnect_attachment.go index ef991c7bce..0de816af97 100644 --- a/google-beta/resource_compute_interconnect_attachment.go +++ b/google-beta/resource_compute_interconnect_attachment.go @@ -474,6 +474,8 @@ func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta in if err != nil { return fmt.Errorf("Error updating InterconnectAttachment %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating InterconnectAttachment %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_machine_image.go b/google-beta/resource_compute_machine_image.go index e40f2087a0..e98b9c233f 100644 --- a/google-beta/resource_compute_machine_image.go +++ b/google-beta/resource_compute_machine_image.go @@ -192,10 +192,12 @@ func resourceComputeMachineImageUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating MachineImage %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating MachineImage %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating MachineImage %q: %#v", d.Id(), res) } return resourceComputeMachineImageRead(d, meta) diff --git a/google-beta/resource_compute_network.go b/google-beta/resource_compute_network.go index 10351b3bf0..863a90c606 100644 --- a/google-beta/resource_compute_network.go +++ b/google-beta/resource_compute_network.go @@ -295,6 +295,8 @@ func resourceComputeNetworkUpdate(d *schema.ResourceData, meta interface{}) erro res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Network %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Network %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_network_peering_routes_config.go b/google-beta/resource_compute_network_peering_routes_config.go index 840326f09b..52e42af878 100644 --- a/google-beta/resource_compute_network_peering_routes_config.go +++ b/google-beta/resource_compute_network_peering_routes_config.go @@ -240,6 +240,8 @@ func resourceComputeNetworkPeeringRoutesConfigUpdate(d *schema.ResourceData, met if err != nil { return fmt.Errorf("Error updating NetworkPeeringRoutesConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating NetworkPeeringRoutesConfig %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_node_group.go b/google-beta/resource_compute_node_group.go index 70d46c39d6..1e0c7665e5 100644 --- a/google-beta/resource_compute_node_group.go +++ b/google-beta/resource_compute_node_group.go @@ -290,6 +290,8 @@ func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) er res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating NodeGroup %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating NodeGroup %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_organization_security_policy.go b/google-beta/resource_compute_organization_security_policy.go new file mode 100644 index 0000000000..b01193d645 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy.go @@ -0,0 +1,342 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// 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 google + +import ( + "fmt" + "log" + "reflect" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func resourceComputeOrganizationSecurityPolicy() *schema.Resource { + return &schema.Resource{ + Create: resourceComputeOrganizationSecurityPolicyCreate, + Read: resourceComputeOrganizationSecurityPolicyRead, + Update: resourceComputeOrganizationSecurityPolicyUpdate, + Delete: resourceComputeOrganizationSecurityPolicyDelete, + + Importer: &schema.ResourceImporter{ + State: resourceComputeOrganizationSecurityPolicyImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(4 * time.Minute), + Update: schema.DefaultTimeout(4 * time.Minute), + Delete: schema.DefaultTimeout(4 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `A textual name of the security policy.`, + }, + "parent": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The parent of this OrganizationSecurityPolicy in the Cloud Resource Hierarchy. +Format: organizations/{organization_id} or folders/{folder_id}`, + }, + "description": { + Type: schema.TypeString, + Optional: true, + Description: `A textual description for the organization security policy.`, + }, + "type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"FIREWALL", ""}, false), + Description: `The type indicates the intended use of the security policy. +For organization security policies, the only supported type +is "FIREWALL". Default value: "FIREWALL" Possible values: ["FIREWALL"]`, + Default: "FIREWALL", + }, + "fingerprint": { + Type: schema.TypeString, + Computed: true, + Description: `Fingerprint of this resource. This field is used internally during +updates of this resource.`, + }, + "policy_id": { + Type: schema.TypeString, + Computed: true, + Description: `The unique identifier for the resource. This identifier is defined by the server.`, + }, + }, + } +} + +func resourceComputeOrganizationSecurityPolicyCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + obj := make(map[string]interface{}) + displayNameProp, err := expandComputeOrganizationSecurityPolicyDisplayName(d.Get("display_name"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("display_name"); !isEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { + obj["displayName"] = displayNameProp + } + descriptionProp, err := expandComputeOrganizationSecurityPolicyDescription(d.Get("description"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { + obj["description"] = descriptionProp + } + fingerprintProp, err := expandComputeOrganizationSecurityPolicyFingerprint(d.Get("fingerprint"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("fingerprint"); !isEmptyValue(reflect.ValueOf(fingerprintProp)) && (ok || !reflect.DeepEqual(v, fingerprintProp)) { + obj["fingerprint"] = fingerprintProp + } + typeProp, err := expandComputeOrganizationSecurityPolicyType(d.Get("type"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("type"); !isEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) { + obj["type"] = typeProp + } + parentProp, err := expandComputeOrganizationSecurityPolicyParent(d.Get("parent"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("parent"); !isEmptyValue(reflect.ValueOf(parentProp)) && (ok || !reflect.DeepEqual(v, parentProp)) { + obj["parent"] = parentProp + } + + url, err := replaceVars(d, config, "{{ComputeBasePath}}locations/global/securityPolicies?parentId={{parent}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new OrganizationSecurityPolicy: %#v", obj) + res, err := sendRequestWithTimeout(config, "POST", "", url, obj, d.Timeout(schema.TimeoutCreate)) + if err != nil { + return fmt.Errorf("Error creating OrganizationSecurityPolicy: %s", err) + } + + // Store the ID now + id, err := replaceVars(d, config, "locations/global/securityPolicies/{{policy_id}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + log.Printf("[DEBUG] Finished creating OrganizationSecurityPolicy %q: %#v", d.Id(), res) + + parent := d.Get("parent").(string) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent, "Creating OrganizationSecurityPolicy", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create OrganizationSecurityPolicy: %s", err) + } + + policyId, ok := opRes["targetId"] + if !ok { + return fmt.Errorf("Create response didn't contain targetId. Create may not have succeeded.") + } + d.Set("policy_id", policyId.(string)) + + // Store the ID now. + id, err = replaceVars(d, config, "locations/global/securityPolicies/{{policy_id}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return resourceComputeOrganizationSecurityPolicyRead(d, meta) +} + +func resourceComputeOrganizationSecurityPolicyRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{ComputeBasePath}}locations/global/securityPolicies/{{policy_id}}") + if err != nil { + return err + } + + res, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicy %q", d.Id())) + } + + if err := d.Set("display_name", flattenComputeOrganizationSecurityPolicyDisplayName(res["displayName"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicy: %s", err) + } + if err := d.Set("description", flattenComputeOrganizationSecurityPolicyDescription(res["description"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicy: %s", err) + } + if err := d.Set("fingerprint", flattenComputeOrganizationSecurityPolicyFingerprint(res["fingerprint"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicy: %s", err) + } + if err := d.Set("policy_id", flattenComputeOrganizationSecurityPolicyPolicyId(res["id"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicy: %s", err) + } + if err := d.Set("type", flattenComputeOrganizationSecurityPolicyType(res["type"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicy: %s", err) + } + if err := d.Set("parent", flattenComputeOrganizationSecurityPolicyParent(res["parent"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicy: %s", err) + } + + return nil +} + +func resourceComputeOrganizationSecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + obj := make(map[string]interface{}) + descriptionProp, err := expandComputeOrganizationSecurityPolicyDescription(d.Get("description"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { + obj["description"] = descriptionProp + } + fingerprintProp, err := expandComputeOrganizationSecurityPolicyFingerprint(d.Get("fingerprint"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("fingerprint"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, fingerprintProp)) { + obj["fingerprint"] = fingerprintProp + } + + url, err := replaceVars(d, config, "{{ComputeBasePath}}locations/global/securityPolicies/{{policy_id}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating OrganizationSecurityPolicy %q: %#v", d.Id(), obj) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + + if err != nil { + return fmt.Errorf("Error updating OrganizationSecurityPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating OrganizationSecurityPolicy %q: %#v", d.Id(), res) + } + + parent := d.Get("parent").(string) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent, "Creating OrganizationSecurityPolicy", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually update + return fmt.Errorf("Error waiting to update OrganizationSecurityPolicy: %s", err) + } + return resourceComputeOrganizationSecurityPolicyRead(d, meta) +} + +func resourceComputeOrganizationSecurityPolicyDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{ComputeBasePath}}locations/global/securityPolicies/{{policy_id}}") + if err != nil { + return err + } + + var obj map[string]interface{} + log.Printf("[DEBUG] Deleting OrganizationSecurityPolicy %q", d.Id()) + + res, err := sendRequestWithTimeout(config, "DELETE", "", url, obj, d.Timeout(schema.TimeoutDelete)) + if err != nil { + return handleNotFoundError(err, d, "OrganizationSecurityPolicy") + } + + parent := d.Get("parent").(string) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent, "Creating OrganizationSecurityPolicy", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually delete + return fmt.Errorf("Error waiting to delete OrganizationSecurityPolicy: %s", err) + } + + log.Printf("[DEBUG] Finished deleting OrganizationSecurityPolicy %q: %#v", d.Id(), res) + return nil +} + +func resourceComputeOrganizationSecurityPolicyImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*Config) + if err := parseImportId([]string{ + "locations/global/securityPolicies/(?P[^/]+)", + "(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := replaceVars(d, config, "locations/global/securityPolicies/{{policy_id}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil +} + +func flattenComputeOrganizationSecurityPolicyDisplayName(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyDescription(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyFingerprint(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyPolicyId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyType(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyParent(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func expandComputeOrganizationSecurityPolicyDisplayName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyFingerprint(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyParent(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} diff --git a/google-beta/resource_compute_organization_security_policy_association.go b/google-beta/resource_compute_organization_security_policy_association.go new file mode 100644 index 0000000000..c1c72cb942 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_association.go @@ -0,0 +1,242 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// 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 google + +import ( + "fmt" + "log" + "reflect" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +func resourceComputeOrganizationSecurityPolicyAssociation() *schema.Resource { + return &schema.Resource{ + Create: resourceComputeOrganizationSecurityPolicyAssociationCreate, + Read: resourceComputeOrganizationSecurityPolicyAssociationRead, + Delete: resourceComputeOrganizationSecurityPolicyAssociationDelete, + + Importer: &schema.ResourceImporter{ + State: resourceComputeOrganizationSecurityPolicyAssociationImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(4 * time.Minute), + Delete: schema.DefaultTimeout(4 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "attachment_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The resource that the security policy is attached to.`, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The name for an association.`, + }, + "policy_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The security policy ID of the association.`, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: `The display name of the security policy of the association.`, + }, + }, + } +} + +func resourceComputeOrganizationSecurityPolicyAssociationCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + obj := make(map[string]interface{}) + nameProp, err := expandComputeOrganizationSecurityPolicyAssociationName(d.Get("name"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { + obj["name"] = nameProp + } + attachmentIdProp, err := expandComputeOrganizationSecurityPolicyAssociationAttachmentId(d.Get("attachment_id"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("attachment_id"); !isEmptyValue(reflect.ValueOf(attachmentIdProp)) && (ok || !reflect.DeepEqual(v, attachmentIdProp)) { + obj["attachmentId"] = attachmentIdProp + } + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/addAssociation") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new OrganizationSecurityPolicyAssociation: %#v", obj) + res, err := sendRequestWithTimeout(config, "POST", "", url, obj, d.Timeout(schema.TimeoutCreate)) + if err != nil { + return fmt.Errorf("Error creating OrganizationSecurityPolicyAssociation: %s", err) + } + + // Store the ID now + id, err := replaceVars(d, config, "{{policy_id}}/association/{{name}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + log.Printf("[DEBUG] Finished creating OrganizationSecurityPolicyAssociation %q: %#v", d.Id(), res) + + // `parent` is needed to poll the asynchronous operations but its available only on the policy. + + policyUrl := fmt.Sprintf("{{ComputeBasePath}}%s", d.Get("policy_id")) + url, err = replaceVars(d, config, policyUrl) + if err != nil { + return err + } + + policyRes, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicy %q", d.Get("policy_id"))) + } + + parent := flattenComputeOrganizationSecurityPolicyParent(policyRes["parent"], d, config) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent.(string), "Creating OrganizationSecurityPolicyAssociation", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create OrganizationSecurityPolicyAssociation: %s", err) + } + + return resourceComputeOrganizationSecurityPolicyAssociationRead(d, meta) +} + +func resourceComputeOrganizationSecurityPolicyAssociationRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/getAssociation?name={{name}}") + if err != nil { + return err + } + + res, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicyAssociation %q", d.Id())) + } + + if err := d.Set("name", flattenComputeOrganizationSecurityPolicyAssociationName(res["name"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyAssociation: %s", err) + } + if err := d.Set("attachment_id", flattenComputeOrganizationSecurityPolicyAssociationAttachmentId(res["attachmentId"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyAssociation: %s", err) + } + if err := d.Set("display_name", flattenComputeOrganizationSecurityPolicyAssociationDisplayName(res["displayName"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyAssociation: %s", err) + } + + return nil +} + +func resourceComputeOrganizationSecurityPolicyAssociationDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/removeAssociation?name={{name}}") + if err != nil { + return err + } + + var obj map[string]interface{} + log.Printf("[DEBUG] Deleting OrganizationSecurityPolicyAssociation %q", d.Id()) + + res, err := sendRequestWithTimeout(config, "POST", "", url, obj, d.Timeout(schema.TimeoutDelete)) + if err != nil { + return handleNotFoundError(err, d, "OrganizationSecurityPolicyAssociation") + } + + // `parent` is needed to poll the asynchronous operations but its available only on the policy. + + policyUrl := fmt.Sprintf("{{ComputeBasePath}}%s", d.Get("policy_id")) + url, err = replaceVars(d, config, policyUrl) + if err != nil { + return err + } + + policyRes, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicy %q", d.Get("policy_id"))) + } + + parent := flattenComputeOrganizationSecurityPolicyParent(policyRes["parent"], d, config) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent.(string), "Creating OrganizationSecurityPolicyAssociation", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create OrganizationSecurityPolicyAssociation: %s", err) + } + + log.Printf("[DEBUG] Finished deleting OrganizationSecurityPolicyAssociation %q: %#v", d.Id(), res) + return nil +} + +func resourceComputeOrganizationSecurityPolicyAssociationImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*Config) + if err := parseImportId([]string{ + "(?P[^/]+)/association/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := replaceVars(d, config, "{{policy_id}}/association/{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil +} + +func flattenComputeOrganizationSecurityPolicyAssociationName(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyAssociationAttachmentId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyAssociationDisplayName(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func expandComputeOrganizationSecurityPolicyAssociationName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyAssociationAttachmentId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} diff --git a/google-beta/resource_compute_organization_security_policy_association_generated_test.go b/google-beta/resource_compute_organization_security_policy_association_generated_test.go new file mode 100644 index 0000000000..23a6e04f74 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_association_generated_test.go @@ -0,0 +1,103 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// 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 google + +import ( + "log" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" +) + +func TestAccComputeOrganizationSecurityPolicyAssociation_organizationSecurityPolicyAssociationBasicExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "org_id": getTestOrgFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProvidersOiCS, + CheckDestroy: testAccCheckComputeOrganizationSecurityPolicyAssociationDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeOrganizationSecurityPolicyAssociation_organizationSecurityPolicyAssociationBasicExample(context), + }, + }, + }) +} + +func testAccComputeOrganizationSecurityPolicyAssociation_organizationSecurityPolicyAssociationBasicExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + provider = "google-beta" + + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" +} + +resource "google_compute_organization_security_policy_rule" "policy" { + provider = "google-beta" + + policy_id = google_compute_organization_security_policy.policy.id + action = "allow" + + direction = "INGRESS" + enable_logging = true + match { + config { + src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"] + layer4_config { + ip_protocol = "tcp" + ports = ["22"] + } + layer4_config { + ip_protocol = "icmp" + } + } + } + priority = 100 +} + +resource "google_compute_organization_security_policy_association" "policy" { + provider = "google-beta" + + name = "tf-test%{random_suffix}" + attachment_id = google_compute_organization_security_policy.policy.parent + policy_id = google_compute_organization_security_policy.policy.id +} +`, context) +} + +func testAccCheckComputeOrganizationSecurityPolicyAssociationDestroyProducer(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_compute_organization_security_policy_association" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + log.Printf("[DEBUG] Ignoring destroy during test") + } + + return nil + } +} diff --git a/google-beta/resource_compute_organization_security_policy_generated_test.go b/google-beta/resource_compute_organization_security_policy_generated_test.go new file mode 100644 index 0000000000..e85f806099 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_generated_test.go @@ -0,0 +1,72 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// 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 google + +import ( + "log" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" +) + +func TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyBasicExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "org_id": getTestOrgFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProvidersOiCS, + CheckDestroy: testAccCheckComputeOrganizationSecurityPolicyDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyBasicExample(context), + }, + }, + }) +} + +func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyBasicExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + provider = "google-beta" + + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" +} +`, context) +} + +func testAccCheckComputeOrganizationSecurityPolicyDestroyProducer(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_compute_organization_security_policy" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + log.Printf("[DEBUG] Ignoring destroy during test") + } + + return nil + } +} diff --git a/google-beta/resource_compute_organization_security_policy_rule.go b/google-beta/resource_compute_organization_security_policy_rule.go new file mode 100644 index 0000000000..9fd1dd6dbc --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_rule.go @@ -0,0 +1,795 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// 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 google + +import ( + "fmt" + "log" + "reflect" + "strconv" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func resourceComputeOrganizationSecurityPolicyRule() *schema.Resource { + return &schema.Resource{ + Create: resourceComputeOrganizationSecurityPolicyRuleCreate, + Read: resourceComputeOrganizationSecurityPolicyRuleRead, + Update: resourceComputeOrganizationSecurityPolicyRuleUpdate, + Delete: resourceComputeOrganizationSecurityPolicyRuleDelete, + + Importer: &schema.ResourceImporter{ + State: resourceComputeOrganizationSecurityPolicyRuleImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(4 * time.Minute), + Update: schema.DefaultTimeout(4 * time.Minute), + Delete: schema.DefaultTimeout(4 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeString, + Required: true, + Description: `The Action to perform when the client connection triggers the rule. Can currently be either +"allow", "deny" or "goto_next".`, + }, + "match": { + Type: schema.TypeList, + Required: true, + Description: `A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config": { + Type: schema.TypeList, + Required: true, + Description: `The configuration options for matching the rule.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "layer4_config": { + Type: schema.TypeList, + Required: true, + Description: `Pairs of IP protocols and ports that the rule should match.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip_protocol": { + Type: schema.TypeString, + Required: true, + Description: `The IP protocol to which this rule applies. The protocol +type is required when creating a firewall rule. +This value can either be one of the following well +known protocol strings (tcp, udp, icmp, esp, ah, ipip, sctp), +or the IP protocol number.`, + }, + "ports": { + Type: schema.TypeList, + Optional: true, + Description: `An optional list of ports to which this rule applies. This field +is only applicable for UDP or TCP protocol. Each entry must be +either an integer or a range. If not specified, this rule +applies to connections through any port. + +Example inputs include: ["22"], ["80","443"], and +["12345-12349"].`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "dest_ip_ranges": { + Type: schema.TypeList, + Optional: true, + Description: `Destination IP address range in CIDR format. Required for +EGRESS rules.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + ExactlyOneOf: []string{"match.0.config.0.src_ip_ranges", "match.0.config.0.dest_ip_ranges"}, + }, + "src_ip_ranges": { + Type: schema.TypeList, + Optional: true, + Description: `Source IP address range in CIDR format. Required for +INGRESS rules.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + ExactlyOneOf: []string{"match.0.config.0.src_ip_ranges", "match.0.config.0.dest_ip_ranges"}, + }, + }, + }, + }, + "description": { + Type: schema.TypeString, + Optional: true, + Description: `A description of the rule.`, + }, + "versioned_expr": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"FIREWALL", ""}, false), + Description: `Preconfigured versioned expression. For organization security policy rules, +the only supported type is "FIREWALL". Default value: "FIREWALL" Possible values: ["FIREWALL"]`, + Default: "FIREWALL", + }, + }, + }, + }, + "policy_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The ID of the OrganizationSecurityPolicy this rule applies to.`, + }, + "priority": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + Description: `An integer indicating the priority of a rule in the list. The priority must be a value +between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the +highest priority and 2147483647 is the lowest prority.`, + }, + "description": { + Type: schema.TypeString, + Optional: true, + Description: `A description of the rule.`, + }, + "direction": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"INGRESS", "EGRESS", ""}, false), + Description: `The direction in which this rule applies. If unspecified an INGRESS rule is created. Possible values: ["INGRESS", "EGRESS"]`, + }, + "enable_logging": { + Type: schema.TypeBool, + Optional: true, + Description: `Denotes whether to enable logging for a particular rule. +If logging is enabled, logs will be exported to the +configured export destination in Stackdriver.`, + }, + "preview": { + Type: schema.TypeBool, + Optional: true, + Description: `If set to true, the specified action is not enforced.`, + }, + "target_resources": { + Type: schema.TypeList, + Optional: true, + Description: `A list of network resource URLs to which this rule applies. +This field allows you to control which network's VMs get +this rule. If this field is left blank, all VMs +within the organization will receive the rule.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "target_service_accounts": { + Type: schema.TypeList, + Optional: true, + Description: `A list of service accounts indicating the sets of +instances that are applied with this rule.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + } +} + +func resourceComputeOrganizationSecurityPolicyRuleCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + obj := make(map[string]interface{}) + descriptionProp, err := expandComputeOrganizationSecurityPolicyRuleDescription(d.Get("description"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { + obj["description"] = descriptionProp + } + priorityProp, err := expandComputeOrganizationSecurityPolicyRulePriority(d.Get("priority"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("priority"); !isEmptyValue(reflect.ValueOf(priorityProp)) && (ok || !reflect.DeepEqual(v, priorityProp)) { + obj["priority"] = priorityProp + } + matchProp, err := expandComputeOrganizationSecurityPolicyRuleMatch(d.Get("match"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("match"); !isEmptyValue(reflect.ValueOf(matchProp)) && (ok || !reflect.DeepEqual(v, matchProp)) { + obj["match"] = matchProp + } + actionProp, err := expandComputeOrganizationSecurityPolicyRuleAction(d.Get("action"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("action"); !isEmptyValue(reflect.ValueOf(actionProp)) && (ok || !reflect.DeepEqual(v, actionProp)) { + obj["action"] = actionProp + } + previewProp, err := expandComputeOrganizationSecurityPolicyRulePreview(d.Get("preview"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("preview"); !isEmptyValue(reflect.ValueOf(previewProp)) && (ok || !reflect.DeepEqual(v, previewProp)) { + obj["preview"] = previewProp + } + directionProp, err := expandComputeOrganizationSecurityPolicyRuleDirection(d.Get("direction"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("direction"); !isEmptyValue(reflect.ValueOf(directionProp)) && (ok || !reflect.DeepEqual(v, directionProp)) { + obj["direction"] = directionProp + } + targetResourcesProp, err := expandComputeOrganizationSecurityPolicyRuleTargetResources(d.Get("target_resources"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("target_resources"); !isEmptyValue(reflect.ValueOf(targetResourcesProp)) && (ok || !reflect.DeepEqual(v, targetResourcesProp)) { + obj["targetResources"] = targetResourcesProp + } + enableLoggingProp, err := expandComputeOrganizationSecurityPolicyRuleEnableLogging(d.Get("enable_logging"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("enable_logging"); ok || !reflect.DeepEqual(v, enableLoggingProp) { + obj["enableLogging"] = enableLoggingProp + } + targetServiceAccountsProp, err := expandComputeOrganizationSecurityPolicyRuleTargetServiceAccounts(d.Get("target_service_accounts"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("target_service_accounts"); !isEmptyValue(reflect.ValueOf(targetServiceAccountsProp)) && (ok || !reflect.DeepEqual(v, targetServiceAccountsProp)) { + obj["targetServiceAccounts"] = targetServiceAccountsProp + } + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/addRule?priority={{priority}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new OrganizationSecurityPolicyRule: %#v", obj) + res, err := sendRequestWithTimeout(config, "POST", "", url, obj, d.Timeout(schema.TimeoutCreate)) + if err != nil { + return fmt.Errorf("Error creating OrganizationSecurityPolicyRule: %s", err) + } + + // Store the ID now + id, err := replaceVars(d, config, "{{policy_id}}/priority/{{priority}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + log.Printf("[DEBUG] Finished creating OrganizationSecurityPolicyRule %q: %#v", d.Id(), res) + + // `parent` is needed to poll the asynchronous operations but its available only on the policy. + + policyUrl := fmt.Sprintf("{{ComputeBasePath}}%s", d.Get("policy_id")) + url, err = replaceVars(d, config, policyUrl) + if err != nil { + return err + } + + policyRes, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicy %q", d.Get("policy_id"))) + } + + parent := flattenComputeOrganizationSecurityPolicyParent(policyRes["parent"], d, config) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent.(string), "Creating OrganizationSecurityPolicyRule", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create OrganizationSecurityPolicyRule: %s", err) + } + + return resourceComputeOrganizationSecurityPolicyRuleRead(d, meta) +} + +func resourceComputeOrganizationSecurityPolicyRuleRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/getRule?priority={{priority}}") + if err != nil { + return err + } + + res, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicyRule %q", d.Id())) + } + + if err := d.Set("description", flattenComputeOrganizationSecurityPolicyRuleDescription(res["description"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("priority", flattenComputeOrganizationSecurityPolicyRulePriority(res["priority"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("match", flattenComputeOrganizationSecurityPolicyRuleMatch(res["match"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("action", flattenComputeOrganizationSecurityPolicyRuleAction(res["action"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("preview", flattenComputeOrganizationSecurityPolicyRulePreview(res["preview"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("direction", flattenComputeOrganizationSecurityPolicyRuleDirection(res["direction"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("target_resources", flattenComputeOrganizationSecurityPolicyRuleTargetResources(res["targetResources"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("enable_logging", flattenComputeOrganizationSecurityPolicyRuleEnableLogging(res["enableLogging"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + if err := d.Set("target_service_accounts", flattenComputeOrganizationSecurityPolicyRuleTargetServiceAccounts(res["targetServiceAccounts"], d, config)); err != nil { + return fmt.Errorf("Error reading OrganizationSecurityPolicyRule: %s", err) + } + + return nil +} + +func resourceComputeOrganizationSecurityPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + obj := make(map[string]interface{}) + descriptionProp, err := expandComputeOrganizationSecurityPolicyRuleDescription(d.Get("description"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { + obj["description"] = descriptionProp + } + priorityProp, err := expandComputeOrganizationSecurityPolicyRulePriority(d.Get("priority"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("priority"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, priorityProp)) { + obj["priority"] = priorityProp + } + matchProp, err := expandComputeOrganizationSecurityPolicyRuleMatch(d.Get("match"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("match"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, matchProp)) { + obj["match"] = matchProp + } + actionProp, err := expandComputeOrganizationSecurityPolicyRuleAction(d.Get("action"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("action"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, actionProp)) { + obj["action"] = actionProp + } + previewProp, err := expandComputeOrganizationSecurityPolicyRulePreview(d.Get("preview"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("preview"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, previewProp)) { + obj["preview"] = previewProp + } + directionProp, err := expandComputeOrganizationSecurityPolicyRuleDirection(d.Get("direction"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("direction"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, directionProp)) { + obj["direction"] = directionProp + } + targetResourcesProp, err := expandComputeOrganizationSecurityPolicyRuleTargetResources(d.Get("target_resources"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("target_resources"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetResourcesProp)) { + obj["targetResources"] = targetResourcesProp + } + enableLoggingProp, err := expandComputeOrganizationSecurityPolicyRuleEnableLogging(d.Get("enable_logging"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("enable_logging"); ok || !reflect.DeepEqual(v, enableLoggingProp) { + obj["enableLogging"] = enableLoggingProp + } + targetServiceAccountsProp, err := expandComputeOrganizationSecurityPolicyRuleTargetServiceAccounts(d.Get("target_service_accounts"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("target_service_accounts"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetServiceAccountsProp)) { + obj["targetServiceAccounts"] = targetServiceAccountsProp + } + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/patchRule?priority={{priority}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating OrganizationSecurityPolicyRule %q: %#v", d.Id(), obj) + res, err := sendRequestWithTimeout(config, "POST", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + + if err != nil { + return fmt.Errorf("Error updating OrganizationSecurityPolicyRule %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating OrganizationSecurityPolicyRule %q: %#v", d.Id(), res) + } + + // `parent` is needed to poll the asynchronous operations but its available only on the policy. + + policyUrl := fmt.Sprintf("{{ComputeBasePath}}%s", d.Get("policy_id")) + url, err = replaceVars(d, config, policyUrl) + if err != nil { + return err + } + + policyRes, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicy %q", d.Get("policy_id"))) + } + + parent := flattenComputeOrganizationSecurityPolicyParent(policyRes["parent"], d, config) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent.(string), "Creating OrganizationSecurityPolicyRule", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create OrganizationSecurityPolicyRule: %s", err) + } + return resourceComputeOrganizationSecurityPolicyRuleRead(d, meta) +} + +func resourceComputeOrganizationSecurityPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + url, err := replaceVars(d, config, "{{ComputeBasePath}}{{policy_id}}/removeRule?priority={{priority}}") + if err != nil { + return err + } + + var obj map[string]interface{} + log.Printf("[DEBUG] Deleting OrganizationSecurityPolicyRule %q", d.Id()) + + res, err := sendRequestWithTimeout(config, "POST", "", url, obj, d.Timeout(schema.TimeoutDelete)) + if err != nil { + return handleNotFoundError(err, d, "OrganizationSecurityPolicyRule") + } + + // `parent` is needed to poll the asynchronous operations but its available only on the policy. + + policyUrl := fmt.Sprintf("{{ComputeBasePath}}%s", d.Get("policy_id")) + url, err = replaceVars(d, config, policyUrl) + if err != nil { + return err + } + + policyRes, err := sendRequest(config, "GET", "", url, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("ComputeOrganizationSecurityPolicy %q", d.Get("policy_id"))) + } + + parent := flattenComputeOrganizationSecurityPolicyParent(policyRes["parent"], d, config) + var opRes map[string]interface{} + err = computeOrgOperationWaitTimeWithResponse( + config, res, &opRes, parent.(string), "Creating OrganizationSecurityPolicyRule", + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create OrganizationSecurityPolicyRule: %s", err) + } + + log.Printf("[DEBUG] Finished deleting OrganizationSecurityPolicyRule %q: %#v", d.Id(), res) + return nil +} + +func resourceComputeOrganizationSecurityPolicyRuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*Config) + + // current import_formats can't import fields with forward slashes in their value + if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { + return nil, err + } + + nameParts := strings.Split(d.Get("policy_id").(string), "/") + if len(nameParts) != 6 { + return nil, fmt.Errorf( + "Saw %s when the import ID is expected to have shape %s", + d.Get("policy_id").(string), + "locations/global/securityPolicies/{{policy_id}}/priority/{{priority}}", + ) + } + d.Set("policy_id", fmt.Sprintf("locations/global/securityPolicies/%s", nameParts[3])) + + if prio, err := strconv.ParseInt(nameParts[5], 10, 64); err != nil { + return nil, fmt.Errorf( + "Priority %s cannot be converted to integer", nameParts[5], + ) + } else { + d.Set("priority", prio) + } + + return []*schema.ResourceData{d}, nil +} + +func flattenComputeOrganizationSecurityPolicyRuleDescription(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRulePriority(v interface{}, d *schema.ResourceData, config *Config) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := strconv.ParseInt(strVal, 10, 64); 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 flattenComputeOrganizationSecurityPolicyRuleMatch(v interface{}, d *schema.ResourceData, config *Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["description"] = + flattenComputeOrganizationSecurityPolicyRuleMatchDescription(original["description"], d, config) + transformed["versioned_expr"] = + flattenComputeOrganizationSecurityPolicyRuleMatchVersionedExpr(original["versionedExpr"], d, config) + transformed["config"] = + flattenComputeOrganizationSecurityPolicyRuleMatchConfig(original["config"], d, config) + return []interface{}{transformed} +} +func flattenComputeOrganizationSecurityPolicyRuleMatchDescription(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleMatchVersionedExpr(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleMatchConfig(v interface{}, d *schema.ResourceData, config *Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["src_ip_ranges"] = + flattenComputeOrganizationSecurityPolicyRuleMatchConfigSrcIpRanges(original["srcIpRanges"], d, config) + transformed["dest_ip_ranges"] = + flattenComputeOrganizationSecurityPolicyRuleMatchConfigDestIpRanges(original["destIpRanges"], d, config) + transformed["layer4_config"] = + flattenComputeOrganizationSecurityPolicyRuleMatchConfigLayer4Config(original["layer4Configs"], d, config) + return []interface{}{transformed} +} +func flattenComputeOrganizationSecurityPolicyRuleMatchConfigSrcIpRanges(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleMatchConfigDestIpRanges(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleMatchConfigLayer4Config(v interface{}, d *schema.ResourceData, config *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{}{ + "ip_protocol": flattenComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigIpProtocol(original["ipProtocol"], d, config), + "ports": flattenComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigPorts(original["ports"], d, config), + }) + } + return transformed +} +func flattenComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigIpProtocol(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigPorts(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleAction(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRulePreview(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleDirection(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleTargetResources(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleEnableLogging(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenComputeOrganizationSecurityPolicyRuleTargetServiceAccounts(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func expandComputeOrganizationSecurityPolicyRuleDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRulePriority(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatch(v interface{}, d TerraformResourceData, config *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{}) + + transformedDescription, err := expandComputeOrganizationSecurityPolicyRuleMatchDescription(original["description"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !isEmptyValue(val) { + transformed["description"] = transformedDescription + } + + transformedVersionedExpr, err := expandComputeOrganizationSecurityPolicyRuleMatchVersionedExpr(original["versioned_expr"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedVersionedExpr); val.IsValid() && !isEmptyValue(val) { + transformed["versionedExpr"] = transformedVersionedExpr + } + + transformedConfig, err := expandComputeOrganizationSecurityPolicyRuleMatchConfig(original["config"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedConfig); val.IsValid() && !isEmptyValue(val) { + transformed["config"] = transformedConfig + } + + return transformed, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchVersionedExpr(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchConfig(v interface{}, d TerraformResourceData, config *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{}) + + transformedSrcIpRanges, err := expandComputeOrganizationSecurityPolicyRuleMatchConfigSrcIpRanges(original["src_ip_ranges"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSrcIpRanges); val.IsValid() && !isEmptyValue(val) { + transformed["srcIpRanges"] = transformedSrcIpRanges + } + + transformedDestIpRanges, err := expandComputeOrganizationSecurityPolicyRuleMatchConfigDestIpRanges(original["dest_ip_ranges"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDestIpRanges); val.IsValid() && !isEmptyValue(val) { + transformed["destIpRanges"] = transformedDestIpRanges + } + + transformedLayer4Config, err := expandComputeOrganizationSecurityPolicyRuleMatchConfigLayer4Config(original["layer4_config"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedLayer4Config); val.IsValid() && !isEmptyValue(val) { + transformed["layer4Configs"] = transformedLayer4Config + } + + return transformed, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchConfigSrcIpRanges(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchConfigDestIpRanges(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchConfigLayer4Config(v interface{}, d TerraformResourceData, config *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{}) + + transformedIpProtocol, err := expandComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigIpProtocol(original["ip_protocol"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedIpProtocol); val.IsValid() && !isEmptyValue(val) { + transformed["ipProtocol"] = transformedIpProtocol + } + + transformedPorts, err := expandComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigPorts(original["ports"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPorts); val.IsValid() && !isEmptyValue(val) { + transformed["ports"] = transformedPorts + } + + req = append(req, transformed) + } + return req, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigIpProtocol(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleMatchConfigLayer4ConfigPorts(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleAction(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRulePreview(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleDirection(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleTargetResources(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleEnableLogging(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandComputeOrganizationSecurityPolicyRuleTargetServiceAccounts(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} diff --git a/google-beta/resource_compute_organization_security_policy_rule_generated_test.go b/google-beta/resource_compute_organization_security_policy_rule_generated_test.go new file mode 100644 index 0000000000..c30d6400a9 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_rule_generated_test.go @@ -0,0 +1,95 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// 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 google + +import ( + "log" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" +) + +func TestAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRuleBasicExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "org_id": getTestOrgFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProvidersOiCS, + CheckDestroy: testAccCheckComputeOrganizationSecurityPolicyRuleDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRuleBasicExample(context), + }, + }, + }) +} + +func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRuleBasicExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + provider = "google-beta" + + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" +} + +resource "google_compute_organization_security_policy_rule" "policy" { + provider = "google-beta" + + policy_id = google_compute_organization_security_policy.policy.id + action = "allow" + + direction = "INGRESS" + enable_logging = true + match { + config { + src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"] + layer4_config { + ip_protocol = "tcp" + ports = ["22"] + } + layer4_config { + ip_protocol = "icmp" + } + } + } + priority = 100 +} +`, context) +} + +func testAccCheckComputeOrganizationSecurityPolicyRuleDestroyProducer(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_compute_organization_security_policy_rule" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + log.Printf("[DEBUG] Ignoring destroy during test") + } + + return nil + } +} diff --git a/google-beta/resource_compute_organization_security_policy_rule_test.go b/google-beta/resource_compute_organization_security_policy_rule_test.go new file mode 100644 index 0000000000..4bc56e5a05 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_rule_test.go @@ -0,0 +1,100 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +func TestAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRuleUpdateExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "org_id": getTestOrgFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeOrganizationSecurityPolicyRuleDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRulePreUpdateExample(context), + }, + { + ResourceName: "google_compute_organization_security_policy_rule.policy", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRulePostUpdateExample(context), + }, + { + ResourceName: "google_compute_organization_security_policy_rule.policy", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRulePreUpdateExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" +} + +resource "google_compute_organization_security_policy_rule" "policy" { + + policy_id = google_compute_organization_security_policy.policy.id + action = "allow" + + direction = "INGRESS" + enable_logging = true + match { + config { + src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"] + layer4_config { + ip_protocol = "tcp" + ports = ["22"] + } + layer4_config { + ip_protocol = "icmp" + } + } + } + priority = 100 +} +`, context) +} + +func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRulePostUpdateExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" +} + +resource "google_compute_organization_security_policy_rule" "policy" { + + policy_id = google_compute_organization_security_policy.policy.id + action = "deny" + + direction = "INGRESS" + enable_logging = false + description = "Updated description" + match { + config { + src_ip_ranges = ["172.16.0.0/12"] + layer4_config { + ip_protocol = "udp" + ports = ["53"] + } + } + } + priority = 100 +} +`, context) +} diff --git a/google-beta/resource_compute_organization_security_policy_test.go b/google-beta/resource_compute_organization_security_policy_test.go new file mode 100644 index 0000000000..74572ef2d4 --- /dev/null +++ b/google-beta/resource_compute_organization_security_policy_test.go @@ -0,0 +1,59 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +func TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdateExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "org_id": getTestOrgFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeOrganizationSecurityPolicyDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPreUpdateExample(context), + }, + { + ResourceName: "google_compute_organization_security_policy.policy", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPostUpdateExample(context), + }, + { + ResourceName: "google_compute_organization_security_policy.policy", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPreUpdateExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" +} +`, context) +} + +func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyPostUpdateExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_compute_organization_security_policy" "policy" { + display_name = "tf-test%{random_suffix}" + parent = "organizations/%{org_id}" + description = "Updated description." +} +`, context) +} diff --git a/google-beta/resource_compute_packet_mirroring.go b/google-beta/resource_compute_packet_mirroring.go index 5b641592a6..84588fa8da 100644 --- a/google-beta/resource_compute_packet_mirroring.go +++ b/google-beta/resource_compute_packet_mirroring.go @@ -395,6 +395,8 @@ func resourceComputePacketMirroringUpdate(d *schema.ResourceData, meta interface if err != nil { return fmt.Errorf("Error updating PacketMirroring %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating PacketMirroring %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_per_instance_config.go b/google-beta/resource_compute_per_instance_config.go index 965c1d4e31..1cb2b95145 100644 --- a/google-beta/resource_compute_per_instance_config.go +++ b/google-beta/resource_compute_per_instance_config.go @@ -309,6 +309,8 @@ func resourceComputePerInstanceConfigUpdate(d *schema.ResourceData, meta interfa if err != nil { return fmt.Errorf("Error updating PerInstanceConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating PerInstanceConfig %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_autoscaler.go b/google-beta/resource_compute_region_autoscaler.go index 5cd8dbe308..f2be3dce29 100644 --- a/google-beta/resource_compute_region_autoscaler.go +++ b/google-beta/resource_compute_region_autoscaler.go @@ -494,6 +494,8 @@ func resourceComputeRegionAutoscalerUpdate(d *schema.ResourceData, meta interfac if err != nil { return fmt.Errorf("Error updating RegionAutoscaler %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionAutoscaler %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_backend_service.go b/google-beta/resource_compute_region_backend_service.go index ad3d90268b..aac4468519 100644 --- a/google-beta/resource_compute_region_backend_service.go +++ b/google-beta/resource_compute_region_backend_service.go @@ -1259,6 +1259,8 @@ func resourceComputeRegionBackendServiceUpdate(d *schema.ResourceData, meta inte if err != nil { return fmt.Errorf("Error updating RegionBackendService %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionBackendService %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_disk.go b/google-beta/resource_compute_region_disk.go index 641e7fc384..8edf192a45 100644 --- a/google-beta/resource_compute_region_disk.go +++ b/google-beta/resource_compute_region_disk.go @@ -512,6 +512,8 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating RegionDisk %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionDisk %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -541,6 +543,8 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating RegionDisk %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionDisk %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_health_check.go b/google-beta/resource_compute_region_health_check.go index 17c381ffdf..88647fd6c8 100644 --- a/google-beta/resource_compute_region_health_check.go +++ b/google-beta/resource_compute_region_health_check.go @@ -823,6 +823,8 @@ func resourceComputeRegionHealthCheckUpdate(d *schema.ResourceData, meta interfa if err != nil { return fmt.Errorf("Error updating RegionHealthCheck %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionHealthCheck %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_per_instance_config.go b/google-beta/resource_compute_region_per_instance_config.go index 519d6f5b23..ab6520e101 100644 --- a/google-beta/resource_compute_region_per_instance_config.go +++ b/google-beta/resource_compute_region_per_instance_config.go @@ -309,6 +309,8 @@ func resourceComputeRegionPerInstanceConfigUpdate(d *schema.ResourceData, meta i if err != nil { return fmt.Errorf("Error updating RegionPerInstanceConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionPerInstanceConfig %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_target_http_proxy.go b/google-beta/resource_compute_region_target_http_proxy.go index 6a2d66daab..b61f37f6e6 100644 --- a/google-beta/resource_compute_region_target_http_proxy.go +++ b/google-beta/resource_compute_region_target_http_proxy.go @@ -239,6 +239,8 @@ func resourceComputeRegionTargetHttpProxyUpdate(d *schema.ResourceData, meta int res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating RegionTargetHttpProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionTargetHttpProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_target_https_proxy.go b/google-beta/resource_compute_region_target_https_proxy.go index a745b5f6ac..c6e83821a4 100644 --- a/google-beta/resource_compute_region_target_https_proxy.go +++ b/google-beta/resource_compute_region_target_https_proxy.go @@ -259,6 +259,8 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating RegionTargetHttpsProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionTargetHttpsProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -287,6 +289,8 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating RegionTargetHttpsProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionTargetHttpsProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_region_url_map.go b/google-beta/resource_compute_region_url_map.go index db8e30583d..1c4168d365 100644 --- a/google-beta/resource_compute_region_url_map.go +++ b/google-beta/resource_compute_region_url_map.go @@ -1968,6 +1968,8 @@ func resourceComputeRegionUrlMapUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return fmt.Errorf("Error updating RegionUrlMap %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RegionUrlMap %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_reservation.go b/google-beta/resource_compute_reservation.go index 1358013157..be27c9b2cf 100644 --- a/google-beta/resource_compute_reservation.go +++ b/google-beta/resource_compute_reservation.go @@ -363,6 +363,8 @@ func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Reservation %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Reservation %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_router.go b/google-beta/resource_compute_router.go index c54ea26447..57128f493d 100644 --- a/google-beta/resource_compute_router.go +++ b/google-beta/resource_compute_router.go @@ -342,6 +342,8 @@ func resourceComputeRouterUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return fmt.Errorf("Error updating Router %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Router %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_router_bgp_peer.go b/google-beta/resource_compute_router_bgp_peer.go index 15ad4b4088..ad4b05cd7a 100644 --- a/google-beta/resource_compute_router_bgp_peer.go +++ b/google-beta/resource_compute_router_bgp_peer.go @@ -395,6 +395,8 @@ func resourceComputeRouterBgpPeerUpdate(d *schema.ResourceData, meta interface{} if err != nil { return fmt.Errorf("Error updating RouterBgpPeer %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RouterBgpPeer %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_router_nat.go b/google-beta/resource_compute_router_nat.go index 4f14e271d1..74da8b167e 100644 --- a/google-beta/resource_compute_router_nat.go +++ b/google-beta/resource_compute_router_nat.go @@ -596,6 +596,8 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er if err != nil { return fmt.Errorf("Error updating RouterNat %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating RouterNat %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_snapshot.go b/google-beta/resource_compute_snapshot.go index d2bd86071d..817b0bde83 100644 --- a/google-beta/resource_compute_snapshot.go +++ b/google-beta/resource_compute_snapshot.go @@ -382,6 +382,8 @@ func resourceComputeSnapshotUpdate(d *schema.ResourceData, meta interface{}) err res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Snapshot %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Snapshot %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_ssl_policy.go b/google-beta/resource_compute_ssl_policy.go index 6b4c7ed885..ac7b34241a 100644 --- a/google-beta/resource_compute_ssl_policy.go +++ b/google-beta/resource_compute_ssl_policy.go @@ -324,6 +324,8 @@ func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) er if err != nil { return fmt.Errorf("Error updating SslPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating SslPolicy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_subnetwork.go b/google-beta/resource_compute_subnetwork.go index 40043d0224..6cc98876c0 100644 --- a/google-beta/resource_compute_subnetwork.go +++ b/google-beta/resource_compute_subnetwork.go @@ -502,6 +502,8 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Subnetwork %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -530,6 +532,8 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Subnetwork %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -569,6 +573,8 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Subnetwork %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -608,6 +614,8 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Subnetwork %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -647,6 +655,8 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Subnetwork %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_target_http_proxy.go b/google-beta/resource_compute_target_http_proxy.go index 757170d7ae..35e2404319 100644 --- a/google-beta/resource_compute_target_http_proxy.go +++ b/google-beta/resource_compute_target_http_proxy.go @@ -221,6 +221,8 @@ func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetHttpProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetHttpProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_target_https_proxy.go b/google-beta/resource_compute_target_https_proxy.go index 9b589c208b..e60c4adeef 100644 --- a/google-beta/resource_compute_target_https_proxy.go +++ b/google-beta/resource_compute_target_https_proxy.go @@ -279,6 +279,8 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetHttpsProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -307,6 +309,8 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetHttpsProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -335,6 +339,8 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetHttpsProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -363,6 +369,8 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetHttpsProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_target_ssl_proxy.go b/google-beta/resource_compute_target_ssl_proxy.go index 435a961641..de498f7440 100644 --- a/google-beta/resource_compute_target_ssl_proxy.go +++ b/google-beta/resource_compute_target_ssl_proxy.go @@ -276,6 +276,8 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetSslProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -304,6 +306,8 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetSslProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -332,6 +336,8 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetSslProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -360,6 +366,8 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetSslProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_target_tcp_proxy.go b/google-beta/resource_compute_target_tcp_proxy.go index c0eeb7358f..e4bc025453 100644 --- a/google-beta/resource_compute_target_tcp_proxy.go +++ b/google-beta/resource_compute_target_tcp_proxy.go @@ -238,6 +238,8 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetTcpProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetTcpProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( @@ -266,6 +268,8 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TargetTcpProxy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TargetTcpProxy %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_url_map.go b/google-beta/resource_compute_url_map.go index 4bdcf31d4c..e082a54cc0 100644 --- a/google-beta/resource_compute_url_map.go +++ b/google-beta/resource_compute_url_map.go @@ -3002,6 +3002,8 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return fmt.Errorf("Error updating UrlMap %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating UrlMap %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_compute_vpn_tunnel.go b/google-beta/resource_compute_vpn_tunnel.go index fb4b1e2998..acf68b57b0 100644 --- a/google-beta/resource_compute_vpn_tunnel.go +++ b/google-beta/resource_compute_vpn_tunnel.go @@ -630,6 +630,8 @@ func resourceComputeVpnTunnelUpdate(d *schema.ResourceData, meta interface{}) er res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating VpnTunnel %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating VpnTunnel %q: %#v", d.Id(), res) } err = computeOperationWaitTime( diff --git a/google-beta/resource_container_analysis_note.go b/google-beta/resource_container_analysis_note.go index 9c044a7b60..d718389639 100644 --- a/google-beta/resource_container_analysis_note.go +++ b/google-beta/resource_container_analysis_note.go @@ -410,10 +410,12 @@ func resourceContainerAnalysisNoteUpdate(d *schema.ResourceData, meta interface{ if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Note %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Note %q: %#v", d.Id(), res) } return resourceContainerAnalysisNoteRead(d, meta) diff --git a/google-beta/resource_container_analysis_occurrence.go b/google-beta/resource_container_analysis_occurrence.go index 974fdacf99..2b185a278c 100644 --- a/google-beta/resource_container_analysis_occurrence.go +++ b/google-beta/resource_container_analysis_occurrence.go @@ -349,10 +349,12 @@ func resourceContainerAnalysisOccurrenceUpdate(d *schema.ResourceData, meta inte if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Occurrence %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Occurrence %q: %#v", d.Id(), res) } return resourceContainerAnalysisOccurrenceRead(d, meta) diff --git a/google-beta/resource_data_catalog_entry.go b/google-beta/resource_data_catalog_entry.go index 68a07d522b..9adf100fe8 100644 --- a/google-beta/resource_data_catalog_entry.go +++ b/google-beta/resource_data_catalog_entry.go @@ -491,10 +491,12 @@ func resourceDataCatalogEntryUpdate(d *schema.ResourceData, meta interface{}) er if parts := regexp.MustCompile(`projects\/([^\/]+)\/`).FindStringSubmatch(url); parts != nil { project = parts[1] } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Entry %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Entry %q: %#v", d.Id(), res) } return resourceDataCatalogEntryRead(d, meta) diff --git a/google-beta/resource_data_catalog_entry_group.go b/google-beta/resource_data_catalog_entry_group.go index afdb74cb40..4bf293e6b7 100644 --- a/google-beta/resource_data_catalog_entry_group.go +++ b/google-beta/resource_data_catalog_entry_group.go @@ -215,10 +215,12 @@ func resourceDataCatalogEntryGroupUpdate(d *schema.ResourceData, meta interface{ if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating EntryGroup %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating EntryGroup %q: %#v", d.Id(), res) } return resourceDataCatalogEntryGroupRead(d, meta) diff --git a/google-beta/resource_data_catalog_tag.go b/google-beta/resource_data_catalog_tag.go index 81dcc2cc47..b30f43b2cf 100644 --- a/google-beta/resource_data_catalog_tag.go +++ b/google-beta/resource_data_catalog_tag.go @@ -267,10 +267,12 @@ func resourceDataCatalogTagUpdate(d *schema.ResourceData, meta interface{}) erro if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Tag %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Tag %q: %#v", d.Id(), res) } return resourceDataCatalogTagRead(d, meta) diff --git a/google-beta/resource_data_catalog_tag_template.go b/google-beta/resource_data_catalog_tag_template.go index d13946840d..de31d1be2b 100644 --- a/google-beta/resource_data_catalog_tag_template.go +++ b/google-beta/resource_data_catalog_tag_template.go @@ -294,10 +294,12 @@ func resourceDataCatalogTagTemplateUpdate(d *schema.ResourceData, meta interface if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TagTemplate %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TagTemplate %q: %#v", d.Id(), res) } return resourceDataCatalogTagTemplateRead(d, meta) diff --git a/google-beta/resource_data_fusion_instance.go b/google-beta/resource_data_fusion_instance.go index e56d25217c..b688f59b1a 100644 --- a/google-beta/resource_data_fusion_instance.go +++ b/google-beta/resource_data_fusion_instance.go @@ -419,6 +419,8 @@ func resourceDataFusionInstanceUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) } err = dataFusionOperationWaitTime( diff --git a/google-beta/resource_dataproc_autoscaling_policy.go b/google-beta/resource_dataproc_autoscaling_policy.go index 7bd2b2bc1c..b92fe9c033 100644 --- a/google-beta/resource_dataproc_autoscaling_policy.go +++ b/google-beta/resource_dataproc_autoscaling_policy.go @@ -379,10 +379,12 @@ func resourceDataprocAutoscalingPolicyUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating AutoscalingPolicy %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating AutoscalingPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating AutoscalingPolicy %q: %#v", d.Id(), res) } return resourceDataprocAutoscalingPolicyRead(d, meta) diff --git a/google-beta/resource_deployment_manager_deployment.go b/google-beta/resource_deployment_manager_deployment.go index 63de33eec6..7210570dba 100644 --- a/google-beta/resource_deployment_manager_deployment.go +++ b/google-beta/resource_deployment_manager_deployment.go @@ -351,6 +351,8 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Deployment %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Deployment %q: %#v", d.Id(), res) } err = deploymentManagerOperationWaitTime( @@ -402,6 +404,8 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Deployment %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Deployment %q: %#v", d.Id(), res) } err = deploymentManagerOperationWaitTime( diff --git a/google-beta/resource_dialogflow_agent.go b/google-beta/resource_dialogflow_agent.go index 410089c3db..9ca6deb601 100644 --- a/google-beta/resource_dialogflow_agent.go +++ b/google-beta/resource_dialogflow_agent.go @@ -380,10 +380,12 @@ func resourceDialogflowAgentUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Agent %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Agent %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Agent %q: %#v", d.Id(), res) } return resourceDialogflowAgentRead(d, meta) diff --git a/google-beta/resource_dialogflow_entity_type.go b/google-beta/resource_dialogflow_entity_type.go index fe25d33476..f78e825118 100644 --- a/google-beta/resource_dialogflow_entity_type.go +++ b/google-beta/resource_dialogflow_entity_type.go @@ -264,10 +264,12 @@ func resourceDialogflowEntityTypeUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating EntityType %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating EntityType %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating EntityType %q: %#v", d.Id(), res) } return resourceDialogflowEntityTypeRead(d, meta) diff --git a/google-beta/resource_dialogflow_intent.go b/google-beta/resource_dialogflow_intent.go index 006332b736..0ad2061483 100644 --- a/google-beta/resource_dialogflow_intent.go +++ b/google-beta/resource_dialogflow_intent.go @@ -436,10 +436,12 @@ func resourceDialogflowIntentUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Intent %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Intent %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Intent %q: %#v", d.Id(), res) } return resourceDialogflowIntentRead(d, meta) diff --git a/google-beta/resource_dns_managed_zone.go b/google-beta/resource_dns_managed_zone.go index c277e4e1bc..cc28e439ea 100644 --- a/google-beta/resource_dns_managed_zone.go +++ b/google-beta/resource_dns_managed_zone.go @@ -550,10 +550,12 @@ func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating ManagedZone %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ManagedZone %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ManagedZone %q: %#v", d.Id(), res) } return resourceDNSManagedZoneRead(d, meta) diff --git a/google-beta/resource_dns_policy.go b/google-beta/resource_dns_policy.go index 7dd7bee774..6baa3b985b 100644 --- a/google-beta/resource_dns_policy.go +++ b/google-beta/resource_dns_policy.go @@ -310,9 +310,11 @@ func resourceDNSPolicyUpdate(d *schema.ResourceData, meta interface{}) error { if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Policy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Policy %q: %#v", d.Id(), res) } d.SetPartial("alternative_name_server_config") diff --git a/google-beta/resource_filestore_instance.go b/google-beta/resource_filestore_instance.go index ff820d7ceb..e6c870f03e 100644 --- a/google-beta/resource_filestore_instance.go +++ b/google-beta/resource_filestore_instance.go @@ -395,6 +395,8 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) } err = filestoreOperationWaitTime( diff --git a/google-beta/resource_firebase_web_app.go b/google-beta/resource_firebase_web_app.go index b74fa50c56..15658fb70e 100644 --- a/google-beta/resource_firebase_web_app.go +++ b/google-beta/resource_firebase_web_app.go @@ -199,10 +199,12 @@ func resourceFirebaseWebAppUpdate(d *schema.ResourceData, meta interface{}) erro if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating WebApp %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating WebApp %q: %#v", d.Id(), res) } return resourceFirebaseWebAppRead(d, meta) diff --git a/google-beta/resource_game_services_game_server_cluster.go b/google-beta/resource_game_services_game_server_cluster.go index d14ff8cd6b..f415a7c9d4 100644 --- a/google-beta/resource_game_services_game_server_cluster.go +++ b/google-beta/resource_game_services_game_server_cluster.go @@ -304,6 +304,8 @@ func resourceGameServicesGameServerClusterUpdate(d *schema.ResourceData, meta in if err != nil { return fmt.Errorf("Error updating GameServerCluster %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GameServerCluster %q: %#v", d.Id(), res) } err = gameServicesOperationWaitTime( diff --git a/google-beta/resource_game_services_game_server_deployment.go b/google-beta/resource_game_services_game_server_deployment.go index 7ce3c7d5de..88b283b217 100644 --- a/google-beta/resource_game_services_game_server_deployment.go +++ b/google-beta/resource_game_services_game_server_deployment.go @@ -234,6 +234,8 @@ func resourceGameServicesGameServerDeploymentUpdate(d *schema.ResourceData, meta if err != nil { return fmt.Errorf("Error updating GameServerDeployment %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GameServerDeployment %q: %#v", d.Id(), res) } err = gameServicesOperationWaitTime( diff --git a/google-beta/resource_game_services_game_server_deployment_rollout.go b/google-beta/resource_game_services_game_server_deployment_rollout.go index 2159a5eb26..9460d3a7e9 100644 --- a/google-beta/resource_game_services_game_server_deployment_rollout.go +++ b/google-beta/resource_game_services_game_server_deployment_rollout.go @@ -210,6 +210,8 @@ func resourceGameServicesGameServerDeploymentRolloutUpdate(d *schema.ResourceDat if err != nil { return fmt.Errorf("Error updating GameServerDeploymentRollout %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GameServerDeploymentRollout %q: %#v", d.Id(), res) } err = gameServicesOperationWaitTime( diff --git a/google-beta/resource_game_services_realm.go b/google-beta/resource_game_services_realm.go index 8b6dca893a..824b5418e1 100644 --- a/google-beta/resource_game_services_realm.go +++ b/google-beta/resource_game_services_realm.go @@ -264,6 +264,8 @@ func resourceGameServicesRealmUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return fmt.Errorf("Error updating Realm %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Realm %q: %#v", d.Id(), res) } err = gameServicesOperationWaitTime( diff --git a/google-beta/resource_healthcare_dataset.go b/google-beta/resource_healthcare_dataset.go index 767c958343..f0889f0b7f 100644 --- a/google-beta/resource_healthcare_dataset.go +++ b/google-beta/resource_healthcare_dataset.go @@ -197,10 +197,12 @@ func resourceHealthcareDatasetUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Dataset %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Dataset %q: %#v", d.Id(), res) } return resourceHealthcareDatasetRead(d, meta) diff --git a/google-beta/resource_healthcare_dicom_store.go b/google-beta/resource_healthcare_dicom_store.go index c5f4896f20..e3a63c49cb 100644 --- a/google-beta/resource_healthcare_dicom_store.go +++ b/google-beta/resource_healthcare_dicom_store.go @@ -226,10 +226,12 @@ func resourceHealthcareDicomStoreUpdate(d *schema.ResourceData, meta interface{} if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating DicomStore %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating DicomStore %q: %#v", d.Id(), res) } return resourceHealthcareDicomStoreRead(d, meta) diff --git a/google-beta/resource_healthcare_fhir_store.go b/google-beta/resource_healthcare_fhir_store.go index 5d682a01ca..393db77c8b 100644 --- a/google-beta/resource_healthcare_fhir_store.go +++ b/google-beta/resource_healthcare_fhir_store.go @@ -427,10 +427,12 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating FhirStore %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating FhirStore %q: %#v", d.Id(), res) } return resourceHealthcareFhirStoreRead(d, meta) diff --git a/google-beta/resource_healthcare_hl7_v2_store.go b/google-beta/resource_healthcare_hl7_v2_store.go index 2f2b3df4dc..07e1bffb23 100644 --- a/google-beta/resource_healthcare_hl7_v2_store.go +++ b/google-beta/resource_healthcare_hl7_v2_store.go @@ -339,10 +339,12 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{} if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Hl7V2Store %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Hl7V2Store %q: %#v", d.Id(), res) } return resourceHealthcareHl7V2StoreRead(d, meta) diff --git a/google-beta/resource_identity_platform_default_supported_idp_config.go b/google-beta/resource_identity_platform_default_supported_idp_config.go index 4606c7cdc5..a9be3a4397 100644 --- a/google-beta/resource_identity_platform_default_supported_idp_config.go +++ b/google-beta/resource_identity_platform_default_supported_idp_config.go @@ -241,10 +241,12 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigUpdate(d *schema.ResourceD if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating DefaultSupportedIdpConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating DefaultSupportedIdpConfig %q: %#v", d.Id(), res) } return resourceIdentityPlatformDefaultSupportedIdpConfigRead(d, meta) diff --git a/google-beta/resource_identity_platform_inbound_saml_config.go b/google-beta/resource_identity_platform_inbound_saml_config.go index 5630a060bb..55f09f8872 100644 --- a/google-beta/resource_identity_platform_inbound_saml_config.go +++ b/google-beta/resource_identity_platform_inbound_saml_config.go @@ -309,10 +309,12 @@ func resourceIdentityPlatformInboundSamlConfigUpdate(d *schema.ResourceData, met if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating InboundSamlConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating InboundSamlConfig %q: %#v", d.Id(), res) } return resourceIdentityPlatformInboundSamlConfigRead(d, meta) diff --git a/google-beta/resource_identity_platform_oauth_idp_config.go b/google-beta/resource_identity_platform_oauth_idp_config.go index 64916ea5b1..875029cf3f 100644 --- a/google-beta/resource_identity_platform_oauth_idp_config.go +++ b/google-beta/resource_identity_platform_oauth_idp_config.go @@ -267,10 +267,12 @@ func resourceIdentityPlatformOauthIdpConfigUpdate(d *schema.ResourceData, meta i if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating OauthIdpConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating OauthIdpConfig %q: %#v", d.Id(), res) } return resourceIdentityPlatformOauthIdpConfigRead(d, meta) diff --git a/google-beta/resource_identity_platform_tenant.go b/google-beta/resource_identity_platform_tenant.go index 6b772bf174..b9dd7bcc3b 100644 --- a/google-beta/resource_identity_platform_tenant.go +++ b/google-beta/resource_identity_platform_tenant.go @@ -254,10 +254,12 @@ func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Tenant %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Tenant %q: %#v", d.Id(), res) } return resourceIdentityPlatformTenantRead(d, meta) diff --git a/google-beta/resource_identity_platform_tenant_default_supported_idp_config.go b/google-beta/resource_identity_platform_tenant_default_supported_idp_config.go index f1bde3f93b..500d151adc 100644 --- a/google-beta/resource_identity_platform_tenant_default_supported_idp_config.go +++ b/google-beta/resource_identity_platform_tenant_default_supported_idp_config.go @@ -247,10 +247,12 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigUpdate(d *schema.Res if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TenantDefaultSupportedIdpConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TenantDefaultSupportedIdpConfig %q: %#v", d.Id(), res) } return resourceIdentityPlatformTenantDefaultSupportedIdpConfigRead(d, meta) diff --git a/google-beta/resource_identity_platform_tenant_inbound_saml_config.go b/google-beta/resource_identity_platform_tenant_inbound_saml_config.go index a58c954722..0dd3c64388 100644 --- a/google-beta/resource_identity_platform_tenant_inbound_saml_config.go +++ b/google-beta/resource_identity_platform_tenant_inbound_saml_config.go @@ -315,10 +315,12 @@ func resourceIdentityPlatformTenantInboundSamlConfigUpdate(d *schema.ResourceDat if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TenantInboundSamlConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TenantInboundSamlConfig %q: %#v", d.Id(), res) } return resourceIdentityPlatformTenantInboundSamlConfigRead(d, meta) diff --git a/google-beta/resource_identity_platform_tenant_oauth_idp_config.go b/google-beta/resource_identity_platform_tenant_oauth_idp_config.go index 2cc46ffa7c..4aafd1613c 100644 --- a/google-beta/resource_identity_platform_tenant_oauth_idp_config.go +++ b/google-beta/resource_identity_platform_tenant_oauth_idp_config.go @@ -273,10 +273,12 @@ func resourceIdentityPlatformTenantOauthIdpConfigUpdate(d *schema.ResourceData, if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating TenantOauthIdpConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating TenantOauthIdpConfig %q: %#v", d.Id(), res) } return resourceIdentityPlatformTenantOauthIdpConfigRead(d, meta) diff --git a/google-beta/resource_kms_crypto_key.go b/google-beta/resource_kms_crypto_key.go index bec4f71d8b..840e0147be 100644 --- a/google-beta/resource_kms_crypto_key.go +++ b/google-beta/resource_kms_crypto_key.go @@ -289,10 +289,12 @@ func resourceKMSCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error if parts := regexp.MustCompile(`projects\/([^\/]+)\/`).FindStringSubmatch(url); parts != nil { project = parts[1] } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating CryptoKey %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating CryptoKey %q: %#v", d.Id(), res) } return resourceKMSCryptoKeyRead(d, meta) diff --git a/google-beta/resource_logging_metric.go b/google-beta/resource_logging_metric.go index d3803a957c..82c13d1ff4 100644 --- a/google-beta/resource_logging_metric.go +++ b/google-beta/resource_logging_metric.go @@ -467,10 +467,12 @@ func resourceLoggingMetricUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Metric %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Metric %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Metric %q: %#v", d.Id(), res) } return resourceLoggingMetricRead(d, meta) diff --git a/google-beta/resource_memcache_instance.go b/google-beta/resource_memcache_instance.go index aaaf0e2990..d8a632f007 100644 --- a/google-beta/resource_memcache_instance.go +++ b/google-beta/resource_memcache_instance.go @@ -356,6 +356,8 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) } err = memcacheOperationWaitTime( diff --git a/google-beta/resource_monitoring_alert_policy.go b/google-beta/resource_monitoring_alert_policy.go index 0ad551b71d..eee770478d 100644 --- a/google-beta/resource_monitoring_alert_policy.go +++ b/google-beta/resource_monitoring_alert_policy.go @@ -985,10 +985,12 @@ func resourceMonitoringAlertPolicyUpdate(d *schema.ResourceData, meta interface{ if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) if err != nil { return fmt.Errorf("Error updating AlertPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating AlertPolicy %q: %#v", d.Id(), res) } return resourceMonitoringAlertPolicyRead(d, meta) diff --git a/google-beta/resource_monitoring_group.go b/google-beta/resource_monitoring_group.go index 267fd12407..b495275511 100644 --- a/google-beta/resource_monitoring_group.go +++ b/google-beta/resource_monitoring_group.go @@ -253,10 +253,12 @@ func resourceMonitoringGroupUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Group %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) if err != nil { return fmt.Errorf("Error updating Group %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Group %q: %#v", d.Id(), res) } return resourceMonitoringGroupRead(d, meta) diff --git a/google-beta/resource_monitoring_metric_descriptor.go b/google-beta/resource_monitoring_metric_descriptor.go index 9c890d5687..1c92d48dd0 100644 --- a/google-beta/resource_monitoring_metric_descriptor.go +++ b/google-beta/resource_monitoring_metric_descriptor.go @@ -420,10 +420,12 @@ func resourceMonitoringMetricDescriptorUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating MetricDescriptor %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) + res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) if err != nil { return fmt.Errorf("Error updating MetricDescriptor %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating MetricDescriptor %q: %#v", d.Id(), res) } err = PollingWaitTime(resourceMonitoringMetricDescriptorPollRead(d, meta), PollCheckForExistence, "Updating MetricDescriptor", d.Timeout(schema.TimeoutUpdate), 20) diff --git a/google-beta/resource_monitoring_notification_channel.go b/google-beta/resource_monitoring_notification_channel.go index 0ce3f9435e..7ae4d74335 100644 --- a/google-beta/resource_monitoring_notification_channel.go +++ b/google-beta/resource_monitoring_notification_channel.go @@ -378,10 +378,12 @@ func resourceMonitoringNotificationChannelUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating NotificationChannel %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) if err != nil { return fmt.Errorf("Error updating NotificationChannel %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating NotificationChannel %q: %#v", d.Id(), res) } return resourceMonitoringNotificationChannelRead(d, meta) diff --git a/google-beta/resource_monitoring_service.go b/google-beta/resource_monitoring_service.go index 9be668e96b..5aca88ca36 100644 --- a/google-beta/resource_monitoring_service.go +++ b/google-beta/resource_monitoring_service.go @@ -232,10 +232,12 @@ func resourceMonitoringServiceUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) if err != nil { return fmt.Errorf("Error updating Service %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Service %q: %#v", d.Id(), res) } return resourceMonitoringServiceRead(d, meta) diff --git a/google-beta/resource_monitoring_slo.go b/google-beta/resource_monitoring_slo.go index 18988ebabf..e531e7bfa4 100644 --- a/google-beta/resource_monitoring_slo.go +++ b/google-beta/resource_monitoring_slo.go @@ -934,10 +934,12 @@ func resourceMonitoringSloUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Slo %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Slo %q: %#v", d.Id(), res) } return resourceMonitoringSloRead(d, meta) diff --git a/google-beta/resource_monitoring_uptime_check_config.go b/google-beta/resource_monitoring_uptime_check_config.go index 3856aeb6da..ab00d5e0ac 100644 --- a/google-beta/resource_monitoring_uptime_check_config.go +++ b/google-beta/resource_monitoring_uptime_check_config.go @@ -576,10 +576,12 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), isMonitoringConcurrentEditError) if err != nil { return fmt.Errorf("Error updating UptimeCheckConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating UptimeCheckConfig %q: %#v", d.Id(), res) } return resourceMonitoringUptimeCheckConfigRead(d, meta) diff --git a/google-beta/resource_network_management_connectivity_test_resource.go b/google-beta/resource_network_management_connectivity_test_resource.go index 34e66ecbfc..c52598bb38 100644 --- a/google-beta/resource_network_management_connectivity_test_resource.go +++ b/google-beta/resource_network_management_connectivity_test_resource.go @@ -464,6 +464,8 @@ func resourceNetworkManagementConnectivityTestUpdate(d *schema.ResourceData, met if err != nil { return fmt.Errorf("Error updating ConnectivityTest %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ConnectivityTest %q: %#v", d.Id(), res) } err = networkManagementOperationWaitTime( diff --git a/google-beta/resource_notebooks_environment.go b/google-beta/resource_notebooks_environment.go index 5ec3f87456..64819e01b6 100644 --- a/google-beta/resource_notebooks_environment.go +++ b/google-beta/resource_notebooks_environment.go @@ -308,6 +308,8 @@ func resourceNotebooksEnvironmentUpdate(d *schema.ResourceData, meta interface{} if err != nil { return fmt.Errorf("Error updating Environment %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Environment %q: %#v", d.Id(), res) } err = notebooksOperationWaitTime( diff --git a/google-beta/resource_notebooks_instance.go b/google-beta/resource_notebooks_instance.go index 5244e99f89..568633947f 100644 --- a/google-beta/resource_notebooks_instance.go +++ b/google-beta/resource_notebooks_instance.go @@ -610,6 +610,8 @@ func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) e res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) } err = notebooksOperationWaitTime( diff --git a/google-beta/resource_notebooks_location.go b/google-beta/resource_notebooks_location.go index b3125a8d0c..8840d76f9a 100644 --- a/google-beta/resource_notebooks_location.go +++ b/google-beta/resource_notebooks_location.go @@ -178,6 +178,8 @@ func resourceNotebooksLocationUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return fmt.Errorf("Error updating Location %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Location %q: %#v", d.Id(), res) } err = notebooksOperationWaitTime( diff --git a/google-beta/resource_os_config_guest_policies.go b/google-beta/resource_os_config_guest_policies.go index 5f727c99d0..4c2c3e107f 100644 --- a/google-beta/resource_os_config_guest_policies.go +++ b/google-beta/resource_os_config_guest_policies.go @@ -1065,10 +1065,12 @@ func resourceOSConfigGuestPoliciesUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating GuestPolicies %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating GuestPolicies %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating GuestPolicies %q: %#v", d.Id(), res) } return resourceOSConfigGuestPoliciesRead(d, meta) diff --git a/google-beta/resource_os_login_ssh_public_key.go b/google-beta/resource_os_login_ssh_public_key.go index 627b10a86f..7d11a472b1 100644 --- a/google-beta/resource_os_login_ssh_public_key.go +++ b/google-beta/resource_os_login_ssh_public_key.go @@ -183,10 +183,12 @@ func resourceOSLoginSSHPublicKeyUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating SSHPublicKey %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating SSHPublicKey %q: %#v", d.Id(), res) } return resourceOSLoginSSHPublicKeyRead(d, meta) diff --git a/google-beta/resource_pubsub_subscription.go b/google-beta/resource_pubsub_subscription.go index fbecfd0e57..70a70c7c26 100644 --- a/google-beta/resource_pubsub_subscription.go +++ b/google-beta/resource_pubsub_subscription.go @@ -577,10 +577,12 @@ func resourcePubsubSubscriptionUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Subscription %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Subscription %q: %#v", d.Id(), res) } return resourcePubsubSubscriptionRead(d, meta) diff --git a/google-beta/resource_pubsub_topic.go b/google-beta/resource_pubsub_topic.go index e446a8cbaa..5519dfc8bf 100644 --- a/google-beta/resource_pubsub_topic.go +++ b/google-beta/resource_pubsub_topic.go @@ -273,10 +273,12 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), pubsubTopicProjectNotReady) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate), pubsubTopicProjectNotReady) if err != nil { return fmt.Errorf("Error updating Topic %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Topic %q: %#v", d.Id(), res) } return resourcePubsubTopicRead(d, meta) diff --git a/google-beta/resource_redis_instance.go b/google-beta/resource_redis_instance.go index 6b6839cb51..2a11a888cd 100644 --- a/google-beta/resource_redis_instance.go +++ b/google-beta/resource_redis_instance.go @@ -487,6 +487,8 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) } err = redisOperationWaitTime( diff --git a/google-beta/resource_secret_manager_secret.go b/google-beta/resource_secret_manager_secret.go index 9e897b82f0..e47be4bdf5 100644 --- a/google-beta/resource_secret_manager_secret.go +++ b/google-beta/resource_secret_manager_secret.go @@ -247,10 +247,12 @@ func resourceSecretManagerSecretUpdate(d *schema.ResourceData, meta interface{}) if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Secret %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Secret %q: %#v", d.Id(), res) } return resourceSecretManagerSecretRead(d, meta) diff --git a/google-beta/resource_security_center_source.go b/google-beta/resource_security_center_source.go index 57d622d945..cf39bfa6b9 100644 --- a/google-beta/resource_security_center_source.go +++ b/google-beta/resource_security_center_source.go @@ -199,10 +199,12 @@ func resourceSecurityCenterSourceUpdate(d *schema.ResourceData, meta interface{} if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Source %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Source %q: %#v", d.Id(), res) } return resourceSecurityCenterSourceRead(d, meta) diff --git a/google-beta/resource_security_scanner_scan_config.go b/google-beta/resource_security_scanner_scan_config.go index fc4a3578c3..19ca2d37d5 100644 --- a/google-beta/resource_security_scanner_scan_config.go +++ b/google-beta/resource_security_scanner_scan_config.go @@ -471,10 +471,12 @@ func resourceSecurityScannerScanConfigUpdate(d *schema.ResourceData, meta interf if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ScanConfig %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ScanConfig %q: %#v", d.Id(), res) } return resourceSecurityScannerScanConfigRead(d, meta) diff --git a/google-beta/resource_service_directory_endpoint.go b/google-beta/resource_service_directory_endpoint.go index 64da56d2ea..39f8f6c83b 100644 --- a/google-beta/resource_service_directory_endpoint.go +++ b/google-beta/resource_service_directory_endpoint.go @@ -215,10 +215,12 @@ func resourceServiceDirectoryEndpointUpdate(d *schema.ResourceData, meta interfa if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Endpoint %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Endpoint %q: %#v", d.Id(), res) } return resourceServiceDirectoryEndpointRead(d, meta) diff --git a/google-beta/resource_service_directory_namespace.go b/google-beta/resource_service_directory_namespace.go index 80560b47cc..87db62b989 100644 --- a/google-beta/resource_service_directory_namespace.go +++ b/google-beta/resource_service_directory_namespace.go @@ -186,10 +186,12 @@ func resourceServiceDirectoryNamespaceUpdate(d *schema.ResourceData, meta interf if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Namespace %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Namespace %q: %#v", d.Id(), res) } return resourceServiceDirectoryNamespaceRead(d, meta) diff --git a/google-beta/resource_service_directory_service.go b/google-beta/resource_service_directory_service.go index 5963dd230f..1dc6ba5214 100644 --- a/google-beta/resource_service_directory_service.go +++ b/google-beta/resource_service_directory_service.go @@ -162,10 +162,12 @@ func resourceServiceDirectoryServiceUpdate(d *schema.ResourceData, meta interfac if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Service %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Service %q: %#v", d.Id(), res) } return resourceServiceDirectoryServiceRead(d, meta) diff --git a/google-beta/resource_service_usage_consumer_quota_override.go b/google-beta/resource_service_usage_consumer_quota_override.go index 74243fdb8b..9b8605fcc8 100644 --- a/google-beta/resource_service_usage_consumer_quota_override.go +++ b/google-beta/resource_service_usage_consumer_quota_override.go @@ -242,6 +242,8 @@ func resourceServiceUsageConsumerQuotaOverrideUpdate(d *schema.ResourceData, met if err != nil { return fmt.Errorf("Error updating ConsumerQuotaOverride %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ConsumerQuotaOverride %q: %#v", d.Id(), res) } err = serviceUsageOperationWaitTime( diff --git a/google-beta/resource_source_repo_repository.go b/google-beta/resource_source_repo_repository.go index 721eff7983..bab3675ac8 100644 --- a/google-beta/resource_source_repo_repository.go +++ b/google-beta/resource_source_repo_repository.go @@ -247,10 +247,12 @@ func resourceSourceRepoRepositoryUpdate(d *schema.ResourceData, meta interface{} if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PATCH", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Repository %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Repository %q: %#v", d.Id(), res) } return resourceSourceRepoRepositoryRead(d, meta) diff --git a/google-beta/resource_spanner_instance.go b/google-beta/resource_spanner_instance.go index bc2c50db4b..fb7f338248 100644 --- a/google-beta/resource_spanner_instance.go +++ b/google-beta/resource_spanner_instance.go @@ -310,6 +310,8 @@ func resourceSpannerInstanceUpdate(d *schema.ResourceData, meta interface{}) err if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) } err = spannerOperationWaitTime( diff --git a/google-beta/resource_sql_database.go b/google-beta/resource_sql_database.go index 7590d81473..f345b1f8e9 100644 --- a/google-beta/resource_sql_database.go +++ b/google-beta/resource_sql_database.go @@ -253,6 +253,8 @@ func resourceSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { if err != nil { return fmt.Errorf("Error updating Database %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Database %q: %#v", d.Id(), res) } err = sqlAdminOperationWaitTime( diff --git a/google-beta/resource_storage_bucket_access_control.go b/google-beta/resource_storage_bucket_access_control.go index 9d4cc0e705..b45ac2291e 100644 --- a/google-beta/resource_storage_bucket_access_control.go +++ b/google-beta/resource_storage_bucket_access_control.go @@ -210,10 +210,12 @@ func resourceStorageBucketAccessControlUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating BucketAccessControl %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating BucketAccessControl %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating BucketAccessControl %q: %#v", d.Id(), res) } return resourceStorageBucketAccessControlRead(d, meta) diff --git a/google-beta/resource_storage_default_object_access_control.go b/google-beta/resource_storage_default_object_access_control.go index 96c4f7612c..398aca6035 100644 --- a/google-beta/resource_storage_default_object_access_control.go +++ b/google-beta/resource_storage_default_object_access_control.go @@ -260,10 +260,12 @@ func resourceStorageDefaultObjectAccessControlUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating DefaultObjectAccessControl %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating DefaultObjectAccessControl %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating DefaultObjectAccessControl %q: %#v", d.Id(), res) } return resourceStorageDefaultObjectAccessControlRead(d, meta) diff --git a/google-beta/resource_storage_hmac_key.go b/google-beta/resource_storage_hmac_key.go index 4bda3e0976..06096cb8d5 100644 --- a/google-beta/resource_storage_hmac_key.go +++ b/google-beta/resource_storage_hmac_key.go @@ -241,9 +241,11 @@ func resourceStorageHmacKeyUpdate(d *schema.ResourceData, meta interface{}) erro if err != nil { return err } - _, err = sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating HmacKey %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating HmacKey %q: %#v", d.Id(), res) } d.SetPartial("state") diff --git a/google-beta/resource_storage_object_access_control.go b/google-beta/resource_storage_object_access_control.go index 6f0f806c4a..c81764d9a7 100644 --- a/google-beta/resource_storage_object_access_control.go +++ b/google-beta/resource_storage_object_access_control.go @@ -263,10 +263,12 @@ func resourceStorageObjectAccessControlUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating ObjectAccessControl %q: %#v", d.Id(), obj) - _, err = sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) + res, err := sendRequestWithTimeout(config, "PUT", "", url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating ObjectAccessControl %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ObjectAccessControl %q: %#v", d.Id(), res) } return resourceStorageObjectAccessControlRead(d, meta) diff --git a/google-beta/resource_tpu_node.go b/google-beta/resource_tpu_node.go index 3341467f40..00fe56cc6b 100644 --- a/google-beta/resource_tpu_node.go +++ b/google-beta/resource_tpu_node.go @@ -380,6 +380,8 @@ func resourceTPUNodeUpdate(d *schema.ResourceData, meta interface{}) error { res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutUpdate)) if err != nil { return fmt.Errorf("Error updating Node %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Node %q: %#v", d.Id(), res) } err = tpuOperationWaitTime( diff --git a/website/docs/r/compute_organization_security_policy.html.markdown b/website/docs/r/compute_organization_security_policy.html.markdown new file mode 100644 index 0000000000..fdb3a1bce9 --- /dev/null +++ b/website/docs/r/compute_organization_security_policy.html.markdown @@ -0,0 +1,117 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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: "Compute Engine" +layout: "google" +page_title: "Google: google_compute_organization_security_policy" +sidebar_current: "docs-google-compute-organization-security-policy" +description: |- + Organization security policies are used to control incoming/outgoing traffic. +--- + +# google\_compute\_organization\_security\_policy + +Organization security policies are used to control incoming/outgoing traffic. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + +To get more information about OrganizationSecurityPolicy, see: + +* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies) +* How-to Guides + * [Creating a firewall policy](https://cloud.google.com/vpc/docs/using-firewall-policies#create-policy) + + +## Example Usage - Organization Security Policy Basic + + +```hcl +resource "google_compute_organization_security_policy" "policy" { + provider = "google-beta" + + display_name = "tf-test%{random_suffix}" + parent = "organizations/123456789" +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `display_name` - + (Required) + A textual name of the security policy. + +* `parent` - + (Required) + The parent of this OrganizationSecurityPolicy in the Cloud Resource Hierarchy. + Format: organizations/{organization_id} or folders/{folder_id} + + +- - - + + +* `description` - + (Optional) + A textual description for the organization security policy. + +* `type` - + (Optional) + The type indicates the intended use of the security policy. + For organization security policies, the only supported type + is "FIREWALL". + Default value is `FIREWALL`. + Possible values are `FIREWALL`. + + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `id` - an identifier for the resource with format `locations/global/securityPolicies/{{policy_id}}` + +* `fingerprint` - + Fingerprint of this resource. This field is used internally during + updates of this resource. + +* `policy_id` - + The unique identifier for the resource. This identifier is defined by the server. + + +## Timeouts + +This resource provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - Default is 4 minutes. +- `update` - Default is 4 minutes. +- `delete` - Default is 4 minutes. + +## Import + +OrganizationSecurityPolicy can be imported using any of these accepted formats: + +``` +$ terraform import -provider=google-beta google_compute_organization_security_policy.default locations/global/securityPolicies/{{policy_id}} +$ terraform import -provider=google-beta google_compute_organization_security_policy.default {{policy_id}} +``` + +-> If you're importing a resource with beta features, make sure to include `-provider=google-beta` +as an argument so that Terraform uses the correct provider to import your resource. diff --git a/website/docs/r/compute_organization_security_policy_association.html.markdown b/website/docs/r/compute_organization_security_policy_association.html.markdown new file mode 100644 index 0000000000..905811706a --- /dev/null +++ b/website/docs/r/compute_organization_security_policy_association.html.markdown @@ -0,0 +1,134 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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: "Compute Engine" +layout: "google" +page_title: "Google: google_compute_organization_security_policy_association" +sidebar_current: "docs-google-compute-organization-security-policy-association" +description: |- + An association for the OrganizationSecurityPolicy. +--- + +# google\_compute\_organization\_security\_policy\_association + +An association for the OrganizationSecurityPolicy. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + +To get more information about OrganizationSecurityPolicyAssociation, see: + +* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies/addAssociation) +* How-to Guides + * [Associating a policy with the organization or folder](https://cloud.google.com/vpc/docs/using-firewall-policies#associate) + + +## Example Usage - Organization Security Policy Association Basic + + +```hcl +resource "google_compute_organization_security_policy" "policy" { + provider = "google-beta" + + display_name = "tf-test%{random_suffix}" + parent = "organizations/123456789" +} + +resource "google_compute_organization_security_policy_rule" "policy" { + provider = "google-beta" + + policy_id = google_compute_organization_security_policy.policy.id + action = "allow" + + direction = "INGRESS" + enable_logging = true + match { + config { + src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"] + layer4_config { + ip_protocol = "tcp" + ports = ["22"] + } + layer4_config { + ip_protocol = "icmp" + } + } + } + priority = 100 +} + +resource "google_compute_organization_security_policy_association" "policy" { + provider = "google-beta" + + name = "tf-test%{random_suffix}" + attachment_id = google_compute_organization_security_policy.policy.parent + policy_id = google_compute_organization_security_policy.policy.id +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `name` - + (Required) + The name for an association. + +* `attachment_id` - + (Required) + The resource that the security policy is attached to. + +* `policy_id` - + (Required) + The security policy ID of the association. + + +- - - + + + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `id` - an identifier for the resource with format `{{policy_id}}/association/{{name}}` + +* `display_name` - + The display name of the security policy of the association. + + +## Timeouts + +This resource provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - Default is 4 minutes. +- `delete` - Default is 4 minutes. + +## Import + +OrganizationSecurityPolicyAssociation can be imported using any of these accepted formats: + +``` +$ terraform import -provider=google-beta google_compute_organization_security_policy_association.default {{policy_id}}/association/{{name}} +$ terraform import -provider=google-beta google_compute_organization_security_policy_association.default {{policy_id}}/{{name}} +``` + +-> If you're importing a resource with beta features, make sure to include `-provider=google-beta` +as an argument so that Terraform uses the correct provider to import your resource. diff --git a/website/docs/r/compute_organization_security_policy_rule.html.markdown b/website/docs/r/compute_organization_security_policy_rule.html.markdown new file mode 100644 index 0000000000..97140c7468 --- /dev/null +++ b/website/docs/r/compute_organization_security_policy_rule.html.markdown @@ -0,0 +1,219 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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: "Compute Engine" +layout: "google" +page_title: "Google: google_compute_organization_security_policy_rule" +sidebar_current: "docs-google-compute-organization-security-policy-rule" +description: |- + A rule for the OrganizationSecurityPolicy. +--- + +# google\_compute\_organization\_security\_policy\_rule + +A rule for the OrganizationSecurityPolicy. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + +To get more information about OrganizationSecurityPolicyRule, see: + +* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies/addRule) +* How-to Guides + * [Creating firewall rules](https://cloud.google.com/vpc/docs/using-firewall-policies#create-rules) + + +## Example Usage - Organization Security Policy Rule Basic + + +```hcl +resource "google_compute_organization_security_policy" "policy" { + provider = "google-beta" + + display_name = "tf-test%{random_suffix}" + parent = "organizations/123456789" +} + +resource "google_compute_organization_security_policy_rule" "policy" { + provider = "google-beta" + + policy_id = google_compute_organization_security_policy.policy.id + action = "allow" + + direction = "INGRESS" + enable_logging = true + match { + config { + src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"] + layer4_config { + ip_protocol = "tcp" + ports = ["22"] + } + layer4_config { + ip_protocol = "icmp" + } + } + } + priority = 100 +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `priority` - + (Required) + An integer indicating the priority of a rule in the list. The priority must be a value + between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the + highest priority and 2147483647 is the lowest prority. + +* `match` - + (Required) + A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced. + Structure is documented below. + +* `action` - + (Required) + The Action to perform when the client connection triggers the rule. Can currently be either + "allow", "deny" or "goto_next". + +* `policy_id` - + (Required) + The ID of the OrganizationSecurityPolicy this rule applies to. + + +The `match` block supports: + +* `description` - + (Optional) + A description of the rule. + +* `versioned_expr` - + (Optional) + Preconfigured versioned expression. For organization security policy rules, + the only supported type is "FIREWALL". + Default value is `FIREWALL`. + Possible values are `FIREWALL`. + +* `config` - + (Required) + The configuration options for matching the rule. + Structure is documented below. + + +The `config` block supports: + +* `src_ip_ranges` - + (Optional) + Source IP address range in CIDR format. Required for + INGRESS rules. + +* `dest_ip_ranges` - + (Optional) + Destination IP address range in CIDR format. Required for + EGRESS rules. + +* `layer4_config` - + (Required) + Pairs of IP protocols and ports that the rule should match. + Structure is documented below. + + +The `layer4_config` block supports: + +* `ip_protocol` - + (Required) + The IP protocol to which this rule applies. The protocol + type is required when creating a firewall rule. + This value can either be one of the following well + known protocol strings (tcp, udp, icmp, esp, ah, ipip, sctp), + or the IP protocol number. + +* `ports` - + (Optional) + An optional list of ports to which this rule applies. This field + is only applicable for UDP or TCP protocol. Each entry must be + either an integer or a range. If not specified, this rule + applies to connections through any port. + Example inputs include: ["22"], ["80","443"], and + ["12345-12349"]. + +- - - + + +* `description` - + (Optional) + A description of the rule. + +* `preview` - + (Optional) + If set to true, the specified action is not enforced. + +* `direction` - + (Optional) + The direction in which this rule applies. If unspecified an INGRESS rule is created. + Possible values are `INGRESS` and `EGRESS`. + +* `target_resources` - + (Optional) + A list of network resource URLs to which this rule applies. + This field allows you to control which network's VMs get + this rule. If this field is left blank, all VMs + within the organization will receive the rule. + +* `enable_logging` - + (Optional) + Denotes whether to enable logging for a particular rule. + If logging is enabled, logs will be exported to the + configured export destination in Stackdriver. + +* `target_service_accounts` - + (Optional) + A list of service accounts indicating the sets of + instances that are applied with this rule. + + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `id` - an identifier for the resource with format `{{policy_id}}/priority/{{priority}}` + + +## Timeouts + +This resource provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - Default is 4 minutes. +- `update` - Default is 4 minutes. +- `delete` - Default is 4 minutes. + +## Import + +OrganizationSecurityPolicyRule can be imported using any of these accepted formats: + +``` +$ terraform import -provider=google-beta google_compute_organization_security_policy_rule.default {{policy_id}}/priority/{{priority}} +$ terraform import -provider=google-beta google_compute_organization_security_policy_rule.default {{policy_id}}/{{priority}} +``` + +-> If you're importing a resource with beta features, make sure to include `-provider=google-beta` +as an argument so that Terraform uses the correct provider to import your resource. diff --git a/website/google.erb b/website/google.erb index cb27eb6441..ba943ea26d 100644 --- a/website/google.erb +++ b/website/google.erb @@ -1523,6 +1523,18 @@ google_compute_node_template +
  • + google_compute_organization_security_policy +
  • + +
  • + google_compute_organization_security_policy_association +
  • + +
  • + google_compute_organization_security_policy_rule +
  • +
  • google_compute_packet_mirroring