hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.31k stars 1.73k forks source link

googleapi: Error 400: Replica configuration does not contain the dump file path when replicating from an on-premises master., errorReplicaConfigurationMissingDumpFilePath #19634

Open ns-rkankanala opened 3 days ago

ns-rkankanala commented 3 days ago

Community Note

Terraform Version & Provider Version(s)

Terraform vX.X.X on

Affected Resource(s)

resource "google_sql_database_instance" "replica2" {

name = "test2" database_version = "MYSQL_8_0" region = "us-west1" settings { tier = "db-custom-1-3840" ip_configuration { ipv4_enabled = false private_network = "projects/ns/global/networks/s" } } master_instance_name = google_sql_source_representation_instance.instance2.name replica_configuration {

dump_file_path = "gs://bucket/dump.sql"

failover_target         = false
username                = "XXXX"
password                = "XXX"
#connect_retry_interval  = 60
#master_heartbeat_period = 60000

} }

Keep getting an error Error, failed to create instance test2: googleapi: Error 400: Replica configuration does not contain the dump file path when replicating from an on-premises master., errorReplicaConfigurationMissingDumpFilePath

But as per documentation dumpfilepath was optional https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#replica_configuration

Terraform Configuration

Debug Output

No response

Expected Behavior

No response

Actual Behavior

No response

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

No response

ns-rkankanala commented 2 days ago

After configuring dump file we get Error importing data: generic::unknown: gs://bucket/dump.sql: googleapi: Error 403: pXXXXXX-XXX@gcp-sa-cloud-sql.iam.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist)., forbidden

The issue here is the service account is generated dynamically and we cannot force service account to cloudsql replica.

Related stack overflow https://stackoverflow.com/questions/74154357/can-i-get-the-service-account-of-a-cloud-sql-instance-before-create-it-via-terra