From abc6dd889e899faa2f238a8d8f25d7009dfc9c0f Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 20 Apr 2023 23:26:27 +0000 Subject: [PATCH] Add support for Database Migration Services - Connection Profile resource (#7447) Signed-off-by: Modular Magician --- .changelog/7447.txt | 3 + google/config.go | 377 +-- google/config_test_utils.go | 1 + .../database_migration_service_operation.go | 62 + google/framework_config.go | 9 + google/framework_provider.go | 179 +- google/provider.go | 11 +- google/provider_model.go | 173 +- ...se_migration_service_connection_profile.go | 2440 +++++++++++++++++ ...rvice_connection_profile_generated_test.go | 339 +++ ...service_connection_profile_sweeper_test.go | 128 + ...gration_service_connection_profile_test.go | 78 + ...n_service_connection_profile.html.markdown | 698 +++++ 13 files changed, 4140 insertions(+), 358 deletions(-) create mode 100644 .changelog/7447.txt create mode 100644 google/database_migration_service_operation.go create mode 100644 google/resource_database_migration_service_connection_profile.go create mode 100644 google/resource_database_migration_service_connection_profile_generated_test.go create mode 100644 google/resource_database_migration_service_connection_profile_sweeper_test.go create mode 100644 google/resource_database_migration_service_connection_profile_test.go create mode 100644 website/docs/r/database_migration_service_connection_profile.html.markdown diff --git a/.changelog/7447.txt b/.changelog/7447.txt new file mode 100644 index 00000000000..23e5c42683f --- /dev/null +++ b/.changelog/7447.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +`google_database_migration_service_connection_profile` +``` diff --git a/google/config.go b/google/config.go index a3a1222261b..8dfa7d493e8 100644 --- a/google/config.go +++ b/google/config.go @@ -174,92 +174,93 @@ type Config struct { tokenSource oauth2.TokenSource - AccessApprovalBasePath string - AccessContextManagerBasePath string - ActiveDirectoryBasePath string - AlloydbBasePath string - ApigeeBasePath string - AppEngineBasePath string - ArtifactRegistryBasePath string - BeyondcorpBasePath string - BigQueryBasePath string - BigqueryAnalyticsHubBasePath string - BigqueryConnectionBasePath string - BigqueryDatapolicyBasePath string - BigqueryDataTransferBasePath string - BigqueryReservationBasePath string - BigtableBasePath string - BillingBasePath string - BinaryAuthorizationBasePath string - CertificateManagerBasePath string - CloudAssetBasePath string - CloudBuildBasePath string - CloudFunctionsBasePath string - Cloudfunctions2BasePath string - CloudIdentityBasePath string - CloudIdsBasePath string - CloudIotBasePath string - CloudRunBasePath string - CloudRunV2BasePath string - CloudSchedulerBasePath string - CloudTasksBasePath string - ComputeBasePath string - ContainerAnalysisBasePath string - ContainerAttachedBasePath string - DataCatalogBasePath string - DataFusionBasePath string - DataLossPreventionBasePath string - DataplexBasePath string - DataprocBasePath string - DataprocMetastoreBasePath string - DatastoreBasePath string - DatastreamBasePath string - DeploymentManagerBasePath string - DialogflowBasePath string - DialogflowCXBasePath string - DNSBasePath string - DocumentAIBasePath string - EssentialContactsBasePath string - FilestoreBasePath string - FirestoreBasePath string - GameServicesBasePath string - GKEBackupBasePath string - GKEHubBasePath string - HealthcareBasePath string - IAM2BasePath string - IAMBetaBasePath string - IAMWorkforcePoolBasePath string - IapBasePath string - IdentityPlatformBasePath string - KMSBasePath string - LoggingBasePath string - MemcacheBasePath string - MLEngineBasePath string - MonitoringBasePath string - NetworkManagementBasePath string - NetworkServicesBasePath string - NotebooksBasePath string - OSConfigBasePath string - OSLoginBasePath string - PrivatecaBasePath string - PubsubBasePath string - PubsubLiteBasePath string - RedisBasePath string - ResourceManagerBasePath string - SecretManagerBasePath string - SecurityCenterBasePath string - ServiceManagementBasePath string - ServiceUsageBasePath string - SourceRepoBasePath string - SpannerBasePath string - SQLBasePath string - StorageBasePath string - StorageTransferBasePath string - TagsBasePath string - TPUBasePath string - VertexAIBasePath string - VPCAccessBasePath string - WorkflowsBasePath string + AccessApprovalBasePath string + AccessContextManagerBasePath string + ActiveDirectoryBasePath string + AlloydbBasePath string + ApigeeBasePath string + AppEngineBasePath string + ArtifactRegistryBasePath string + BeyondcorpBasePath string + BigQueryBasePath string + BigqueryAnalyticsHubBasePath string + BigqueryConnectionBasePath string + BigqueryDatapolicyBasePath string + BigqueryDataTransferBasePath string + BigqueryReservationBasePath string + BigtableBasePath string + BillingBasePath string + BinaryAuthorizationBasePath string + CertificateManagerBasePath string + CloudAssetBasePath string + CloudBuildBasePath string + CloudFunctionsBasePath string + Cloudfunctions2BasePath string + CloudIdentityBasePath string + CloudIdsBasePath string + CloudIotBasePath string + CloudRunBasePath string + CloudRunV2BasePath string + CloudSchedulerBasePath string + CloudTasksBasePath string + ComputeBasePath string + ContainerAnalysisBasePath string + ContainerAttachedBasePath string + DatabaseMigrationServiceBasePath string + DataCatalogBasePath string + DataFusionBasePath string + DataLossPreventionBasePath string + DataplexBasePath string + DataprocBasePath string + DataprocMetastoreBasePath string + DatastoreBasePath string + DatastreamBasePath string + DeploymentManagerBasePath string + DialogflowBasePath string + DialogflowCXBasePath string + DNSBasePath string + DocumentAIBasePath string + EssentialContactsBasePath string + FilestoreBasePath string + FirestoreBasePath string + GameServicesBasePath string + GKEBackupBasePath string + GKEHubBasePath string + HealthcareBasePath string + IAM2BasePath string + IAMBetaBasePath string + IAMWorkforcePoolBasePath string + IapBasePath string + IdentityPlatformBasePath string + KMSBasePath string + LoggingBasePath string + MemcacheBasePath string + MLEngineBasePath string + MonitoringBasePath string + NetworkManagementBasePath string + NetworkServicesBasePath string + NotebooksBasePath string + OSConfigBasePath string + OSLoginBasePath string + PrivatecaBasePath string + PubsubBasePath string + PubsubLiteBasePath string + RedisBasePath string + ResourceManagerBasePath string + SecretManagerBasePath string + SecurityCenterBasePath string + ServiceManagementBasePath string + ServiceUsageBasePath string + SourceRepoBasePath string + SpannerBasePath string + SQLBasePath string + StorageBasePath string + StorageTransferBasePath string + TagsBasePath string + TPUBasePath string + VertexAIBasePath string + VPCAccessBasePath string + WorkflowsBasePath string CloudBillingBasePath string ComposerBasePath string @@ -313,6 +314,7 @@ const CloudTasksBasePathKey = "CloudTasks" const ComputeBasePathKey = "Compute" const ContainerAnalysisBasePathKey = "ContainerAnalysis" const ContainerAttachedBasePathKey = "ContainerAttached" +const DatabaseMigrationServiceBasePathKey = "DatabaseMigrationService" const DataCatalogBasePathKey = "DataCatalog" const DataFusionBasePathKey = "DataFusion" const DataLossPreventionBasePathKey = "DataLossPrevention" @@ -382,104 +384,105 @@ const TagsLocationBasePathKey = "TagsLocation" // Generated product base paths var DefaultBasePaths = map[string]string{ - AccessApprovalBasePathKey: "https://accessapproval.googleapis.com/v1/", - AccessContextManagerBasePathKey: "https://accesscontextmanager.googleapis.com/v1/", - ActiveDirectoryBasePathKey: "https://managedidentities.googleapis.com/v1/", - AlloydbBasePathKey: "https://alloydb.googleapis.com/v1/", - ApigeeBasePathKey: "https://apigee.googleapis.com/v1/", - AppEngineBasePathKey: "https://appengine.googleapis.com/v1/", - ArtifactRegistryBasePathKey: "https://artifactregistry.googleapis.com/v1/", - BeyondcorpBasePathKey: "https://beyondcorp.googleapis.com/v1/", - BigQueryBasePathKey: "https://bigquery.googleapis.com/bigquery/v2/", - BigqueryAnalyticsHubBasePathKey: "https://analyticshub.googleapis.com/v1/", - BigqueryConnectionBasePathKey: "https://bigqueryconnection.googleapis.com/v1/", - BigqueryDatapolicyBasePathKey: "https://bigquerydatapolicy.googleapis.com/v1/", - BigqueryDataTransferBasePathKey: "https://bigquerydatatransfer.googleapis.com/v1/", - BigqueryReservationBasePathKey: "https://bigqueryreservation.googleapis.com/v1/", - BigtableBasePathKey: "https://bigtableadmin.googleapis.com/v2/", - BillingBasePathKey: "https://billingbudgets.googleapis.com/v1/", - BinaryAuthorizationBasePathKey: "https://binaryauthorization.googleapis.com/v1/", - CertificateManagerBasePathKey: "https://certificatemanager.googleapis.com/v1/", - CloudAssetBasePathKey: "https://cloudasset.googleapis.com/v1/", - CloudBuildBasePathKey: "https://cloudbuild.googleapis.com/v1/", - CloudFunctionsBasePathKey: "https://cloudfunctions.googleapis.com/v1/", - Cloudfunctions2BasePathKey: "https://cloudfunctions.googleapis.com/v2/", - CloudIdentityBasePathKey: "https://cloudidentity.googleapis.com/v1/", - CloudIdsBasePathKey: "https://ids.googleapis.com/v1/", - CloudIotBasePathKey: "https://cloudiot.googleapis.com/v1/", - CloudRunBasePathKey: "https://{{location}}-run.googleapis.com/", - CloudRunV2BasePathKey: "https://run.googleapis.com/v2/", - CloudSchedulerBasePathKey: "https://cloudscheduler.googleapis.com/v1/", - CloudTasksBasePathKey: "https://cloudtasks.googleapis.com/v2/", - ComputeBasePathKey: "https://compute.googleapis.com/compute/v1/", - ContainerAnalysisBasePathKey: "https://containeranalysis.googleapis.com/v1/", - ContainerAttachedBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", - DataCatalogBasePathKey: "https://datacatalog.googleapis.com/v1/", - DataFusionBasePathKey: "https://datafusion.googleapis.com/v1/", - DataLossPreventionBasePathKey: "https://dlp.googleapis.com/v2/", - DataplexBasePathKey: "https://dataplex.googleapis.com/v1/", - DataprocBasePathKey: "https://dataproc.googleapis.com/v1/", - DataprocMetastoreBasePathKey: "https://metastore.googleapis.com/v1/", - DatastoreBasePathKey: "https://datastore.googleapis.com/v1/", - DatastreamBasePathKey: "https://datastream.googleapis.com/v1/", - DeploymentManagerBasePathKey: "https://www.googleapis.com/deploymentmanager/v2/", - DialogflowBasePathKey: "https://dialogflow.googleapis.com/v2/", - DialogflowCXBasePathKey: "https://{{location}}-dialogflow.googleapis.com/v3/", - DNSBasePathKey: "https://dns.googleapis.com/dns/v1/", - DocumentAIBasePathKey: "https://{{location}}-documentai.googleapis.com/v1/", - EssentialContactsBasePathKey: "https://essentialcontacts.googleapis.com/v1/", - FilestoreBasePathKey: "https://file.googleapis.com/v1/", - FirestoreBasePathKey: "https://firestore.googleapis.com/v1/", - GameServicesBasePathKey: "https://gameservices.googleapis.com/v1/", - GKEBackupBasePathKey: "https://gkebackup.googleapis.com/v1/", - GKEHubBasePathKey: "https://gkehub.googleapis.com/v1/", - HealthcareBasePathKey: "https://healthcare.googleapis.com/v1/", - IAM2BasePathKey: "https://iam.googleapis.com/v2/", - IAMBetaBasePathKey: "https://iam.googleapis.com/v1/", - IAMWorkforcePoolBasePathKey: "https://iam.googleapis.com/v1/", - IapBasePathKey: "https://iap.googleapis.com/v1/", - IdentityPlatformBasePathKey: "https://identitytoolkit.googleapis.com/v2/", - KMSBasePathKey: "https://cloudkms.googleapis.com/v1/", - LoggingBasePathKey: "https://logging.googleapis.com/v2/", - MemcacheBasePathKey: "https://memcache.googleapis.com/v1/", - MLEngineBasePathKey: "https://ml.googleapis.com/v1/", - MonitoringBasePathKey: "https://monitoring.googleapis.com/", - NetworkManagementBasePathKey: "https://networkmanagement.googleapis.com/v1/", - NetworkServicesBasePathKey: "https://networkservices.googleapis.com/v1/", - NotebooksBasePathKey: "https://notebooks.googleapis.com/v1/", - OSConfigBasePathKey: "https://osconfig.googleapis.com/v1/", - OSLoginBasePathKey: "https://oslogin.googleapis.com/v1/", - PrivatecaBasePathKey: "https://privateca.googleapis.com/v1/", - PubsubBasePathKey: "https://pubsub.googleapis.com/v1/", - PubsubLiteBasePathKey: "https://{{region}}-pubsublite.googleapis.com/v1/admin/", - RedisBasePathKey: "https://redis.googleapis.com/v1/", - ResourceManagerBasePathKey: "https://cloudresourcemanager.googleapis.com/v1/", - SecretManagerBasePathKey: "https://secretmanager.googleapis.com/v1/", - SecurityCenterBasePathKey: "https://securitycenter.googleapis.com/v1/", - ServiceManagementBasePathKey: "https://servicemanagement.googleapis.com/v1/", - ServiceUsageBasePathKey: "https://serviceusage.googleapis.com/v1/", - SourceRepoBasePathKey: "https://sourcerepo.googleapis.com/v1/", - SpannerBasePathKey: "https://spanner.googleapis.com/v1/", - SQLBasePathKey: "https://sqladmin.googleapis.com/sql/v1beta4/", - StorageBasePathKey: "https://storage.googleapis.com/storage/v1/", - StorageTransferBasePathKey: "https://storagetransfer.googleapis.com/v1/", - TagsBasePathKey: "https://cloudresourcemanager.googleapis.com/v3/", - TPUBasePathKey: "https://tpu.googleapis.com/v1/", - VertexAIBasePathKey: "https://{{region}}-aiplatform.googleapis.com/v1/", - VPCAccessBasePathKey: "https://vpcaccess.googleapis.com/v1/", - WorkflowsBasePathKey: "https://workflows.googleapis.com/v1/", - CloudBillingBasePathKey: "https://cloudbilling.googleapis.com/v1/", - ComposerBasePathKey: "https://composer.googleapis.com/v1/", - ContainerBasePathKey: "https://container.googleapis.com/v1/", - DataflowBasePathKey: "https://dataflow.googleapis.com/v1b3/", - IAMBasePathKey: "https://iam.googleapis.com/v1/", - IamCredentialsBasePathKey: "https://iamcredentials.googleapis.com/v1/", - ResourceManagerV3BasePathKey: "https://cloudresourcemanager.googleapis.com/v3/", - ServiceNetworkingBasePathKey: "https://servicenetworking.googleapis.com/v1/", - BigtableAdminBasePathKey: "https://bigtableadmin.googleapis.com/v2/", - ContainerAwsBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", - ContainerAzureBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", - TagsLocationBasePathKey: "https://{{location}}-cloudresourcemanager.googleapis.com/v3/", + AccessApprovalBasePathKey: "https://accessapproval.googleapis.com/v1/", + AccessContextManagerBasePathKey: "https://accesscontextmanager.googleapis.com/v1/", + ActiveDirectoryBasePathKey: "https://managedidentities.googleapis.com/v1/", + AlloydbBasePathKey: "https://alloydb.googleapis.com/v1/", + ApigeeBasePathKey: "https://apigee.googleapis.com/v1/", + AppEngineBasePathKey: "https://appengine.googleapis.com/v1/", + ArtifactRegistryBasePathKey: "https://artifactregistry.googleapis.com/v1/", + BeyondcorpBasePathKey: "https://beyondcorp.googleapis.com/v1/", + BigQueryBasePathKey: "https://bigquery.googleapis.com/bigquery/v2/", + BigqueryAnalyticsHubBasePathKey: "https://analyticshub.googleapis.com/v1/", + BigqueryConnectionBasePathKey: "https://bigqueryconnection.googleapis.com/v1/", + BigqueryDatapolicyBasePathKey: "https://bigquerydatapolicy.googleapis.com/v1/", + BigqueryDataTransferBasePathKey: "https://bigquerydatatransfer.googleapis.com/v1/", + BigqueryReservationBasePathKey: "https://bigqueryreservation.googleapis.com/v1/", + BigtableBasePathKey: "https://bigtableadmin.googleapis.com/v2/", + BillingBasePathKey: "https://billingbudgets.googleapis.com/v1/", + BinaryAuthorizationBasePathKey: "https://binaryauthorization.googleapis.com/v1/", + CertificateManagerBasePathKey: "https://certificatemanager.googleapis.com/v1/", + CloudAssetBasePathKey: "https://cloudasset.googleapis.com/v1/", + CloudBuildBasePathKey: "https://cloudbuild.googleapis.com/v1/", + CloudFunctionsBasePathKey: "https://cloudfunctions.googleapis.com/v1/", + Cloudfunctions2BasePathKey: "https://cloudfunctions.googleapis.com/v2/", + CloudIdentityBasePathKey: "https://cloudidentity.googleapis.com/v1/", + CloudIdsBasePathKey: "https://ids.googleapis.com/v1/", + CloudIotBasePathKey: "https://cloudiot.googleapis.com/v1/", + CloudRunBasePathKey: "https://{{location}}-run.googleapis.com/", + CloudRunV2BasePathKey: "https://run.googleapis.com/v2/", + CloudSchedulerBasePathKey: "https://cloudscheduler.googleapis.com/v1/", + CloudTasksBasePathKey: "https://cloudtasks.googleapis.com/v2/", + ComputeBasePathKey: "https://compute.googleapis.com/compute/v1/", + ContainerAnalysisBasePathKey: "https://containeranalysis.googleapis.com/v1/", + ContainerAttachedBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", + DatabaseMigrationServiceBasePathKey: "https://datamigration.googleapis.com/v1/", + DataCatalogBasePathKey: "https://datacatalog.googleapis.com/v1/", + DataFusionBasePathKey: "https://datafusion.googleapis.com/v1/", + DataLossPreventionBasePathKey: "https://dlp.googleapis.com/v2/", + DataplexBasePathKey: "https://dataplex.googleapis.com/v1/", + DataprocBasePathKey: "https://dataproc.googleapis.com/v1/", + DataprocMetastoreBasePathKey: "https://metastore.googleapis.com/v1/", + DatastoreBasePathKey: "https://datastore.googleapis.com/v1/", + DatastreamBasePathKey: "https://datastream.googleapis.com/v1/", + DeploymentManagerBasePathKey: "https://www.googleapis.com/deploymentmanager/v2/", + DialogflowBasePathKey: "https://dialogflow.googleapis.com/v2/", + DialogflowCXBasePathKey: "https://{{location}}-dialogflow.googleapis.com/v3/", + DNSBasePathKey: "https://dns.googleapis.com/dns/v1/", + DocumentAIBasePathKey: "https://{{location}}-documentai.googleapis.com/v1/", + EssentialContactsBasePathKey: "https://essentialcontacts.googleapis.com/v1/", + FilestoreBasePathKey: "https://file.googleapis.com/v1/", + FirestoreBasePathKey: "https://firestore.googleapis.com/v1/", + GameServicesBasePathKey: "https://gameservices.googleapis.com/v1/", + GKEBackupBasePathKey: "https://gkebackup.googleapis.com/v1/", + GKEHubBasePathKey: "https://gkehub.googleapis.com/v1/", + HealthcareBasePathKey: "https://healthcare.googleapis.com/v1/", + IAM2BasePathKey: "https://iam.googleapis.com/v2/", + IAMBetaBasePathKey: "https://iam.googleapis.com/v1/", + IAMWorkforcePoolBasePathKey: "https://iam.googleapis.com/v1/", + IapBasePathKey: "https://iap.googleapis.com/v1/", + IdentityPlatformBasePathKey: "https://identitytoolkit.googleapis.com/v2/", + KMSBasePathKey: "https://cloudkms.googleapis.com/v1/", + LoggingBasePathKey: "https://logging.googleapis.com/v2/", + MemcacheBasePathKey: "https://memcache.googleapis.com/v1/", + MLEngineBasePathKey: "https://ml.googleapis.com/v1/", + MonitoringBasePathKey: "https://monitoring.googleapis.com/", + NetworkManagementBasePathKey: "https://networkmanagement.googleapis.com/v1/", + NetworkServicesBasePathKey: "https://networkservices.googleapis.com/v1/", + NotebooksBasePathKey: "https://notebooks.googleapis.com/v1/", + OSConfigBasePathKey: "https://osconfig.googleapis.com/v1/", + OSLoginBasePathKey: "https://oslogin.googleapis.com/v1/", + PrivatecaBasePathKey: "https://privateca.googleapis.com/v1/", + PubsubBasePathKey: "https://pubsub.googleapis.com/v1/", + PubsubLiteBasePathKey: "https://{{region}}-pubsublite.googleapis.com/v1/admin/", + RedisBasePathKey: "https://redis.googleapis.com/v1/", + ResourceManagerBasePathKey: "https://cloudresourcemanager.googleapis.com/v1/", + SecretManagerBasePathKey: "https://secretmanager.googleapis.com/v1/", + SecurityCenterBasePathKey: "https://securitycenter.googleapis.com/v1/", + ServiceManagementBasePathKey: "https://servicemanagement.googleapis.com/v1/", + ServiceUsageBasePathKey: "https://serviceusage.googleapis.com/v1/", + SourceRepoBasePathKey: "https://sourcerepo.googleapis.com/v1/", + SpannerBasePathKey: "https://spanner.googleapis.com/v1/", + SQLBasePathKey: "https://sqladmin.googleapis.com/sql/v1beta4/", + StorageBasePathKey: "https://storage.googleapis.com/storage/v1/", + StorageTransferBasePathKey: "https://storagetransfer.googleapis.com/v1/", + TagsBasePathKey: "https://cloudresourcemanager.googleapis.com/v3/", + TPUBasePathKey: "https://tpu.googleapis.com/v1/", + VertexAIBasePathKey: "https://{{region}}-aiplatform.googleapis.com/v1/", + VPCAccessBasePathKey: "https://vpcaccess.googleapis.com/v1/", + WorkflowsBasePathKey: "https://workflows.googleapis.com/v1/", + CloudBillingBasePathKey: "https://cloudbilling.googleapis.com/v1/", + ComposerBasePathKey: "https://composer.googleapis.com/v1/", + ContainerBasePathKey: "https://container.googleapis.com/v1/", + DataflowBasePathKey: "https://dataflow.googleapis.com/v1b3/", + IAMBasePathKey: "https://iam.googleapis.com/v1/", + IamCredentialsBasePathKey: "https://iamcredentials.googleapis.com/v1/", + ResourceManagerV3BasePathKey: "https://cloudresourcemanager.googleapis.com/v3/", + ServiceNetworkingBasePathKey: "https://servicenetworking.googleapis.com/v1/", + BigtableAdminBasePathKey: "https://bigtableadmin.googleapis.com/v2/", + ContainerAwsBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", + ContainerAzureBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", + TagsLocationBasePathKey: "https://{{location}}-cloudresourcemanager.googleapis.com/v3/", } var DefaultClientScopes = []string{ @@ -706,6 +709,11 @@ func HandleSDKDefaults(d *schema.ResourceData) error { "GOOGLE_CONTAINER_ATTACHED_CUSTOM_ENDPOINT", }, DefaultBasePaths[ContainerAttachedBasePathKey])) } + if d.Get("database_migration_service_custom_endpoint") == "" { + d.Set("database_migration_service_custom_endpoint", MultiEnvDefault([]string{ + "GOOGLE_DATABASE_MIGRATION_SERVICE_CUSTOM_ENDPOINT", + }, DefaultBasePaths[DatabaseMigrationServiceBasePathKey])) + } if d.Get("data_catalog_custom_endpoint") == "" { d.Set("data_catalog_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_DATA_CATALOG_CUSTOM_ENDPOINT", @@ -1850,6 +1858,7 @@ func ConfigureBasePaths(c *Config) { c.ComputeBasePath = DefaultBasePaths[ComputeBasePathKey] c.ContainerAnalysisBasePath = DefaultBasePaths[ContainerAnalysisBasePathKey] c.ContainerAttachedBasePath = DefaultBasePaths[ContainerAttachedBasePathKey] + c.DatabaseMigrationServiceBasePath = DefaultBasePaths[DatabaseMigrationServiceBasePathKey] c.DataCatalogBasePath = DefaultBasePaths[DataCatalogBasePathKey] c.DataFusionBasePath = DefaultBasePaths[DataFusionBasePathKey] c.DataLossPreventionBasePath = DefaultBasePaths[DataLossPreventionBasePathKey] diff --git a/google/config_test_utils.go b/google/config_test_utils.go index a34934f898b..e2ba584444d 100644 --- a/google/config_test_utils.go +++ b/google/config_test_utils.go @@ -53,6 +53,7 @@ func configureTestBasePaths(c *Config, url string) { c.ComputeBasePath = url c.ContainerAnalysisBasePath = url c.ContainerAttachedBasePath = url + c.DatabaseMigrationServiceBasePath = url c.DataCatalogBasePath = url c.DataFusionBasePath = url c.DataLossPreventionBasePath = url diff --git a/google/database_migration_service_operation.go b/google/database_migration_service_operation.go new file mode 100644 index 00000000000..da329f79a18 --- /dev/null +++ b/google/database_migration_service_operation.go @@ -0,0 +1,62 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "time" +) + +type DatabaseMigrationServiceOperationWaiter struct { + Config *Config + UserAgent string + Project string + CommonOperationWaiter +} + +func (w *DatabaseMigrationServiceOperationWaiter) QueryOp() (interface{}, error) { + if w == nil { + return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") + } + // Returns the proper get. + url := fmt.Sprintf("%s%s", w.Config.DatabaseMigrationServiceBasePath, w.CommonOperationWaiter.Op.Name) + + return SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil) +} + +func createDatabaseMigrationServiceWaiter(config *Config, op map[string]interface{}, project, activity, userAgent string) (*DatabaseMigrationServiceOperationWaiter, error) { + w := &DatabaseMigrationServiceOperationWaiter{ + Config: config, + UserAgent: userAgent, + Project: project, + } + if err := w.CommonOperationWaiter.SetOp(op); err != nil { + return nil, err + } + return w, nil +} + +func DatabaseMigrationServiceOperationWaitTime(config *Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { + if val, ok := op["name"]; !ok || val == "" { + // This was a synchronous call - there is no operation to wait for. + return nil + } + w, err := createDatabaseMigrationServiceWaiter(config, op, project, activity, userAgent) + if err != nil { + // If w is nil, the op was synchronous. + return err + } + return OperationWait(w, activity, timeout, config.PollInterval) +} diff --git a/google/framework_config.go b/google/framework_config.go index a569e3851c8..db4701fe00b 100644 --- a/google/framework_config.go +++ b/google/framework_config.go @@ -94,6 +94,7 @@ func (p *frameworkProvider) LoadAndValidateFramework(ctx context.Context, data P p.ComputeBasePath = data.ComputeCustomEndpoint.ValueString() p.ContainerAnalysisBasePath = data.ContainerAnalysisCustomEndpoint.ValueString() p.ContainerAttachedBasePath = data.ContainerAttachedCustomEndpoint.ValueString() + p.DatabaseMigrationServiceBasePath = data.DatabaseMigrationServiceCustomEndpoint.ValueString() p.DataCatalogBasePath = data.DataCatalogCustomEndpoint.ValueString() p.DataFusionBasePath = data.DataFusionCustomEndpoint.ValueString() p.DataLossPreventionBasePath = data.DataLossPreventionCustomEndpoint.ValueString() @@ -526,6 +527,14 @@ func (p *frameworkProvider) HandleDefaults(ctx context.Context, data *ProviderMo data.ContainerAttachedCustomEndpoint = types.StringValue(customEndpoint.(string)) } } + if data.DatabaseMigrationServiceCustomEndpoint.IsNull() { + customEndpoint := MultiEnvDefault([]string{ + "GOOGLE_DATABASE_MIGRATION_SERVICE_CUSTOM_ENDPOINT", + }, DefaultBasePaths[DatabaseMigrationServiceBasePathKey]) + if customEndpoint != nil { + data.DatabaseMigrationServiceCustomEndpoint = types.StringValue(customEndpoint.(string)) + } + } if data.DataCatalogCustomEndpoint.IsNull() { customEndpoint := MultiEnvDefault([]string{ "GOOGLE_DATA_CATALOG_CUSTOM_ENDPOINT", diff --git a/google/framework_provider.go b/google/framework_provider.go index fa55d7b0cb6..303c445b8c0 100644 --- a/google/framework_provider.go +++ b/google/framework_provider.go @@ -55,92 +55,93 @@ type frameworkProvider struct { version string // paths for client setup - AccessApprovalBasePath string - AccessContextManagerBasePath string - ActiveDirectoryBasePath string - AlloydbBasePath string - ApigeeBasePath string - AppEngineBasePath string - ArtifactRegistryBasePath string - BeyondcorpBasePath string - BigQueryBasePath string - BigqueryAnalyticsHubBasePath string - BigqueryConnectionBasePath string - BigqueryDatapolicyBasePath string - BigqueryDataTransferBasePath string - BigqueryReservationBasePath string - BigtableBasePath string - BillingBasePath string - BinaryAuthorizationBasePath string - CertificateManagerBasePath string - CloudAssetBasePath string - CloudBuildBasePath string - CloudFunctionsBasePath string - Cloudfunctions2BasePath string - CloudIdentityBasePath string - CloudIdsBasePath string - CloudIotBasePath string - CloudRunBasePath string - CloudRunV2BasePath string - CloudSchedulerBasePath string - CloudTasksBasePath string - ComputeBasePath string - ContainerAnalysisBasePath string - ContainerAttachedBasePath string - DataCatalogBasePath string - DataFusionBasePath string - DataLossPreventionBasePath string - DataplexBasePath string - DataprocBasePath string - DataprocMetastoreBasePath string - DatastoreBasePath string - DatastreamBasePath string - DeploymentManagerBasePath string - DialogflowBasePath string - DialogflowCXBasePath string - DNSBasePath string - DocumentAIBasePath string - EssentialContactsBasePath string - FilestoreBasePath string - FirestoreBasePath string - GameServicesBasePath string - GKEBackupBasePath string - GKEHubBasePath string - HealthcareBasePath string - IAM2BasePath string - IAMBetaBasePath string - IAMWorkforcePoolBasePath string - IapBasePath string - IdentityPlatformBasePath string - KMSBasePath string - LoggingBasePath string - MemcacheBasePath string - MLEngineBasePath string - MonitoringBasePath string - NetworkManagementBasePath string - NetworkServicesBasePath string - NotebooksBasePath string - OSConfigBasePath string - OSLoginBasePath string - PrivatecaBasePath string - PubsubBasePath string - PubsubLiteBasePath string - RedisBasePath string - ResourceManagerBasePath string - SecretManagerBasePath string - SecurityCenterBasePath string - ServiceManagementBasePath string - ServiceUsageBasePath string - SourceRepoBasePath string - SpannerBasePath string - SQLBasePath string - StorageBasePath string - StorageTransferBasePath string - TagsBasePath string - TPUBasePath string - VertexAIBasePath string - VPCAccessBasePath string - WorkflowsBasePath string + AccessApprovalBasePath string + AccessContextManagerBasePath string + ActiveDirectoryBasePath string + AlloydbBasePath string + ApigeeBasePath string + AppEngineBasePath string + ArtifactRegistryBasePath string + BeyondcorpBasePath string + BigQueryBasePath string + BigqueryAnalyticsHubBasePath string + BigqueryConnectionBasePath string + BigqueryDatapolicyBasePath string + BigqueryDataTransferBasePath string + BigqueryReservationBasePath string + BigtableBasePath string + BillingBasePath string + BinaryAuthorizationBasePath string + CertificateManagerBasePath string + CloudAssetBasePath string + CloudBuildBasePath string + CloudFunctionsBasePath string + Cloudfunctions2BasePath string + CloudIdentityBasePath string + CloudIdsBasePath string + CloudIotBasePath string + CloudRunBasePath string + CloudRunV2BasePath string + CloudSchedulerBasePath string + CloudTasksBasePath string + ComputeBasePath string + ContainerAnalysisBasePath string + ContainerAttachedBasePath string + DatabaseMigrationServiceBasePath string + DataCatalogBasePath string + DataFusionBasePath string + DataLossPreventionBasePath string + DataplexBasePath string + DataprocBasePath string + DataprocMetastoreBasePath string + DatastoreBasePath string + DatastreamBasePath string + DeploymentManagerBasePath string + DialogflowBasePath string + DialogflowCXBasePath string + DNSBasePath string + DocumentAIBasePath string + EssentialContactsBasePath string + FilestoreBasePath string + FirestoreBasePath string + GameServicesBasePath string + GKEBackupBasePath string + GKEHubBasePath string + HealthcareBasePath string + IAM2BasePath string + IAMBetaBasePath string + IAMWorkforcePoolBasePath string + IapBasePath string + IdentityPlatformBasePath string + KMSBasePath string + LoggingBasePath string + MemcacheBasePath string + MLEngineBasePath string + MonitoringBasePath string + NetworkManagementBasePath string + NetworkServicesBasePath string + NotebooksBasePath string + OSConfigBasePath string + OSLoginBasePath string + PrivatecaBasePath string + PubsubBasePath string + PubsubLiteBasePath string + RedisBasePath string + ResourceManagerBasePath string + SecretManagerBasePath string + SecurityCenterBasePath string + ServiceManagementBasePath string + ServiceUsageBasePath string + SourceRepoBasePath string + SpannerBasePath string + SQLBasePath string + StorageBasePath string + StorageTransferBasePath string + TagsBasePath string + TPUBasePath string + VertexAIBasePath string + VPCAccessBasePath string + WorkflowsBasePath string } // Metadata returns the provider type name. @@ -407,6 +408,12 @@ func (p *frameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, CustomEndpointValidator(), }, }, + "database_migration_service_custom_endpoint": &schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + CustomEndpointValidator(), + }, + }, "data_catalog_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ diff --git a/google/provider.go b/google/provider.go index cba82168a36..3ffd2b9e616 100644 --- a/google/provider.go +++ b/google/provider.go @@ -277,6 +277,11 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: validateCustomEndpoint, }, + "database_migration_service_custom_endpoint": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateCustomEndpoint, + }, "data_catalog_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -712,9 +717,9 @@ func Provider() *schema.Provider { return provider } -// Generated resources: 282 +// Generated resources: 283 // Generated IAM resources: 186 -// Total generated resources: 468 +// Total generated resources: 469 func ResourceMap() map[string]*schema.Resource { resourceMap, _ := ResourceMapWithErrors() return resourceMap @@ -937,6 +942,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) { "google_container_analysis_note": ResourceContainerAnalysisNote(), "google_container_analysis_occurrence": ResourceContainerAnalysisOccurrence(), "google_container_attached_cluster": ResourceContainerAttachedCluster(), + "google_database_migration_service_connection_profile": ResourceDatabaseMigrationServiceConnectionProfile(), "google_data_catalog_entry": ResourceDataCatalogEntry(), "google_data_catalog_entry_group": ResourceDataCatalogEntryGroup(), "google_data_catalog_entry_group_iam_binding": ResourceIamBinding(DataCatalogEntryGroupIamSchema, DataCatalogEntryGroupIamUpdaterProducer, DataCatalogEntryGroupIdParseFunc), @@ -1445,6 +1451,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.ComputeBasePath = d.Get("compute_custom_endpoint").(string) config.ContainerAnalysisBasePath = d.Get("container_analysis_custom_endpoint").(string) config.ContainerAttachedBasePath = d.Get("container_attached_custom_endpoint").(string) + config.DatabaseMigrationServiceBasePath = d.Get("database_migration_service_custom_endpoint").(string) config.DataCatalogBasePath = d.Get("data_catalog_custom_endpoint").(string) config.DataFusionBasePath = d.Get("data_fusion_custom_endpoint").(string) config.DataLossPreventionBasePath = d.Get("data_loss_prevention_custom_endpoint").(string) diff --git a/google/provider_model.go b/google/provider_model.go index 7a315d9b318..472a7d3b1b3 100644 --- a/google/provider_model.go +++ b/google/provider_model.go @@ -22,92 +22,93 @@ type ProviderModel struct { RequestReason types.String `tfsdk:"request_reason"` // Generated Products - AccessApprovalCustomEndpoint types.String `tfsdk:"access_approval_custom_endpoint"` - AccessContextManagerCustomEndpoint types.String `tfsdk:"access_context_manager_custom_endpoint"` - ActiveDirectoryCustomEndpoint types.String `tfsdk:"active_directory_custom_endpoint"` - AlloydbCustomEndpoint types.String `tfsdk:"alloydb_custom_endpoint"` - ApigeeCustomEndpoint types.String `tfsdk:"apigee_custom_endpoint"` - AppEngineCustomEndpoint types.String `tfsdk:"app_engine_custom_endpoint"` - ArtifactRegistryCustomEndpoint types.String `tfsdk:"artifact_registry_custom_endpoint"` - BeyondcorpCustomEndpoint types.String `tfsdk:"beyondcorp_custom_endpoint"` - BigQueryCustomEndpoint types.String `tfsdk:"big_query_custom_endpoint"` - BigqueryAnalyticsHubCustomEndpoint types.String `tfsdk:"bigquery_analytics_hub_custom_endpoint"` - BigqueryConnectionCustomEndpoint types.String `tfsdk:"bigquery_connection_custom_endpoint"` - BigqueryDatapolicyCustomEndpoint types.String `tfsdk:"bigquery_datapolicy_custom_endpoint"` - BigqueryDataTransferCustomEndpoint types.String `tfsdk:"bigquery_data_transfer_custom_endpoint"` - BigqueryReservationCustomEndpoint types.String `tfsdk:"bigquery_reservation_custom_endpoint"` - BigtableCustomEndpoint types.String `tfsdk:"bigtable_custom_endpoint"` - BillingCustomEndpoint types.String `tfsdk:"billing_custom_endpoint"` - BinaryAuthorizationCustomEndpoint types.String `tfsdk:"binary_authorization_custom_endpoint"` - CertificateManagerCustomEndpoint types.String `tfsdk:"certificate_manager_custom_endpoint"` - CloudAssetCustomEndpoint types.String `tfsdk:"cloud_asset_custom_endpoint"` - CloudBuildCustomEndpoint types.String `tfsdk:"cloud_build_custom_endpoint"` - CloudFunctionsCustomEndpoint types.String `tfsdk:"cloud_functions_custom_endpoint"` - Cloudfunctions2CustomEndpoint types.String `tfsdk:"cloudfunctions2_custom_endpoint"` - CloudIdentityCustomEndpoint types.String `tfsdk:"cloud_identity_custom_endpoint"` - CloudIdsCustomEndpoint types.String `tfsdk:"cloud_ids_custom_endpoint"` - CloudIotCustomEndpoint types.String `tfsdk:"cloud_iot_custom_endpoint"` - CloudRunCustomEndpoint types.String `tfsdk:"cloud_run_custom_endpoint"` - CloudRunV2CustomEndpoint types.String `tfsdk:"cloud_run_v2_custom_endpoint"` - CloudSchedulerCustomEndpoint types.String `tfsdk:"cloud_scheduler_custom_endpoint"` - CloudTasksCustomEndpoint types.String `tfsdk:"cloud_tasks_custom_endpoint"` - ComputeCustomEndpoint types.String `tfsdk:"compute_custom_endpoint"` - ContainerAnalysisCustomEndpoint types.String `tfsdk:"container_analysis_custom_endpoint"` - ContainerAttachedCustomEndpoint types.String `tfsdk:"container_attached_custom_endpoint"` - DataCatalogCustomEndpoint types.String `tfsdk:"data_catalog_custom_endpoint"` - DataFusionCustomEndpoint types.String `tfsdk:"data_fusion_custom_endpoint"` - DataLossPreventionCustomEndpoint types.String `tfsdk:"data_loss_prevention_custom_endpoint"` - DataplexCustomEndpoint types.String `tfsdk:"dataplex_custom_endpoint"` - DataprocCustomEndpoint types.String `tfsdk:"dataproc_custom_endpoint"` - DataprocMetastoreCustomEndpoint types.String `tfsdk:"dataproc_metastore_custom_endpoint"` - DatastoreCustomEndpoint types.String `tfsdk:"datastore_custom_endpoint"` - DatastreamCustomEndpoint types.String `tfsdk:"datastream_custom_endpoint"` - DeploymentManagerCustomEndpoint types.String `tfsdk:"deployment_manager_custom_endpoint"` - DialogflowCustomEndpoint types.String `tfsdk:"dialogflow_custom_endpoint"` - DialogflowCXCustomEndpoint types.String `tfsdk:"dialogflow_cx_custom_endpoint"` - DNSCustomEndpoint types.String `tfsdk:"dns_custom_endpoint"` - DocumentAICustomEndpoint types.String `tfsdk:"document_ai_custom_endpoint"` - EssentialContactsCustomEndpoint types.String `tfsdk:"essential_contacts_custom_endpoint"` - FilestoreCustomEndpoint types.String `tfsdk:"filestore_custom_endpoint"` - FirestoreCustomEndpoint types.String `tfsdk:"firestore_custom_endpoint"` - GameServicesCustomEndpoint types.String `tfsdk:"game_services_custom_endpoint"` - GKEBackupCustomEndpoint types.String `tfsdk:"gke_backup_custom_endpoint"` - GKEHubCustomEndpoint types.String `tfsdk:"gke_hub_custom_endpoint"` - HealthcareCustomEndpoint types.String `tfsdk:"healthcare_custom_endpoint"` - IAM2CustomEndpoint types.String `tfsdk:"iam2_custom_endpoint"` - IAMBetaCustomEndpoint types.String `tfsdk:"iam_beta_custom_endpoint"` - IAMWorkforcePoolCustomEndpoint types.String `tfsdk:"iam_workforce_pool_custom_endpoint"` - IapCustomEndpoint types.String `tfsdk:"iap_custom_endpoint"` - IdentityPlatformCustomEndpoint types.String `tfsdk:"identity_platform_custom_endpoint"` - KMSCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"` - LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"` - MemcacheCustomEndpoint types.String `tfsdk:"memcache_custom_endpoint"` - MLEngineCustomEndpoint types.String `tfsdk:"ml_engine_custom_endpoint"` - MonitoringCustomEndpoint types.String `tfsdk:"monitoring_custom_endpoint"` - NetworkManagementCustomEndpoint types.String `tfsdk:"network_management_custom_endpoint"` - NetworkServicesCustomEndpoint types.String `tfsdk:"network_services_custom_endpoint"` - NotebooksCustomEndpoint types.String `tfsdk:"notebooks_custom_endpoint"` - OSConfigCustomEndpoint types.String `tfsdk:"os_config_custom_endpoint"` - OSLoginCustomEndpoint types.String `tfsdk:"os_login_custom_endpoint"` - PrivatecaCustomEndpoint types.String `tfsdk:"privateca_custom_endpoint"` - PubsubCustomEndpoint types.String `tfsdk:"pubsub_custom_endpoint"` - PubsubLiteCustomEndpoint types.String `tfsdk:"pubsub_lite_custom_endpoint"` - RedisCustomEndpoint types.String `tfsdk:"redis_custom_endpoint"` - ResourceManagerCustomEndpoint types.String `tfsdk:"resource_manager_custom_endpoint"` - SecretManagerCustomEndpoint types.String `tfsdk:"secret_manager_custom_endpoint"` - SecurityCenterCustomEndpoint types.String `tfsdk:"security_center_custom_endpoint"` - ServiceManagementCustomEndpoint types.String `tfsdk:"service_management_custom_endpoint"` - ServiceUsageCustomEndpoint types.String `tfsdk:"service_usage_custom_endpoint"` - SourceRepoCustomEndpoint types.String `tfsdk:"source_repo_custom_endpoint"` - SpannerCustomEndpoint types.String `tfsdk:"spanner_custom_endpoint"` - SQLCustomEndpoint types.String `tfsdk:"sql_custom_endpoint"` - StorageCustomEndpoint types.String `tfsdk:"storage_custom_endpoint"` - StorageTransferCustomEndpoint types.String `tfsdk:"storage_transfer_custom_endpoint"` - TagsCustomEndpoint types.String `tfsdk:"tags_custom_endpoint"` - TPUCustomEndpoint types.String `tfsdk:"tpu_custom_endpoint"` - VertexAICustomEndpoint types.String `tfsdk:"vertex_ai_custom_endpoint"` - VPCAccessCustomEndpoint types.String `tfsdk:"vpc_access_custom_endpoint"` - WorkflowsCustomEndpoint types.String `tfsdk:"workflows_custom_endpoint"` + AccessApprovalCustomEndpoint types.String `tfsdk:"access_approval_custom_endpoint"` + AccessContextManagerCustomEndpoint types.String `tfsdk:"access_context_manager_custom_endpoint"` + ActiveDirectoryCustomEndpoint types.String `tfsdk:"active_directory_custom_endpoint"` + AlloydbCustomEndpoint types.String `tfsdk:"alloydb_custom_endpoint"` + ApigeeCustomEndpoint types.String `tfsdk:"apigee_custom_endpoint"` + AppEngineCustomEndpoint types.String `tfsdk:"app_engine_custom_endpoint"` + ArtifactRegistryCustomEndpoint types.String `tfsdk:"artifact_registry_custom_endpoint"` + BeyondcorpCustomEndpoint types.String `tfsdk:"beyondcorp_custom_endpoint"` + BigQueryCustomEndpoint types.String `tfsdk:"big_query_custom_endpoint"` + BigqueryAnalyticsHubCustomEndpoint types.String `tfsdk:"bigquery_analytics_hub_custom_endpoint"` + BigqueryConnectionCustomEndpoint types.String `tfsdk:"bigquery_connection_custom_endpoint"` + BigqueryDatapolicyCustomEndpoint types.String `tfsdk:"bigquery_datapolicy_custom_endpoint"` + BigqueryDataTransferCustomEndpoint types.String `tfsdk:"bigquery_data_transfer_custom_endpoint"` + BigqueryReservationCustomEndpoint types.String `tfsdk:"bigquery_reservation_custom_endpoint"` + BigtableCustomEndpoint types.String `tfsdk:"bigtable_custom_endpoint"` + BillingCustomEndpoint types.String `tfsdk:"billing_custom_endpoint"` + BinaryAuthorizationCustomEndpoint types.String `tfsdk:"binary_authorization_custom_endpoint"` + CertificateManagerCustomEndpoint types.String `tfsdk:"certificate_manager_custom_endpoint"` + CloudAssetCustomEndpoint types.String `tfsdk:"cloud_asset_custom_endpoint"` + CloudBuildCustomEndpoint types.String `tfsdk:"cloud_build_custom_endpoint"` + CloudFunctionsCustomEndpoint types.String `tfsdk:"cloud_functions_custom_endpoint"` + Cloudfunctions2CustomEndpoint types.String `tfsdk:"cloudfunctions2_custom_endpoint"` + CloudIdentityCustomEndpoint types.String `tfsdk:"cloud_identity_custom_endpoint"` + CloudIdsCustomEndpoint types.String `tfsdk:"cloud_ids_custom_endpoint"` + CloudIotCustomEndpoint types.String `tfsdk:"cloud_iot_custom_endpoint"` + CloudRunCustomEndpoint types.String `tfsdk:"cloud_run_custom_endpoint"` + CloudRunV2CustomEndpoint types.String `tfsdk:"cloud_run_v2_custom_endpoint"` + CloudSchedulerCustomEndpoint types.String `tfsdk:"cloud_scheduler_custom_endpoint"` + CloudTasksCustomEndpoint types.String `tfsdk:"cloud_tasks_custom_endpoint"` + ComputeCustomEndpoint types.String `tfsdk:"compute_custom_endpoint"` + ContainerAnalysisCustomEndpoint types.String `tfsdk:"container_analysis_custom_endpoint"` + ContainerAttachedCustomEndpoint types.String `tfsdk:"container_attached_custom_endpoint"` + DatabaseMigrationServiceCustomEndpoint types.String `tfsdk:"database_migration_service_custom_endpoint"` + DataCatalogCustomEndpoint types.String `tfsdk:"data_catalog_custom_endpoint"` + DataFusionCustomEndpoint types.String `tfsdk:"data_fusion_custom_endpoint"` + DataLossPreventionCustomEndpoint types.String `tfsdk:"data_loss_prevention_custom_endpoint"` + DataplexCustomEndpoint types.String `tfsdk:"dataplex_custom_endpoint"` + DataprocCustomEndpoint types.String `tfsdk:"dataproc_custom_endpoint"` + DataprocMetastoreCustomEndpoint types.String `tfsdk:"dataproc_metastore_custom_endpoint"` + DatastoreCustomEndpoint types.String `tfsdk:"datastore_custom_endpoint"` + DatastreamCustomEndpoint types.String `tfsdk:"datastream_custom_endpoint"` + DeploymentManagerCustomEndpoint types.String `tfsdk:"deployment_manager_custom_endpoint"` + DialogflowCustomEndpoint types.String `tfsdk:"dialogflow_custom_endpoint"` + DialogflowCXCustomEndpoint types.String `tfsdk:"dialogflow_cx_custom_endpoint"` + DNSCustomEndpoint types.String `tfsdk:"dns_custom_endpoint"` + DocumentAICustomEndpoint types.String `tfsdk:"document_ai_custom_endpoint"` + EssentialContactsCustomEndpoint types.String `tfsdk:"essential_contacts_custom_endpoint"` + FilestoreCustomEndpoint types.String `tfsdk:"filestore_custom_endpoint"` + FirestoreCustomEndpoint types.String `tfsdk:"firestore_custom_endpoint"` + GameServicesCustomEndpoint types.String `tfsdk:"game_services_custom_endpoint"` + GKEBackupCustomEndpoint types.String `tfsdk:"gke_backup_custom_endpoint"` + GKEHubCustomEndpoint types.String `tfsdk:"gke_hub_custom_endpoint"` + HealthcareCustomEndpoint types.String `tfsdk:"healthcare_custom_endpoint"` + IAM2CustomEndpoint types.String `tfsdk:"iam2_custom_endpoint"` + IAMBetaCustomEndpoint types.String `tfsdk:"iam_beta_custom_endpoint"` + IAMWorkforcePoolCustomEndpoint types.String `tfsdk:"iam_workforce_pool_custom_endpoint"` + IapCustomEndpoint types.String `tfsdk:"iap_custom_endpoint"` + IdentityPlatformCustomEndpoint types.String `tfsdk:"identity_platform_custom_endpoint"` + KMSCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"` + LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"` + MemcacheCustomEndpoint types.String `tfsdk:"memcache_custom_endpoint"` + MLEngineCustomEndpoint types.String `tfsdk:"ml_engine_custom_endpoint"` + MonitoringCustomEndpoint types.String `tfsdk:"monitoring_custom_endpoint"` + NetworkManagementCustomEndpoint types.String `tfsdk:"network_management_custom_endpoint"` + NetworkServicesCustomEndpoint types.String `tfsdk:"network_services_custom_endpoint"` + NotebooksCustomEndpoint types.String `tfsdk:"notebooks_custom_endpoint"` + OSConfigCustomEndpoint types.String `tfsdk:"os_config_custom_endpoint"` + OSLoginCustomEndpoint types.String `tfsdk:"os_login_custom_endpoint"` + PrivatecaCustomEndpoint types.String `tfsdk:"privateca_custom_endpoint"` + PubsubCustomEndpoint types.String `tfsdk:"pubsub_custom_endpoint"` + PubsubLiteCustomEndpoint types.String `tfsdk:"pubsub_lite_custom_endpoint"` + RedisCustomEndpoint types.String `tfsdk:"redis_custom_endpoint"` + ResourceManagerCustomEndpoint types.String `tfsdk:"resource_manager_custom_endpoint"` + SecretManagerCustomEndpoint types.String `tfsdk:"secret_manager_custom_endpoint"` + SecurityCenterCustomEndpoint types.String `tfsdk:"security_center_custom_endpoint"` + ServiceManagementCustomEndpoint types.String `tfsdk:"service_management_custom_endpoint"` + ServiceUsageCustomEndpoint types.String `tfsdk:"service_usage_custom_endpoint"` + SourceRepoCustomEndpoint types.String `tfsdk:"source_repo_custom_endpoint"` + SpannerCustomEndpoint types.String `tfsdk:"spanner_custom_endpoint"` + SQLCustomEndpoint types.String `tfsdk:"sql_custom_endpoint"` + StorageCustomEndpoint types.String `tfsdk:"storage_custom_endpoint"` + StorageTransferCustomEndpoint types.String `tfsdk:"storage_transfer_custom_endpoint"` + TagsCustomEndpoint types.String `tfsdk:"tags_custom_endpoint"` + TPUCustomEndpoint types.String `tfsdk:"tpu_custom_endpoint"` + VertexAICustomEndpoint types.String `tfsdk:"vertex_ai_custom_endpoint"` + VPCAccessCustomEndpoint types.String `tfsdk:"vpc_access_custom_endpoint"` + WorkflowsCustomEndpoint types.String `tfsdk:"workflows_custom_endpoint"` // Handwritten Products / Versioned / Atypical Entries CloudBillingCustomEndpoint types.String `tfsdk:"cloud_billing_custom_endpoint"` diff --git a/google/resource_database_migration_service_connection_profile.go b/google/resource_database_migration_service_connection_profile.go new file mode 100644 index 00000000000..742eb688122 --- /dev/null +++ b/google/resource_database_migration_service_connection_profile.go @@ -0,0 +1,2440 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "log" + "reflect" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func ResourceDatabaseMigrationServiceConnectionProfile() *schema.Resource { + return &schema.Resource{ + Create: resourceDatabaseMigrationServiceConnectionProfileCreate, + Read: resourceDatabaseMigrationServiceConnectionProfileRead, + Update: resourceDatabaseMigrationServiceConnectionProfileUpdate, + Delete: resourceDatabaseMigrationServiceConnectionProfileDelete, + + Importer: &schema.ResourceImporter{ + State: resourceDatabaseMigrationServiceConnectionProfileImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(60 * time.Minute), + Update: schema.DefaultTimeout(60 * time.Minute), + Delete: schema.DefaultTimeout(60 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "connection_profile_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The ID of the connection profile.`, + }, + "alloydb": { + Type: schema.TypeList, + Optional: true, + Description: `Specifies required connection parameters, and the parameters required to create an AlloyDB destination cluster.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Required: true, + Description: `Required. The AlloyDB cluster ID that this connection profile is associated with.`, + }, + "settings": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Immutable. Metadata used to create the destination AlloyDB cluster.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "initial_user": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `Required. Input only. Initial user to setup during cluster creation.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "password": { + Type: schema.TypeString, + Required: true, + Description: `The initial password for the user.`, + Sensitive: true, + }, + "user": { + Type: schema.TypeString, + Required: true, + Description: `The database username.`, + }, + "password_set": { + Type: schema.TypeBool, + Computed: true, + Description: `Output only. Indicates if the initialUser.password field has been set.`, + }, + }, + }, + }, + "vpc_network": { + Type: schema.TypeString, + Required: true, + Description: `Required. The resource link for the VPC network in which cluster resources are created and from which they are accessible via Private IP. The network must belong to the same project as the cluster. +It is specified in the form: 'projects/{project_number}/global/networks/{network_id}'. This is required to create a cluster.`, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + Description: `Labels for the AlloyDB cluster created by DMS.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "primary_instance_settings": { + Type: schema.TypeList, + Optional: true, + Description: `Settings for the cluster's primary instance`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Required: true, + Description: `The database username.`, + }, + "machine_config": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `Configuration for the machines that host the underlying database engine.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cpu_count": { + Type: schema.TypeInt, + Required: true, + Description: `The number of CPU's in the VM instance.`, + }, + }, + }, + }, + "database_flags": { + Type: schema.TypeMap, + Optional: true, + Description: `Database flags to pass to AlloyDB when DMS is creating the AlloyDB cluster and instances. See the AlloyDB documentation for how these can be used.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + Description: `Labels for the AlloyDB primary instance created by DMS.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "private_ip": { + Type: schema.TypeString, + Computed: true, + Description: `Output only. The private IP address for the Instance. This is the connection endpoint for an end-user application.`, + }, + }, + }, + }, + }, + }, + }, + }, + }, + ExactlyOneOf: []string{"mysql", "postgresql", "cloudsql", "alloydb"}, + }, + "cloudsql": { + Type: schema.TypeList, + Optional: true, + Description: `Specifies required connection parameters, and, optionally, the parameters required to create a Cloud SQL destination database instance.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "settings": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Immutable. Metadata used to create the destination Cloud SQL database.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "source_id": { + Type: schema.TypeString, + Required: true, + Description: `The Database Migration Service source connection profile ID, in the format: projects/my_project_name/locations/us-central1/connectionProfiles/connection_profile_ID`, + }, + "activation_policy": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateEnum([]string{"ALWAYS", "NEVER", ""}), + Description: `The activation policy specifies when the instance is activated; it is applicable only when the instance state is 'RUNNABLE'. Possible values: ["ALWAYS", "NEVER"]`, + }, + "auto_storage_increase": { + Type: schema.TypeBool, + Optional: true, + Description: `If you enable this setting, Cloud SQL checks your available storage every 30 seconds. If the available storage falls below a threshold size, Cloud SQL automatically adds additional storage capacity. +If the available storage repeatedly falls below the threshold size, Cloud SQL continues to add storage until it reaches the maximum of 30 TB.`, + }, + "cmek_key_name": { + Type: schema.TypeString, + Optional: true, + Description: `The KMS key name used for the csql instance.`, + }, + "collation": { + Type: schema.TypeString, + Optional: true, + Description: `The Cloud SQL default instance level collation.`, + }, + "data_disk_size_gb": { + Type: schema.TypeString, + Optional: true, + Description: `The storage capacity available to the database, in GB. The minimum (and default) size is 10GB.`, + }, + "data_disk_type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateEnum([]string{"PD_SSD", "PD_HDD", ""}), + Description: `The type of storage. Possible values: ["PD_SSD", "PD_HDD"]`, + }, + "database_flags": { + Type: schema.TypeMap, + Optional: true, + Description: `The database flags passed to the Cloud SQL instance at startup.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "database_version": { + Type: schema.TypeString, + Optional: true, + Description: `The database engine type and version. +Currently supported values located at https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.connectionProfiles#sqldatabaseversion`, + }, + "ip_config": { + Type: schema.TypeList, + Optional: true, + Description: `The settings for IP Management. This allows to enable or disable the instance IP and manage which external networks can connect to the instance. The IPv4 address cannot be disabled.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "authorized_networks": { + Type: schema.TypeList, + Optional: true, + Description: `The list of external networks that are allowed to connect to the instance using the IP.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "value": { + Type: schema.TypeString, + Required: true, + Description: `The allowlisted value for the access control list.`, + }, + "expire_time": { + Type: schema.TypeString, + Optional: true, + Description: `The time when this access control entry expires in RFC 3339 format.`, + ExactlyOneOf: []string{}, + }, + "label": { + Type: schema.TypeString, + Optional: true, + Description: `A label to identify this entry.`, + }, + "ttl": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Input only. The time-to-leave of this access control entry.`, + }, + }, + }, + }, + "enable_ipv4": { + Type: schema.TypeBool, + Optional: true, + Description: `Whether the instance should be assigned an IPv4 address or not.`, + }, + "private_network": { + Type: schema.TypeString, + Optional: true, + Description: `The resource link for the VPC network from which the Cloud SQL instance is accessible for private IP. For example, projects/myProject/global/networks/default. +This setting can be updated, but it cannot be removed after it is set.`, + }, + "require_ssl": { + Type: schema.TypeBool, + Optional: true, + Description: `Whether SSL connections over IP should be enforced or not.`, + }, + }, + }, + }, + "root_password": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Input only. Initial root password.`, + Sensitive: true, + }, + "storage_auto_resize_limit": { + Type: schema.TypeString, + Optional: true, + Description: `The maximum size to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit.`, + }, + "tier": { + Type: schema.TypeString, + Optional: true, + Description: `The tier (or machine type) for this instance, for example: db-n1-standard-1 (MySQL instances) or db-custom-1-3840 (PostgreSQL instances). +For more information, see https://cloud.google.com/sql/docs/mysql/instance-settings`, + }, + "user_labels": { + Type: schema.TypeMap, + Optional: true, + Description: `The resource labels for a Cloud SQL instance to use to annotate any related underlying resources such as Compute Engine VMs.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "zone": { + Type: schema.TypeString, + Optional: true, + Description: `The Google Cloud Platform zone where your Cloud SQL datdabse instance is located.`, + }, + "root_password_set": { + Type: schema.TypeBool, + Computed: true, + Description: `Output only. Indicates If this connection profile root password is stored.`, + }, + }, + }, + }, + "cloud_sql_id": { + Type: schema.TypeString, + Computed: true, + Description: `Output only. The Cloud SQL instance ID that this connection profile is associated with.`, + }, + "private_ip": { + Type: schema.TypeString, + Computed: true, + Description: `Output only. The Cloud SQL database instance's private IP.`, + }, + "public_ip": { + Type: schema.TypeString, + Computed: true, + Description: `Output only. The Cloud SQL database instance's public IP.`, + }, + }, + }, + ExactlyOneOf: []string{"mysql", "postgresql", "cloudsql", "alloydb"}, + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + Description: `The connection profile display name.`, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + Description: `The resource labels for connection profile to use to annotate any related underlying resources such as Compute Engine VMs.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "location": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The location where the connection profile should reside.`, + }, + "mysql": { + Type: schema.TypeList, + Optional: true, + Description: `Specifies connection parameters required specifically for MySQL databases.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "host": { + Type: schema.TypeString, + Required: true, + Description: `Required. The IP or hostname of the source MySQL database.`, + }, + "password": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Required. Input only. The password for the user that Database Migration Service will be using to connect to the database. +This field is not returned on request, and the value is encrypted when stored in Database Migration Service.`, + Sensitive: true, + }, + "port": { + Type: schema.TypeInt, + Required: true, + Description: `Required. The network port of the source MySQL database.`, + }, + "username": { + Type: schema.TypeString, + Required: true, + Description: `Required. The username that Database Migration Service will use to connect to the database. The value is encrypted when stored in Database Migration Service.`, + }, + "cloud_sql_id": { + Type: schema.TypeString, + Optional: true, + Description: `If the source is a Cloud SQL database, use this field to provide the Cloud SQL instance ID of the source.`, + }, + "ssl": { + Type: schema.TypeList, + Optional: true, + Description: `SSL configuration for the destination to connect to the source database.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ca_certificate": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Required. Input only. The x509 PEM-encoded certificate of the CA that signed the source database server's certificate. +The replica will use this certificate to verify it's connecting to the right host.`, + Sensitive: true, + }, + "client_certificate": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Input only. The x509 PEM-encoded certificate that will be used by the replica to authenticate against the source database server. +If this field is used then the 'clientKey' field is mandatory`, + Sensitive: true, + }, + "client_key": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Input only. The unencrypted PKCS#1 or PKCS#8 PEM-encoded private key associated with the Client Certificate. +If this field is used then the 'clientCertificate' field is mandatory.`, + Sensitive: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: `The current connection profile state.`, + }, + }, + }, + }, + "password_set": { + Type: schema.TypeBool, + Computed: true, + Description: `Output only. Indicates If this connection profile password is stored.`, + }, + }, + }, + ExactlyOneOf: []string{"mysql", "postgresql", "cloudsql", "alloydb"}, + }, + "postgresql": { + Type: schema.TypeList, + Optional: true, + Description: `Specifies connection parameters required specifically for PostgreSQL databases.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "host": { + Type: schema.TypeString, + Required: true, + Description: `Required. The IP or hostname of the source MySQL database.`, + }, + "password": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Required. Input only. The password for the user that Database Migration Service will be using to connect to the database. +This field is not returned on request, and the value is encrypted when stored in Database Migration Service.`, + Sensitive: true, + }, + "port": { + Type: schema.TypeInt, + Required: true, + Description: `Required. The network port of the source MySQL database.`, + }, + "username": { + Type: schema.TypeString, + Required: true, + Description: `Required. The username that Database Migration Service will use to connect to the database. The value is encrypted when stored in Database Migration Service.`, + }, + "cloud_sql_id": { + Type: schema.TypeString, + Optional: true, + Description: `If the source is a Cloud SQL database, use this field to provide the Cloud SQL instance ID of the source.`, + }, + "ssl": { + Type: schema.TypeList, + Optional: true, + Description: `SSL configuration for the destination to connect to the source database.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ca_certificate": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Required. Input only. The x509 PEM-encoded certificate of the CA that signed the source database server's certificate. +The replica will use this certificate to verify it's connecting to the right host.`, + Sensitive: true, + }, + "client_certificate": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Input only. The x509 PEM-encoded certificate that will be used by the replica to authenticate against the source database server. +If this field is used then the 'clientKey' field is mandatory`, + Sensitive: true, + RequiredWith: []string{}, + }, + "client_key": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Input only. The unencrypted PKCS#1 or PKCS#8 PEM-encoded private key associated with the Client Certificate. +If this field is used then the 'clientCertificate' field is mandatory.`, + Sensitive: true, + RequiredWith: []string{}, + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: `The current connection profile state.`, + }, + }, + }, + }, + "network_architecture": { + Type: schema.TypeString, + Computed: true, + Description: `Output only. If the source is a Cloud SQL database, this field indicates the network architecture it's associated with.`, + }, + "password_set": { + Type: schema.TypeBool, + Computed: true, + Description: `Output only. Indicates If this connection profile password is stored.`, + }, + }, + }, + ExactlyOneOf: []string{"mysql", "postgresql", "cloudsql", "alloydb"}, + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: `Output only. The timestamp when the resource was created. A timestamp in RFC3339 UTC 'Zulu' format, accurate to nanoseconds. Example: '2014-10-02T15:01:23.045123456Z'.`, + }, + "dbprovider": { + Type: schema.TypeString, + Computed: true, + Description: `The database provider.`, + }, + "error": { + Type: schema.TypeList, + Computed: true, + Description: `Output only. The error details in case of state FAILED.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "code": { + Type: schema.TypeInt, + Computed: true, + Description: `The status code, which should be an enum value of google.rpc.Code.`, + }, + "details": { + Type: schema.TypeList, + Computed: true, + Description: `A list of messages that carry the error details.`, + Elem: &schema.Schema{ + Type: schema.TypeMap, + }, + }, + "message": { + Type: schema.TypeString, + Computed: true, + Description: `Human readable message indicating details about the current status.`, + }, + }, + }, + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: `The name of this connection profile resource in the form of projects/{project}/locations/{location}/connectionProfiles/{connectionProfile}.`, + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: `The current connection profile state.`, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func resourceDatabaseMigrationServiceConnectionProfileCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + userAgent, err := generateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + obj := make(map[string]interface{}) + displayNameProp, err := expandDatabaseMigrationServiceConnectionProfileDisplayName(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 + } + labelsProp, err := expandDatabaseMigrationServiceConnectionProfileLabels(d.Get("labels"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp + } + mysqlProp, err := expandDatabaseMigrationServiceConnectionProfileMysql(d.Get("mysql"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("mysql"); !isEmptyValue(reflect.ValueOf(mysqlProp)) && (ok || !reflect.DeepEqual(v, mysqlProp)) { + obj["mysql"] = mysqlProp + } + postgresqlProp, err := expandDatabaseMigrationServiceConnectionProfilePostgresql(d.Get("postgresql"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("postgresql"); !isEmptyValue(reflect.ValueOf(postgresqlProp)) && (ok || !reflect.DeepEqual(v, postgresqlProp)) { + obj["postgresql"] = postgresqlProp + } + cloudsqlProp, err := expandDatabaseMigrationServiceConnectionProfileCloudsql(d.Get("cloudsql"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("cloudsql"); !isEmptyValue(reflect.ValueOf(cloudsqlProp)) && (ok || !reflect.DeepEqual(v, cloudsqlProp)) { + obj["cloudsql"] = cloudsqlProp + } + alloydbProp, err := expandDatabaseMigrationServiceConnectionProfileAlloydb(d.Get("alloydb"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("alloydb"); !isEmptyValue(reflect.ValueOf(alloydbProp)) && (ok || !reflect.DeepEqual(v, alloydbProp)) { + obj["alloydb"] = alloydbProp + } + + url, err := ReplaceVars(d, config, "{{DatabaseMigrationServiceBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles?connectionProfileId={{connection_profile_id}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new ConnectionProfile: %#v", obj) + billingProject := "" + + project, err := getProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for ConnectionProfile: %s", err) + } + billingProject = project + + // err == nil indicates that the billing_project value was found + if bp, err := getBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := SendRequestWithTimeout(config, "POST", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutCreate)) + if err != nil { + return fmt.Errorf("Error creating ConnectionProfile: %s", err) + } + + // Store the ID now + id, err := ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + err = DatabaseMigrationServiceOperationWaitTime( + config, res, project, "Creating ConnectionProfile", userAgent, + d.Timeout(schema.TimeoutCreate)) + + if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create ConnectionProfile: %s", err) + } + + log.Printf("[DEBUG] Finished creating ConnectionProfile %q: %#v", d.Id(), res) + + return resourceDatabaseMigrationServiceConnectionProfileRead(d, meta) +} + +func resourceDatabaseMigrationServiceConnectionProfileRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + userAgent, err := generateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + url, err := ReplaceVars(d, config, "{{DatabaseMigrationServiceBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}") + if err != nil { + return err + } + + billingProject := "" + + project, err := getProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for ConnectionProfile: %s", err) + } + billingProject = project + + // err == nil indicates that the billing_project value was found + if bp, err := getBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := SendRequest(config, "GET", billingProject, url, userAgent, nil) + if err != nil { + return handleNotFoundError(err, d, fmt.Sprintf("DatabaseMigrationServiceConnectionProfile %q", d.Id())) + } + + if err := d.Set("project", project); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + + if err := d.Set("name", flattenDatabaseMigrationServiceConnectionProfileName(res["name"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("display_name", flattenDatabaseMigrationServiceConnectionProfileDisplayName(res["displayName"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("create_time", flattenDatabaseMigrationServiceConnectionProfileCreateTime(res["createTime"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("labels", flattenDatabaseMigrationServiceConnectionProfileLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("state", flattenDatabaseMigrationServiceConnectionProfileState(res["state"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("error", flattenDatabaseMigrationServiceConnectionProfileError(res["error"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("dbprovider", flattenDatabaseMigrationServiceConnectionProfileDbprovider(res["provider"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("mysql", flattenDatabaseMigrationServiceConnectionProfileMysql(res["mysql"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("postgresql", flattenDatabaseMigrationServiceConnectionProfilePostgresql(res["postgresql"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("cloudsql", flattenDatabaseMigrationServiceConnectionProfileCloudsql(res["cloudsql"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + if err := d.Set("alloydb", flattenDatabaseMigrationServiceConnectionProfileAlloydb(res["alloydb"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } + + return nil +} + +func resourceDatabaseMigrationServiceConnectionProfileUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + userAgent, err := generateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + project, err := getProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for ConnectionProfile: %s", err) + } + billingProject = project + + obj := make(map[string]interface{}) + displayNameProp, err := expandDatabaseMigrationServiceConnectionProfileDisplayName(d.Get("display_name"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("display_name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { + obj["displayName"] = displayNameProp + } + labelsProp, err := expandDatabaseMigrationServiceConnectionProfileLabels(d.Get("labels"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp + } + mysqlProp, err := expandDatabaseMigrationServiceConnectionProfileMysql(d.Get("mysql"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("mysql"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, mysqlProp)) { + obj["mysql"] = mysqlProp + } + postgresqlProp, err := expandDatabaseMigrationServiceConnectionProfilePostgresql(d.Get("postgresql"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("postgresql"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, postgresqlProp)) { + obj["postgresql"] = postgresqlProp + } + cloudsqlProp, err := expandDatabaseMigrationServiceConnectionProfileCloudsql(d.Get("cloudsql"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("cloudsql"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, cloudsqlProp)) { + obj["cloudsql"] = cloudsqlProp + } + alloydbProp, err := expandDatabaseMigrationServiceConnectionProfileAlloydb(d.Get("alloydb"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("alloydb"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, alloydbProp)) { + obj["alloydb"] = alloydbProp + } + + url, err := ReplaceVars(d, config, "{{DatabaseMigrationServiceBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating ConnectionProfile %q: %#v", d.Id(), obj) + updateMask := []string{} + + if d.HasChange("display_name") { + updateMask = append(updateMask, "displayName") + } + + if d.HasChange("labels") { + updateMask = append(updateMask, "labels") + } + + if d.HasChange("mysql") { + updateMask = append(updateMask, "mysql") + } + + if d.HasChange("postgresql") { + updateMask = append(updateMask, "postgresql") + } + + if d.HasChange("cloudsql") { + updateMask = append(updateMask, "cloudsql") + } + + if d.HasChange("alloydb") { + updateMask = append(updateMask, "alloydb") + } + // updateMask is a URL parameter but not present in the schema, so ReplaceVars + // won't set it + url, err = AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + if err != nil { + return err + } + + // err == nil indicates that the billing_project value was found + if bp, err := getBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := SendRequestWithTimeout(config, "PATCH", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutUpdate)) + + if err != nil { + return fmt.Errorf("Error updating ConnectionProfile %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ConnectionProfile %q: %#v", d.Id(), res) + } + + err = DatabaseMigrationServiceOperationWaitTime( + config, res, project, "Updating ConnectionProfile", userAgent, + d.Timeout(schema.TimeoutUpdate)) + + if err != nil { + return err + } + + return resourceDatabaseMigrationServiceConnectionProfileRead(d, meta) +} + +func resourceDatabaseMigrationServiceConnectionProfileDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + userAgent, err := generateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + project, err := getProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for ConnectionProfile: %s", err) + } + billingProject = project + + url, err := ReplaceVars(d, config, "{{DatabaseMigrationServiceBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}") + if err != nil { + return err + } + + var obj map[string]interface{} + log.Printf("[DEBUG] Deleting ConnectionProfile %q", d.Id()) + + // err == nil indicates that the billing_project value was found + if bp, err := getBillingProject(d, config); err == nil { + billingProject = bp + } + + res, err := SendRequestWithTimeout(config, "DELETE", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutDelete)) + if err != nil { + return handleNotFoundError(err, d, "ConnectionProfile") + } + + err = DatabaseMigrationServiceOperationWaitTime( + config, res, project, "Deleting ConnectionProfile", userAgent, + d.Timeout(schema.TimeoutDelete)) + + if err != nil { + return err + } + + log.Printf("[DEBUG] Finished deleting ConnectionProfile %q: %#v", d.Id(), res) + return nil +} + +func resourceDatabaseMigrationServiceConnectionProfileImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*Config) + if err := ParseImportId([]string{ + "projects/(?P[^/]+)/locations/(?P[^/]+)/connectionProfiles/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil +} + +func flattenDatabaseMigrationServiceConnectionProfileName(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileDisplayName(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCreateTime(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileLabels(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileState(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileError(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["code"] = + flattenDatabaseMigrationServiceConnectionProfileErrorCode(original["code"], d, config) + transformed["message"] = + flattenDatabaseMigrationServiceConnectionProfileErrorMessage(original["message"], d, config) + transformed["details"] = + flattenDatabaseMigrationServiceConnectionProfileErrorDetails(original["details"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileErrorCode(v interface{}, d *schema.ResourceData, config *Config) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := StringToFixed64(strVal); err == nil { + return intVal + } + } + + // number values are represented as float64 + if floatVal, ok := v.(float64); ok { + intVal := int(floatVal) + return intVal + } + + return v // let terraform core handle it otherwise +} + +func flattenDatabaseMigrationServiceConnectionProfileErrorMessage(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileErrorDetails(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileDbprovider(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileMysql(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["host"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlHost(original["host"], d, config) + transformed["port"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlPort(original["port"], d, config) + transformed["username"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlUsername(original["username"], d, config) + transformed["password"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlPassword(original["password"], d, config) + transformed["password_set"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlPasswordSet(original["passwordSet"], d, config) + transformed["ssl"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlSsl(original["ssl"], d, config) + transformed["cloud_sql_id"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlCloudSqlId(original["cloudSqlId"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileMysqlHost(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlPort(v interface{}, d *schema.ResourceData, config *Config) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := StringToFixed64(strVal); err == nil { + return intVal + } + } + + // number values are represented as float64 + if floatVal, ok := v.(float64); ok { + intVal := int(floatVal) + return intVal + } + + return v // let terraform core handle it otherwise +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlUsername(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlPassword(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("mysql.0.password") +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlPasswordSet(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlSsl(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["type"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlSslType(original["type"], d, config) + transformed["client_key"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlSslClientKey(original["clientKey"], d, config) + transformed["client_certificate"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlSslClientCertificate(original["clientCertificate"], d, config) + transformed["ca_certificate"] = + flattenDatabaseMigrationServiceConnectionProfileMysqlSslCaCertificate(original["caCertificate"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileMysqlSslType(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlSslClientKey(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("mysql.0.ssl.0.client_key") +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlSslClientCertificate(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("mysql.0.ssl.0.client_certificate") +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlSslCaCertificate(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("mysql.0.ssl.0.ca_certificate") +} + +func flattenDatabaseMigrationServiceConnectionProfileMysqlCloudSqlId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresql(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["host"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlHost(original["host"], d, config) + transformed["port"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlPort(original["port"], d, config) + transformed["username"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlUsername(original["username"], d, config) + transformed["password"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlPassword(original["password"], d, config) + transformed["password_set"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlPasswordSet(original["passwordSet"], d, config) + transformed["ssl"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlSsl(original["ssl"], d, config) + transformed["cloud_sql_id"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlCloudSqlId(original["cloudSqlId"], d, config) + transformed["network_architecture"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlNetworkArchitecture(original["networkArchitecture"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlHost(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlPort(v interface{}, d *schema.ResourceData, config *Config) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := StringToFixed64(strVal); err == nil { + return intVal + } + } + + // number values are represented as float64 + if floatVal, ok := v.(float64); ok { + intVal := int(floatVal) + return intVal + } + + return v // let terraform core handle it otherwise +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlUsername(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlPassword(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("postgresql.0.password") +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlPasswordSet(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlSsl(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["type"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslType(original["type"], d, config) + transformed["client_key"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslClientKey(original["clientKey"], d, config) + transformed["client_certificate"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslClientCertificate(original["clientCertificate"], d, config) + transformed["ca_certificate"] = + flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslCaCertificate(original["caCertificate"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslType(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslClientKey(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("postgresql.0.ssl.0.client_key") +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslClientCertificate(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("postgresql.0.ssl.0.client_certificate") +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlSslCaCertificate(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("postgresql.0.ssl.0.ca_certificate") +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlCloudSqlId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfilePostgresqlNetworkArchitecture(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsql(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["cloud_sql_id"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlCloudSqlId(original["cloudSqlId"], d, config) + transformed["settings"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettings(original["settings"], d, config) + transformed["private_ip"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlPrivateIp(original["privateIp"], d, config) + transformed["public_ip"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlPublicIp(original["publicIp"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlCloudSqlId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettings(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["database_version"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseVersion(original["databaseVersion"], d, config) + transformed["user_labels"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsUserLabels(original["userLabels"], d, config) + transformed["tier"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsTier(original["tier"], d, config) + transformed["storage_auto_resize_limit"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsStorageAutoResizeLimit(original["storageAutoResizeLimit"], d, config) + transformed["activation_policy"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsActivationPolicy(original["activationPolicy"], d, config) + transformed["ip_config"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfig(original["ipConfig"], d, config) + transformed["auto_storage_increase"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsAutoStorageIncrease(original["autoStorageIncrease"], d, config) + transformed["database_flags"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseFlags(original["databaseFlags"], d, config) + transformed["data_disk_type"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskType(original["dataDiskType"], d, config) + transformed["data_disk_size_gb"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskSizeGb(original["dataDiskSizeGb"], d, config) + transformed["zone"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsZone(original["zone"], d, config) + transformed["source_id"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsSourceId(original["sourceId"], d, config) + transformed["root_password"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPassword(original["rootPassword"], d, config) + transformed["root_password_set"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPasswordSet(original["rootPasswordSet"], d, config) + transformed["collation"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCollation(original["collation"], d, config) + transformed["cmek_key_name"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName(original["cmekKeyName"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseVersion(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsUserLabels(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsTier(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsStorageAutoResizeLimit(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsActivationPolicy(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfig(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["enable_ipv4"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigEnableIpv4(original["enableIpv4"], d, config) + transformed["private_network"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigPrivateNetwork(original["privateNetwork"], d, config) + transformed["require_ssl"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigRequireSsl(original["requireSsl"], d, config) + transformed["authorized_networks"] = + flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworks(original["authorizedNetworks"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigEnableIpv4(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigPrivateNetwork(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigRequireSsl(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworks(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{}{ + "value": flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksValue(original["value"], d, config), + "label": flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksLabel(original["label"], d, config), + "expire_time": flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksExpireTime(original["expireTime"], d, config), + "ttl": flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksTtl(original["ttl"], d, config), + }) + } + return transformed +} +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksValue(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksLabel(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksExpireTime(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksTtl(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsAutoStorageIncrease(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseFlags(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskType(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskSizeGb(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsZone(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsSourceId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPassword(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("cloudsql.0.settings.0.root_password") +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPasswordSet(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCollation(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlPrivateIp(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileCloudsqlPublicIp(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydb(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["cluster_id"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbClusterId(original["clusterId"], d, config) + transformed["settings"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettings(original["settings"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileAlloydbClusterId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettings(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["initial_user"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUser(original["initialUser"], d, config) + transformed["vpc_network"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsVpcNetwork(original["vpcNetwork"], d, config) + transformed["labels"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsLabels(original["labels"], d, config) + transformed["primary_instance_settings"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettings(original["primaryInstanceSettings"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUser(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["user"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserUser(original["user"], d, config) + transformed["password"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPassword(original["password"], d, config) + transformed["password_set"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPasswordSet(original["passwordSet"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserUser(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPassword(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return d.Get("alloydb.0.settings.0.initial_user.0.password") +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPasswordSet(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsVpcNetwork(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsLabels(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettings(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["id"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsId(original["id"], d, config) + transformed["machine_config"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfig(original["machineConfig"], d, config) + transformed["database_flags"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsDatabaseFlags(original["databaseFlags"], d, config) + transformed["labels"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsLabels(original["labels"], d, config) + transformed["private_ip"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsPrivateIp(original["privateIp"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsId(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfig(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["cpu_count"] = + flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfigCpuCount(original["cpuCount"], d, config) + return []interface{}{transformed} +} +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfigCpuCount(v interface{}, d *schema.ResourceData, config *Config) interface{} { + // Handles the string fixed64 format + if strVal, ok := v.(string); ok { + if intVal, err := StringToFixed64(strVal); err == nil { + return intVal + } + } + + // number values are represented as float64 + if floatVal, ok := v.(float64); ok { + intVal := int(floatVal) + return intVal + } + + return v // let terraform core handle it otherwise +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsDatabaseFlags(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsLabels(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func flattenDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsPrivateIp(v interface{}, d *schema.ResourceData, config *Config) interface{} { + return v +} + +func expandDatabaseMigrationServiceConnectionProfileDisplayName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileLabels(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysql(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{}) + + transformedHost, err := expandDatabaseMigrationServiceConnectionProfileMysqlHost(original["host"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedHost); val.IsValid() && !isEmptyValue(val) { + transformed["host"] = transformedHost + } + + transformedPort, err := expandDatabaseMigrationServiceConnectionProfileMysqlPort(original["port"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !isEmptyValue(val) { + transformed["port"] = transformedPort + } + + transformedUsername, err := expandDatabaseMigrationServiceConnectionProfileMysqlUsername(original["username"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !isEmptyValue(val) { + transformed["username"] = transformedUsername + } + + transformedPassword, err := expandDatabaseMigrationServiceConnectionProfileMysqlPassword(original["password"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPassword); val.IsValid() && !isEmptyValue(val) { + transformed["password"] = transformedPassword + } + + transformedPasswordSet, err := expandDatabaseMigrationServiceConnectionProfileMysqlPasswordSet(original["password_set"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPasswordSet); val.IsValid() && !isEmptyValue(val) { + transformed["passwordSet"] = transformedPasswordSet + } + + transformedSsl, err := expandDatabaseMigrationServiceConnectionProfileMysqlSsl(original["ssl"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSsl); val.IsValid() && !isEmptyValue(val) { + transformed["ssl"] = transformedSsl + } + + transformedCloudSqlId, err := expandDatabaseMigrationServiceConnectionProfileMysqlCloudSqlId(original["cloud_sql_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCloudSqlId); val.IsValid() && !isEmptyValue(val) { + transformed["cloudSqlId"] = transformedCloudSqlId + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlHost(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlPort(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlUsername(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlPassword(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlPasswordSet(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlSsl(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{}) + + transformedType, err := expandDatabaseMigrationServiceConnectionProfileMysqlSslType(original["type"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedType); val.IsValid() && !isEmptyValue(val) { + transformed["type"] = transformedType + } + + transformedClientKey, err := expandDatabaseMigrationServiceConnectionProfileMysqlSslClientKey(original["client_key"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedClientKey); val.IsValid() && !isEmptyValue(val) { + transformed["clientKey"] = transformedClientKey + } + + transformedClientCertificate, err := expandDatabaseMigrationServiceConnectionProfileMysqlSslClientCertificate(original["client_certificate"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedClientCertificate); val.IsValid() && !isEmptyValue(val) { + transformed["clientCertificate"] = transformedClientCertificate + } + + transformedCaCertificate, err := expandDatabaseMigrationServiceConnectionProfileMysqlSslCaCertificate(original["ca_certificate"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCaCertificate); val.IsValid() && !isEmptyValue(val) { + transformed["caCertificate"] = transformedCaCertificate + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlSslType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlSslClientKey(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlSslClientCertificate(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlSslCaCertificate(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileMysqlCloudSqlId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresql(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{}) + + transformedHost, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlHost(original["host"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedHost); val.IsValid() && !isEmptyValue(val) { + transformed["host"] = transformedHost + } + + transformedPort, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlPort(original["port"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPort); val.IsValid() && !isEmptyValue(val) { + transformed["port"] = transformedPort + } + + transformedUsername, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlUsername(original["username"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !isEmptyValue(val) { + transformed["username"] = transformedUsername + } + + transformedPassword, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlPassword(original["password"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPassword); val.IsValid() && !isEmptyValue(val) { + transformed["password"] = transformedPassword + } + + transformedPasswordSet, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlPasswordSet(original["password_set"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPasswordSet); val.IsValid() && !isEmptyValue(val) { + transformed["passwordSet"] = transformedPasswordSet + } + + transformedSsl, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlSsl(original["ssl"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSsl); val.IsValid() && !isEmptyValue(val) { + transformed["ssl"] = transformedSsl + } + + transformedCloudSqlId, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlCloudSqlId(original["cloud_sql_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCloudSqlId); val.IsValid() && !isEmptyValue(val) { + transformed["cloudSqlId"] = transformedCloudSqlId + } + + transformedNetworkArchitecture, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlNetworkArchitecture(original["network_architecture"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedNetworkArchitecture); val.IsValid() && !isEmptyValue(val) { + transformed["networkArchitecture"] = transformedNetworkArchitecture + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlHost(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlPort(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlUsername(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlPassword(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlPasswordSet(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlSsl(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{}) + + transformedType, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlSslType(original["type"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedType); val.IsValid() && !isEmptyValue(val) { + transformed["type"] = transformedType + } + + transformedClientKey, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlSslClientKey(original["client_key"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedClientKey); val.IsValid() && !isEmptyValue(val) { + transformed["clientKey"] = transformedClientKey + } + + transformedClientCertificate, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlSslClientCertificate(original["client_certificate"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedClientCertificate); val.IsValid() && !isEmptyValue(val) { + transformed["clientCertificate"] = transformedClientCertificate + } + + transformedCaCertificate, err := expandDatabaseMigrationServiceConnectionProfilePostgresqlSslCaCertificate(original["ca_certificate"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCaCertificate); val.IsValid() && !isEmptyValue(val) { + transformed["caCertificate"] = transformedCaCertificate + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlSslType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlSslClientKey(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlSslClientCertificate(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlSslCaCertificate(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlCloudSqlId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfilePostgresqlNetworkArchitecture(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsql(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{}) + + transformedCloudSqlId, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlCloudSqlId(original["cloud_sql_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCloudSqlId); val.IsValid() && !isEmptyValue(val) { + transformed["cloudSqlId"] = transformedCloudSqlId + } + + transformedSettings, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettings(original["settings"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSettings); val.IsValid() && !isEmptyValue(val) { + transformed["settings"] = transformedSettings + } + + transformedPrivateIp, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlPrivateIp(original["private_ip"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPrivateIp); val.IsValid() && !isEmptyValue(val) { + transformed["privateIp"] = transformedPrivateIp + } + + transformedPublicIp, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlPublicIp(original["public_ip"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPublicIp); val.IsValid() && !isEmptyValue(val) { + transformed["publicIp"] = transformedPublicIp + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlCloudSqlId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettings(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{}) + + transformedDatabaseVersion, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseVersion(original["database_version"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDatabaseVersion); val.IsValid() && !isEmptyValue(val) { + transformed["databaseVersion"] = transformedDatabaseVersion + } + + transformedUserLabels, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsUserLabels(original["user_labels"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedUserLabels); val.IsValid() && !isEmptyValue(val) { + transformed["userLabels"] = transformedUserLabels + } + + transformedTier, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsTier(original["tier"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedTier); val.IsValid() && !isEmptyValue(val) { + transformed["tier"] = transformedTier + } + + transformedStorageAutoResizeLimit, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsStorageAutoResizeLimit(original["storage_auto_resize_limit"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedStorageAutoResizeLimit); val.IsValid() && !isEmptyValue(val) { + transformed["storageAutoResizeLimit"] = transformedStorageAutoResizeLimit + } + + transformedActivationPolicy, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsActivationPolicy(original["activation_policy"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedActivationPolicy); val.IsValid() && !isEmptyValue(val) { + transformed["activationPolicy"] = transformedActivationPolicy + } + + transformedIpConfig, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfig(original["ip_config"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedIpConfig); val.IsValid() && !isEmptyValue(val) { + transformed["ipConfig"] = transformedIpConfig + } + + transformedAutoStorageIncrease, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsAutoStorageIncrease(original["auto_storage_increase"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAutoStorageIncrease); val.IsValid() && !isEmptyValue(val) { + transformed["autoStorageIncrease"] = transformedAutoStorageIncrease + } + + transformedDatabaseFlags, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseFlags(original["database_flags"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDatabaseFlags); val.IsValid() && !isEmptyValue(val) { + transformed["databaseFlags"] = transformedDatabaseFlags + } + + transformedDataDiskType, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskType(original["data_disk_type"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDataDiskType); val.IsValid() && !isEmptyValue(val) { + transformed["dataDiskType"] = transformedDataDiskType + } + + transformedDataDiskSizeGb, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskSizeGb(original["data_disk_size_gb"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDataDiskSizeGb); val.IsValid() && !isEmptyValue(val) { + transformed["dataDiskSizeGb"] = transformedDataDiskSizeGb + } + + transformedZone, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsZone(original["zone"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedZone); val.IsValid() && !isEmptyValue(val) { + transformed["zone"] = transformedZone + } + + transformedSourceId, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsSourceId(original["source_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSourceId); val.IsValid() && !isEmptyValue(val) { + transformed["sourceId"] = transformedSourceId + } + + transformedRootPassword, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPassword(original["root_password"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedRootPassword); val.IsValid() && !isEmptyValue(val) { + transformed["rootPassword"] = transformedRootPassword + } + + transformedRootPasswordSet, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPasswordSet(original["root_password_set"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedRootPasswordSet); val.IsValid() && !isEmptyValue(val) { + transformed["rootPasswordSet"] = transformedRootPasswordSet + } + + transformedCollation, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCollation(original["collation"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCollation); val.IsValid() && !isEmptyValue(val) { + transformed["collation"] = transformedCollation + } + + transformedCmekKeyName, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName(original["cmek_key_name"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCmekKeyName); val.IsValid() && !isEmptyValue(val) { + transformed["cmekKeyName"] = transformedCmekKeyName + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseVersion(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsUserLabels(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsTier(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsStorageAutoResizeLimit(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsActivationPolicy(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfig(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{}) + + transformedEnableIpv4, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigEnableIpv4(original["enable_ipv4"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEnableIpv4); val.IsValid() && !isEmptyValue(val) { + transformed["enableIpv4"] = transformedEnableIpv4 + } + + transformedPrivateNetwork, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigPrivateNetwork(original["private_network"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPrivateNetwork); val.IsValid() && !isEmptyValue(val) { + transformed["privateNetwork"] = transformedPrivateNetwork + } + + transformedRequireSsl, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigRequireSsl(original["require_ssl"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedRequireSsl); val.IsValid() && !isEmptyValue(val) { + transformed["requireSsl"] = transformedRequireSsl + } + + transformedAuthorizedNetworks, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworks(original["authorized_networks"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAuthorizedNetworks); val.IsValid() && !isEmptyValue(val) { + transformed["authorizedNetworks"] = transformedAuthorizedNetworks + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigEnableIpv4(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigPrivateNetwork(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigRequireSsl(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworks(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{}) + + transformedValue, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksValue(original["value"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !isEmptyValue(val) { + transformed["value"] = transformedValue + } + + transformedLabel, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksLabel(original["label"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedLabel); val.IsValid() && !isEmptyValue(val) { + transformed["label"] = transformedLabel + } + + transformedExpireTime, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksExpireTime(original["expire_time"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedExpireTime); val.IsValid() && !isEmptyValue(val) { + transformed["expireTime"] = transformedExpireTime + } + + transformedTtl, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksTtl(original["ttl"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedTtl); val.IsValid() && !isEmptyValue(val) { + transformed["ttl"] = transformedTtl + } + + req = append(req, transformed) + } + return req, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksValue(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksLabel(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksExpireTime(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsIpConfigAuthorizedNetworksTtl(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsAutoStorageIncrease(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseFlags(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDataDiskSizeGb(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsZone(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsSourceId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPassword(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsRootPasswordSet(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCollation(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlPrivateIp(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileCloudsqlPublicIp(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydb(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{}) + + transformedClusterId, err := expandDatabaseMigrationServiceConnectionProfileAlloydbClusterId(original["cluster_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedClusterId); val.IsValid() && !isEmptyValue(val) { + transformed["clusterId"] = transformedClusterId + } + + transformedSettings, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettings(original["settings"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedSettings); val.IsValid() && !isEmptyValue(val) { + transformed["settings"] = transformedSettings + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbClusterId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettings(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{}) + + transformedInitialUser, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUser(original["initial_user"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedInitialUser); val.IsValid() && !isEmptyValue(val) { + transformed["initialUser"] = transformedInitialUser + } + + transformedVpcNetwork, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsVpcNetwork(original["vpc_network"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedVpcNetwork); val.IsValid() && !isEmptyValue(val) { + transformed["vpcNetwork"] = transformedVpcNetwork + } + + transformedLabels, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsLabels(original["labels"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedLabels); val.IsValid() && !isEmptyValue(val) { + transformed["labels"] = transformedLabels + } + + transformedPrimaryInstanceSettings, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettings(original["primary_instance_settings"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPrimaryInstanceSettings); val.IsValid() && !isEmptyValue(val) { + transformed["primaryInstanceSettings"] = transformedPrimaryInstanceSettings + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUser(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{}) + + transformedUser, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserUser(original["user"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedUser); val.IsValid() && !isEmptyValue(val) { + transformed["user"] = transformedUser + } + + transformedPassword, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPassword(original["password"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPassword); val.IsValid() && !isEmptyValue(val) { + transformed["password"] = transformedPassword + } + + transformedPasswordSet, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPasswordSet(original["password_set"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPasswordSet); val.IsValid() && !isEmptyValue(val) { + transformed["passwordSet"] = transformedPasswordSet + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserUser(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPassword(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsInitialUserPasswordSet(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsVpcNetwork(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsLabels(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettings(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{}) + + transformedId, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsId(original["id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedId); val.IsValid() && !isEmptyValue(val) { + transformed["id"] = transformedId + } + + transformedMachineConfig, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfig(original["machine_config"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedMachineConfig); val.IsValid() && !isEmptyValue(val) { + transformed["machineConfig"] = transformedMachineConfig + } + + transformedDatabaseFlags, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsDatabaseFlags(original["database_flags"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDatabaseFlags); val.IsValid() && !isEmptyValue(val) { + transformed["databaseFlags"] = transformedDatabaseFlags + } + + transformedLabels, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsLabels(original["labels"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedLabels); val.IsValid() && !isEmptyValue(val) { + transformed["labels"] = transformedLabels + } + + transformedPrivateIp, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsPrivateIp(original["private_ip"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPrivateIp); val.IsValid() && !isEmptyValue(val) { + transformed["privateIp"] = transformedPrivateIp + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfig(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{}) + + transformedCpuCount, err := expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfigCpuCount(original["cpu_count"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCpuCount); val.IsValid() && !isEmptyValue(val) { + transformed["cpuCount"] = transformedCpuCount + } + + return transformed, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsMachineConfigCpuCount(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsDatabaseFlags(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsLabels(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandDatabaseMigrationServiceConnectionProfileAlloydbSettingsPrimaryInstanceSettingsPrivateIp(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} diff --git a/google/resource_database_migration_service_connection_profile_generated_test.go b/google/resource_database_migration_service_connection_profile_generated_test.go new file mode 100644 index 00000000000..59398a55361 --- /dev/null +++ b/google/resource_database_migration_service_connection_profile_generated_test.go @@ -0,0 +1,339 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfileCloudsqlExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": RandString(t, 10), + } + + VcrTest(t, resource.TestCase{ + PreCheck: func() { AccTestPreCheck(t) }, + ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckDatabaseMigrationServiceConnectionProfileDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfileCloudsqlExample(context), + }, + { + ResourceName: "google_database_migration_service_connection_profile.cloudsqlprofile", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"connection_profile_id", "location", "mysql.0.password", "mysql.0.ssl.0.ca_certificate", "mysql.0.ssl.0.client_certificate", "mysql.0.ssl.0.client_key"}, + }, + }, + }) +} + +func testAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfileCloudsqlExample(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "project" { +} + +resource "google_sql_database_instance" "cloudsqldb" { + name = "tf-test-my-database%{random_suffix}" + database_version = "MYSQL_5_7" + settings { + tier = "db-n1-standard-1" + deletion_protection_enabled = false + } + deletion_protection = false +} + +resource "google_sql_ssl_cert" "sql_client_cert" { + common_name = "tf-test-my-cert%{random_suffix}" + instance = google_sql_database_instance.cloudsqldb.name + + depends_on = [google_sql_database_instance.cloudsqldb] +} + +resource "google_sql_user" "sqldb_user" { + name = "tf-test-my-username%{random_suffix}" + instance = google_sql_database_instance.cloudsqldb.name + password = "tf-test-my-password%{random_suffix}" + + depends_on = [google_sql_ssl_cert.sql_client_cert] +} + + + +resource "google_database_migration_service_connection_profile" "cloudsqlprofile" { + location = "us-central1" + connection_profile_id = "tf-test-my-fromprofileid%{random_suffix}" + display_name = "tf-test-my-fromprofileid%{random_suffix}_display" + labels = { + foo = "bar" + } + mysql { + host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address + port = 3306 + username = google_sql_user.sqldb_user.name + password = google_sql_user.sqldb_user.password + ssl { + client_key = google_sql_ssl_cert.sql_client_cert.private_key + client_certificate = google_sql_ssl_cert.sql_client_cert.cert + ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert + } + cloud_sql_id = "tf-test-my-database%{random_suffix}" + } + + depends_on = [google_sql_user.sqldb_user] +} + + +resource "google_database_migration_service_connection_profile" "cloudsqlprofile_destination" { + location = "us-central1" + connection_profile_id = "tf-test-my-toprofileid%{random_suffix}" + display_name = "tf-test-my-toprofileid%{random_suffix}_displayname" + labels = { + foo = "bar" + } + cloudsql { + settings { + database_version = "MYSQL_5_7" + user_labels = { + cloudfoo = "cloudbar" + } + tier = "db-n1-standard-1" + storage_auto_resize_limit = "0" + activation_policy = "ALWAYS" + ip_config { + enable_ipv4 = true + require_ssl = "true" + } + auto_storage_increase = true + data_disk_type = "PD_HDD" + data_disk_size_gb = "11" + zone = "us-central1-b" + source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/tf-test-my-fromprofileid%{random_suffix}" + root_password = "testpasscloudsql" + } + + + } + depends_on = [google_database_migration_service_connection_profile.cloudsqlprofile] +} +`, context) +} + +func TestAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfilePostgresExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": RandString(t, 10), + } + + VcrTest(t, resource.TestCase{ + PreCheck: func() { AccTestPreCheck(t) }, + ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckDatabaseMigrationServiceConnectionProfileDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfilePostgresExample(context), + }, + { + ResourceName: "google_database_migration_service_connection_profile.postgresprofile", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"connection_profile_id", "location", "postgresql.0.password", "postgresql.0.ssl.0.ca_certificate", "postgresql.0.ssl.0.client_certificate", "postgresql.0.ssl.0.client_key"}, + }, + }, + }) +} + +func testAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfilePostgresExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_sql_database_instance" "postgresqldb" { + name = "tf-test-my-database%{random_suffix}" + database_version = "POSTGRES_12" + settings { + tier = "db-custom-2-13312" + } + deletion_protection = false +} + +resource "google_sql_ssl_cert" "sql_client_cert" { + common_name = "tf-test-my-cert%{random_suffix}" + instance = google_sql_database_instance.postgresqldb.name + + depends_on = [google_sql_database_instance.postgresqldb] +} + +resource "google_sql_user" "sqldb_user" { + name = "tf-test-my-username%{random_suffix}" + instance = google_sql_database_instance.postgresqldb.name + password = "tf-test-my-password%{random_suffix}" + + + depends_on = [google_sql_ssl_cert.sql_client_cert] +} + +resource "google_database_migration_service_connection_profile" "postgresprofile" { + location = "us-central1" + connection_profile_id = "tf-test-my-profileid%{random_suffix}" + display_name = "tf-test-my-profileid%{random_suffix}_display" + labels = { + foo = "bar" + } + postgresql { + host = google_sql_database_instance.postgresqldb.ip_address.0.ip_address + port = 5432 + username = google_sql_user.sqldb_user.name + password = google_sql_user.sqldb_user.password + ssl { + client_key = google_sql_ssl_cert.sql_client_cert.private_key + client_certificate = google_sql_ssl_cert.sql_client_cert.cert + ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert + } + cloud_sql_id = "tf-test-my-database%{random_suffix}" + } + depends_on = [google_sql_user.sqldb_user] +} +`, context) +} + +func TestAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfileAlloydbExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": RandString(t, 10), + } + + VcrTest(t, resource.TestCase{ + PreCheck: func() { AccTestPreCheck(t) }, + ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckDatabaseMigrationServiceConnectionProfileDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfileAlloydbExample(context), + }, + { + ResourceName: "google_database_migration_service_connection_profile.alloydbprofile", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"connection_profile_id", "location", "alloydb.0.settings.0.initial_user.0.password"}, + }, + }, + }) +} + +func testAccDatabaseMigrationServiceConnectionProfile_databaseMigrationServiceConnectionProfileAlloydbExample(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "project" { +} + +resource "google_compute_network" "default" { + name = "tf-test-alloydb-cp%{random_suffix}" +} + +resource "google_compute_global_address" "private_ip_alloc" { + name = "private-ip-alloc%{random_suffix}" + address_type = "INTERNAL" + purpose = "VPC_PEERING" + prefix_length = 16 + network = google_compute_network.default.id + + depends_on = [google_compute_network.default] +} + +resource "google_service_networking_connection" "vpc_connection" { + network = google_compute_network.default.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] + + depends_on = [google_compute_global_address.private_ip_alloc] +} + + +resource "google_database_migration_service_connection_profile" "alloydbprofile" { + location = "us-central1" + connection_profile_id = "tf-test-my-profileid%{random_suffix}" + display_name = "tf-test-my-profileid%{random_suffix}_display" + labels = { + foo = "bar" + } + alloydb { + cluster_id = "dbmsalloycluster%{random_suffix}" + settings { + initial_user { + user = "alloyuser%{random_suffix}" + password = "alloypass%{random_suffix}" + } + vpc_network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + labels = { + alloyfoo = "alloybar" + } + primary_instance_settings { + id = "priminstid" + machine_config { + cpu_count = 2 + } + database_flags = { + } + labels = { + alloysinstfoo = "allowinstbar" + } + } + } + } + + depends_on = [google_service_networking_connection.vpc_connection] +} +`, context) +} + +func testAccCheckDatabaseMigrationServiceConnectionProfileDestroyProducer(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_database_migration_service_connection_profile" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := GoogleProviderConfig(t) + + url, err := replaceVarsForTest(config, rs, "{{DatabaseMigrationServiceBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}") + if err != nil { + return err + } + + billingProject := "" + + if config.BillingProject != "" { + billingProject = config.BillingProject + } + + _, err = SendRequest(config, "GET", billingProject, url, config.UserAgent, nil) + if err == nil { + return fmt.Errorf("DatabaseMigrationServiceConnectionProfile still exists at %s", url) + } + } + + return nil + } +} diff --git a/google/resource_database_migration_service_connection_profile_sweeper_test.go b/google/resource_database_migration_service_connection_profile_sweeper_test.go new file mode 100644 index 00000000000..76fd13f5504 --- /dev/null +++ b/google/resource_database_migration_service_connection_profile_sweeper_test.go @@ -0,0 +1,128 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "context" + "log" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func init() { + resource.AddTestSweepers("DatabaseMigrationServiceConnectionProfile", &resource.Sweeper{ + Name: "DatabaseMigrationServiceConnectionProfile", + F: testSweepDatabaseMigrationServiceConnectionProfile, + }) +} + +// At the time of writing, the CI only passes us-central1 as the region +func testSweepDatabaseMigrationServiceConnectionProfile(region string) error { + resourceName := "DatabaseMigrationServiceConnectionProfile" + log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) + + config, err := SharedConfigForRegion(region) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) + return err + } + + err = config.LoadAndValidate(context.Background()) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) + return err + } + + t := &testing.T{} + billingId := GetTestBillingAccountFromEnv(t) + + // Setup variables to replace in list template + d := &ResourceDataMock{ + FieldsInSchema: map[string]interface{}{ + "project": config.Project, + "region": region, + "location": region, + "zone": "-", + "billing_account": billingId, + }, + } + + listTemplate := strings.Split("https://datamigration.googleapis.com/v1/projects/{{project}}/locations/{{location}}/connectionProfiles", "?")[0] + listUrl, err := ReplaceVars(d, config, listTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) + return nil + } + + res, err := SendRequest(config, "GET", config.Project, listUrl, config.UserAgent, nil) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) + return nil + } + + resourceList, ok := res["connectionProfiles"] + if !ok { + log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") + return nil + } + + rl := resourceList.([]interface{}) + + log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) + // Keep count of items that aren't sweepable for logging. + nonPrefixCount := 0 + for _, ri := range rl { + obj := ri.(map[string]interface{}) + var name string + // Id detected in the delete URL, attempt to use id. + if obj["id"] != nil { + name = GetResourceNameFromSelfLink(obj["id"].(string)) + } else if obj["name"] != nil { + name = GetResourceNameFromSelfLink(obj["name"].(string)) + } else { + log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) + return nil + } + // Skip resources that shouldn't be sweeped + if !IsSweepableTestResource(name) { + nonPrefixCount++ + continue + } + + deleteTemplate := "https://datamigration.googleapis.com/v1/projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}" + deleteUrl, err := ReplaceVars(d, config, deleteTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) + return nil + } + deleteUrl = deleteUrl + name + + // Don't wait on operations as we may have a lot to delete + _, err = SendRequest(config, "DELETE", config.Project, deleteUrl, config.UserAgent, nil) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) + } else { + log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) + } + } + + if nonPrefixCount > 0 { + log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) + } + + return nil +} diff --git a/google/resource_database_migration_service_connection_profile_test.go b/google/resource_database_migration_service_connection_profile_test.go new file mode 100644 index 00000000000..4cbb6ac3ad9 --- /dev/null +++ b/google/resource_database_migration_service_connection_profile_test.go @@ -0,0 +1,78 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccDatabaseMigrationServiceConnectionProfile_update(t *testing.T) { + t.Parallel() + + suffix := map[string]interface{}{ + "random_suffix": RandString(t, 10), + } + + VcrTest(t, resource.TestCase{ + PreCheck: func() { AccTestPreCheck(t) }, + ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccDatabaseMigrationServiceConnectionProfile_basic(suffix), + }, + { + ResourceName: "google_database_migration_service_connection_profile.default", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"connection_profile_id", "location", "mysql.0.password"}, + }, + { + Config: testAccDatabaseMigrationServiceConnectionProfile_update(suffix), + }, + { + ResourceName: "google_database_migration_service_connection_profile.default", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"connection_profile_id", "location", "mysql.0.password"}, + }, + }, + }) +} + +func testAccDatabaseMigrationServiceConnectionProfile_basic(context map[string]interface{}) string { + return Nprintf(` +resource "google_database_migration_service_connection_profile" "default" { + location = "us-central1" + connection_profile_id = "tf-test-dbms-connection-profile%{random_suffix}" + display_name = "tf-test-dbms-connection-profile-display%{random_suffix}" + labels = { + foo = "bar" + } + mysql { + host = "10.20.30.40" + port = 3306 + username = "tf-test-dbms-test-user%{random_suffix}" + password = "tf-test-dbms-test-pass%{random_suffix}" + } +} +`, context) +} + +func testAccDatabaseMigrationServiceConnectionProfile_update(context map[string]interface{}) string { + return Nprintf(` +resource "google_database_migration_service_connection_profile" "default" { + location = "us-central1" + connection_profile_id = "tf-test-dbms-connection-profile%{random_suffix}" + display_name = "tf-test-dbms-connection-profile-updated-display%{random_suffix}" + labels = { + bar = "foo" + } + mysql { + host = "10.20.30.50" + port = 3306 + username = "tf-test-update-dbms-test-user%{random_suffix}" + password = "tf-test-update-dbms-test-pass%{random_suffix}" + } +} +`, context) +} diff --git a/website/docs/r/database_migration_service_connection_profile.html.markdown b/website/docs/r/database_migration_service_connection_profile.html.markdown new file mode 100644 index 00000000000..e69dbfbb113 --- /dev/null +++ b/website/docs/r/database_migration_service_connection_profile.html.markdown @@ -0,0 +1,698 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in +# .github/CONTRIBUTING.md. +# +# ---------------------------------------------------------------------------- +subcategory: "DatabaseMigrationService" +description: |- + A connection profile definition. +--- + +# google\_database\_migration\_service\_connection\_profile + +A connection profile definition. + + +To get more information about ConnectionProfile, see: + +* [API documentation](https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.connectionProfiles/create) +* How-to Guides + * [Database Migration](https://cloud.google.com/database-migration/docs/) + +~> **Warning:** All arguments including the following potentially sensitive +values will be stored in the raw state as plain text: `mysql.password`, `mysql.ssl.client_key`, `mysql.ssl.client_certificate`, `mysql.ssl.ca_certificate`, `postgresql.password`, `postgresql.ssl.client_key`, `postgresql.ssl.client_certificate`, `postgresql.ssl.ca_certificate`, `cloudsql.settings.root_password`, `alloydb.settings.initial_user.password`. +[Read more about sensitive data in state](https://www.terraform.io/language/state/sensitive-data). + + +## Example Usage - Database Migration Service Connection Profile Cloudsql + + +```hcl +data "google_project" "project" { +} + +resource "google_sql_database_instance" "cloudsqldb" { + name = "my-database" + database_version = "MYSQL_5_7" + settings { + tier = "db-n1-standard-1" + deletion_protection_enabled = false + } + deletion_protection = false +} + +resource "google_sql_ssl_cert" "sql_client_cert" { + common_name = "my-cert" + instance = google_sql_database_instance.cloudsqldb.name + + depends_on = [google_sql_database_instance.cloudsqldb] +} + +resource "google_sql_user" "sqldb_user" { + name = "my-username" + instance = google_sql_database_instance.cloudsqldb.name + password = "my-password" + + depends_on = [google_sql_ssl_cert.sql_client_cert] +} + + + +resource "google_database_migration_service_connection_profile" "cloudsqlprofile" { + location = "us-central1" + connection_profile_id = "my-fromprofileid" + display_name = "my-fromprofileid_display" + labels = { + foo = "bar" + } + mysql { + host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address + port = 3306 + username = google_sql_user.sqldb_user.name + password = google_sql_user.sqldb_user.password + ssl { + client_key = google_sql_ssl_cert.sql_client_cert.private_key + client_certificate = google_sql_ssl_cert.sql_client_cert.cert + ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert + } + cloud_sql_id = "my-database" + } + + depends_on = [google_sql_user.sqldb_user] +} + + +resource "google_database_migration_service_connection_profile" "cloudsqlprofile_destination" { + location = "us-central1" + connection_profile_id = "my-toprofileid" + display_name = "my-toprofileid_displayname" + labels = { + foo = "bar" + } + cloudsql { + settings { + database_version = "MYSQL_5_7" + user_labels = { + cloudfoo = "cloudbar" + } + tier = "db-n1-standard-1" + storage_auto_resize_limit = "0" + activation_policy = "ALWAYS" + ip_config { + enable_ipv4 = true + require_ssl = "true" + } + auto_storage_increase = true + data_disk_type = "PD_HDD" + data_disk_size_gb = "11" + zone = "us-central1-b" + source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/my-fromprofileid" + root_password = "testpasscloudsql" + } + + + } + depends_on = [google_database_migration_service_connection_profile.cloudsqlprofile] +} +``` + +## Example Usage - Database Migration Service Connection Profile Postgres + + +```hcl +resource "google_sql_database_instance" "postgresqldb" { + name = "my-database" + database_version = "POSTGRES_12" + settings { + tier = "db-custom-2-13312" + } + deletion_protection = false +} + +resource "google_sql_ssl_cert" "sql_client_cert" { + common_name = "my-cert" + instance = google_sql_database_instance.postgresqldb.name + + depends_on = [google_sql_database_instance.postgresqldb] +} + +resource "google_sql_user" "sqldb_user" { + name = "my-username" + instance = google_sql_database_instance.postgresqldb.name + password = "my-password" + + + depends_on = [google_sql_ssl_cert.sql_client_cert] +} + +resource "google_database_migration_service_connection_profile" "postgresprofile" { + location = "us-central1" + connection_profile_id = "my-profileid" + display_name = "my-profileid_display" + labels = { + foo = "bar" + } + postgresql { + host = google_sql_database_instance.postgresqldb.ip_address.0.ip_address + port = 5432 + username = google_sql_user.sqldb_user.name + password = google_sql_user.sqldb_user.password + ssl { + client_key = google_sql_ssl_cert.sql_client_cert.private_key + client_certificate = google_sql_ssl_cert.sql_client_cert.cert + ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert + } + cloud_sql_id = "my-database" + } + depends_on = [google_sql_user.sqldb_user] +} +``` + +## Example Usage - Database Migration Service Connection Profile Alloydb + + +```hcl +data "google_project" "project" { +} + +resource "google_compute_network" "default" { + name = "tf-test-alloydb-cp%{random_suffix}" +} + +resource "google_compute_global_address" "private_ip_alloc" { + name = "private-ip-alloc%{random_suffix}" + address_type = "INTERNAL" + purpose = "VPC_PEERING" + prefix_length = 16 + network = google_compute_network.default.id + + depends_on = [google_compute_network.default] +} + +resource "google_service_networking_connection" "vpc_connection" { + network = google_compute_network.default.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] + + depends_on = [google_compute_global_address.private_ip_alloc] +} + + +resource "google_database_migration_service_connection_profile" "alloydbprofile" { + location = "us-central1" + connection_profile_id = "my-profileid" + display_name = "my-profileid_display" + labels = { + foo = "bar" + } + alloydb { + cluster_id = "dbmsalloycluster%{random_suffix}" + settings { + initial_user { + user = "alloyuser%{random_suffix}" + password = "alloypass%{random_suffix}" + } + vpc_network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" + labels = { + alloyfoo = "alloybar" + } + primary_instance_settings { + id = "priminstid" + machine_config { + cpu_count = 2 + } + database_flags = { + } + labels = { + alloysinstfoo = "allowinstbar" + } + } + } + } + + depends_on = [google_service_networking_connection.vpc_connection] +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `connection_profile_id` - + (Required) + The ID of the connection profile. + + +- - - + + +* `display_name` - + (Optional) + The connection profile display name. + +* `labels` - + (Optional) + The resource labels for connection profile to use to annotate any related underlying resources such as Compute Engine VMs. + +* `mysql` - + (Optional) + Specifies connection parameters required specifically for MySQL databases. + Structure is [documented below](#nested_mysql). + +* `postgresql` - + (Optional) + Specifies connection parameters required specifically for PostgreSQL databases. + Structure is [documented below](#nested_postgresql). + +* `cloudsql` - + (Optional) + Specifies required connection parameters, and, optionally, the parameters required to create a Cloud SQL destination database instance. + Structure is [documented below](#nested_cloudsql). + +* `alloydb` - + (Optional) + Specifies required connection parameters, and the parameters required to create an AlloyDB destination cluster. + Structure is [documented below](#nested_alloydb). + +* `location` - + (Optional) + The location where the connection profile should reside. + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + + +The `mysql` block supports: + +* `host` - + (Required) + Required. The IP or hostname of the source MySQL database. + +* `port` - + (Required) + Required. The network port of the source MySQL database. + +* `username` - + (Required) + Required. The username that Database Migration Service will use to connect to the database. The value is encrypted when stored in Database Migration Service. + +* `password` - + (Required) + Required. Input only. The password for the user that Database Migration Service will be using to connect to the database. + This field is not returned on request, and the value is encrypted when stored in Database Migration Service. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `password_set` - + (Output) + Output only. Indicates If this connection profile password is stored. + +* `ssl` - + (Optional) + SSL configuration for the destination to connect to the source database. + Structure is [documented below](#nested_ssl). + +* `cloud_sql_id` - + (Optional) + If the source is a Cloud SQL database, use this field to provide the Cloud SQL instance ID of the source. + + +The `ssl` block supports: + +* `type` - + (Output) + The current connection profile state. + +* `client_key` - + (Optional) + Input only. The unencrypted PKCS#1 or PKCS#8 PEM-encoded private key associated with the Client Certificate. + If this field is used then the 'clientCertificate' field is mandatory. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `client_certificate` - + (Optional) + Input only. The x509 PEM-encoded certificate that will be used by the replica to authenticate against the source database server. + If this field is used then the 'clientKey' field is mandatory + **Note**: This property is sensitive and will not be displayed in the plan. + +* `ca_certificate` - + (Required) + Required. Input only. The x509 PEM-encoded certificate of the CA that signed the source database server's certificate. + The replica will use this certificate to verify it's connecting to the right host. + **Note**: This property is sensitive and will not be displayed in the plan. + +The `postgresql` block supports: + +* `host` - + (Required) + Required. The IP or hostname of the source MySQL database. + +* `port` - + (Required) + Required. The network port of the source MySQL database. + +* `username` - + (Required) + Required. The username that Database Migration Service will use to connect to the database. The value is encrypted when stored in Database Migration Service. + +* `password` - + (Required) + Required. Input only. The password for the user that Database Migration Service will be using to connect to the database. + This field is not returned on request, and the value is encrypted when stored in Database Migration Service. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `password_set` - + (Output) + Output only. Indicates If this connection profile password is stored. + +* `ssl` - + (Optional) + SSL configuration for the destination to connect to the source database. + Structure is [documented below](#nested_ssl). + +* `cloud_sql_id` - + (Optional) + If the source is a Cloud SQL database, use this field to provide the Cloud SQL instance ID of the source. + +* `network_architecture` - + (Output) + Output only. If the source is a Cloud SQL database, this field indicates the network architecture it's associated with. + + +The `ssl` block supports: + +* `type` - + (Output) + The current connection profile state. + +* `client_key` - + (Optional) + Input only. The unencrypted PKCS#1 or PKCS#8 PEM-encoded private key associated with the Client Certificate. + If this field is used then the 'clientCertificate' field is mandatory. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `client_certificate` - + (Optional) + Input only. The x509 PEM-encoded certificate that will be used by the replica to authenticate against the source database server. + If this field is used then the 'clientKey' field is mandatory + **Note**: This property is sensitive and will not be displayed in the plan. + +* `ca_certificate` - + (Required) + Required. Input only. The x509 PEM-encoded certificate of the CA that signed the source database server's certificate. + The replica will use this certificate to verify it's connecting to the right host. + **Note**: This property is sensitive and will not be displayed in the plan. + +The `cloudsql` block supports: + +* `cloud_sql_id` - + (Output) + Output only. The Cloud SQL instance ID that this connection profile is associated with. + +* `settings` - + (Optional) + Immutable. Metadata used to create the destination Cloud SQL database. + Structure is [documented below](#nested_settings). + +* `private_ip` - + (Output) + Output only. The Cloud SQL database instance's private IP. + +* `public_ip` - + (Output) + Output only. The Cloud SQL database instance's public IP. + + +The `settings` block supports: + +* `database_version` - + (Optional) + The database engine type and version. + Currently supported values located at https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.connectionProfiles#sqldatabaseversion + +* `user_labels` - + (Optional) + The resource labels for a Cloud SQL instance to use to annotate any related underlying resources such as Compute Engine VMs. + +* `tier` - + (Optional) + The tier (or machine type) for this instance, for example: db-n1-standard-1 (MySQL instances) or db-custom-1-3840 (PostgreSQL instances). + For more information, see https://cloud.google.com/sql/docs/mysql/instance-settings + +* `storage_auto_resize_limit` - + (Optional) + The maximum size to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit. + +* `activation_policy` - + (Optional) + The activation policy specifies when the instance is activated; it is applicable only when the instance state is 'RUNNABLE'. + Possible values are: `ALWAYS`, `NEVER`. + +* `ip_config` - + (Optional) + The settings for IP Management. This allows to enable or disable the instance IP and manage which external networks can connect to the instance. The IPv4 address cannot be disabled. + Structure is [documented below](#nested_ip_config). + +* `auto_storage_increase` - + (Optional) + If you enable this setting, Cloud SQL checks your available storage every 30 seconds. If the available storage falls below a threshold size, Cloud SQL automatically adds additional storage capacity. + If the available storage repeatedly falls below the threshold size, Cloud SQL continues to add storage until it reaches the maximum of 30 TB. + +* `database_flags` - + (Optional) + The database flags passed to the Cloud SQL instance at startup. + +* `data_disk_type` - + (Optional) + The type of storage. + Possible values are: `PD_SSD`, `PD_HDD`. + +* `data_disk_size_gb` - + (Optional) + The storage capacity available to the database, in GB. The minimum (and default) size is 10GB. + +* `zone` - + (Optional) + The Google Cloud Platform zone where your Cloud SQL datdabse instance is located. + +* `source_id` - + (Required) + The Database Migration Service source connection profile ID, in the format: projects/my_project_name/locations/us-central1/connectionProfiles/connection_profile_ID + +* `root_password` - + (Optional) + Input only. Initial root password. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `root_password_set` - + (Output) + Output only. Indicates If this connection profile root password is stored. + +* `collation` - + (Optional) + The Cloud SQL default instance level collation. + +* `cmek_key_name` - + (Optional) + The KMS key name used for the csql instance. + + +The `ip_config` block supports: + +* `enable_ipv4` - + (Optional) + Whether the instance should be assigned an IPv4 address or not. + +* `private_network` - + (Optional) + The resource link for the VPC network from which the Cloud SQL instance is accessible for private IP. For example, projects/myProject/global/networks/default. + This setting can be updated, but it cannot be removed after it is set. + +* `require_ssl` - + (Optional) + Whether SSL connections over IP should be enforced or not. + +* `authorized_networks` - + (Optional) + The list of external networks that are allowed to connect to the instance using the IP. + Structure is [documented below](#nested_authorized_networks). + + +The `authorized_networks` block supports: + +* `value` - + (Required) + The allowlisted value for the access control list. + +* `label` - + (Optional) + A label to identify this entry. + +* `expire_time` - + (Optional) + The time when this access control entry expires in RFC 3339 format. + +* `ttl` - + (Optional) + Input only. The time-to-leave of this access control entry. + +The `alloydb` block supports: + +* `cluster_id` - + (Required) + Required. The AlloyDB cluster ID that this connection profile is associated with. + +* `settings` - + (Optional) + Immutable. Metadata used to create the destination AlloyDB cluster. + Structure is [documented below](#nested_settings). + + +The `settings` block supports: + +* `initial_user` - + (Required) + Required. Input only. Initial user to setup during cluster creation. + Structure is [documented below](#nested_initial_user). + +* `vpc_network` - + (Required) + Required. The resource link for the VPC network in which cluster resources are created and from which they are accessible via Private IP. The network must belong to the same project as the cluster. + It is specified in the form: 'projects/{project_number}/global/networks/{network_id}'. This is required to create a cluster. + +* `labels` - + (Optional) + Labels for the AlloyDB cluster created by DMS. + +* `primary_instance_settings` - + (Optional) + Settings for the cluster's primary instance + Structure is [documented below](#nested_primary_instance_settings). + + +The `initial_user` block supports: + +* `user` - + (Required) + The database username. + +* `password` - + (Required) + The initial password for the user. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `password_set` - + (Output) + Output only. Indicates if the initialUser.password field has been set. + +The `primary_instance_settings` block supports: + +* `id` - + (Required) + The database username. + +* `machine_config` - + (Required) + Configuration for the machines that host the underlying database engine. + Structure is [documented below](#nested_machine_config). + +* `database_flags` - + (Optional) + Database flags to pass to AlloyDB when DMS is creating the AlloyDB cluster and instances. See the AlloyDB documentation for how these can be used. + +* `labels` - + (Optional) + Labels for the AlloyDB primary instance created by DMS. + +* `private_ip` - + (Output) + Output only. The private IP address for the Instance. This is the connection endpoint for an end-user application. + + +The `machine_config` block supports: + +* `cpu_count` - + (Required) + The number of CPU's in the VM instance. + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}` + +* `name` - + The name of this connection profile resource in the form of projects/{project}/locations/{location}/connectionProfiles/{connectionProfile}. + +* `create_time` - + Output only. The timestamp when the resource was created. A timestamp in RFC3339 UTC 'Zulu' format, accurate to nanoseconds. Example: '2014-10-02T15:01:23.045123456Z'. + +* `state` - + The current connection profile state. + +* `error` - + Output only. The error details in case of state FAILED. + Structure is [documented below](#nested_error). + +* `dbprovider` - + The database provider. + + +The `error` block contains: + +* `code` - + (Output) + The status code, which should be an enum value of google.rpc.Code. + +* `message` - + (Output) + Human readable message indicating details about the current status. + +* `details` - + (Output) + A list of messages that carry the error details. + +## Timeouts + +This resource provides the following +[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: + +- `create` - Default is 60 minutes. +- `update` - Default is 60 minutes. +- `delete` - Default is 60 minutes. + +## Import + + +ConnectionProfile can be imported using any of these accepted formats: + +``` +$ terraform import google_database_migration_service_connection_profile.default projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}} +$ terraform import google_database_migration_service_connection_profile.default {{project}}/{{location}}/{{connection_profile_id}} +$ terraform import google_database_migration_service_connection_profile.default {{location}}/{{connection_profile_id}} +``` + +## User Project Overrides + +This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).