According the GCP guides, setting up a database migration involves creating a migration job in the console using the wizard [1]. The wizard creates a new CloudSQL instance, but I would like to specify an existing instance such that we can manage the destination instance through version control (e.g. Terraform)
Is it possible to specify an existing CloudSQL instance as the destination for the database migration service in GCP? If so, how?
If not, another solution for version control is to create the migration job (and possibly the destination instance) through a script running gcloud CLI/API commands.
From the API guides for database migration [2], it seems we need to specify a destination connection profile.
destination-connection-profile-id: the destination connection profile ID
This is reflected in the gcloud CLI docs [3]
--destination=DESTINATION
ID of the connection_profile or fully qualified identifier for the connection_profile. To set the connection_profile attribute:
provide the argument --destination on the command line.
Does this mean that in order to create the migration job through the CLI, I will need to manually create a destination CloudSQL instance AND a connection profile for that instance as well? If so, what privileges does the connection user need? Or does the "gcloud database-migration migration-jobs create" command automatically create a destination instance?
Otherwise, open to suggestions as to what the --destination flag could mean.
[1] https://cloud.google.com/database-migration/docs/mysql/create-migration-job
[2] https://cloud.google.com/database-migration/docs/mysql/api-migration-jobs#create_a_continuous_migration_job_with_reverse_ssh_connectivity
[3] https://cloud.google.com/sdk/gcloud/reference/database-migration/migration-jobs/create