Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add master_instance_name and instance_type to mysql module #556

Conversation

OscarVanL
Copy link
Contributor

@OscarVanL OscarVanL commented Dec 14, 2023

Relates to my feature request: #554

fix #554

… the 'root' google_sql_database_instance, which can be used to create a replica and promote it to source (master)
@OscarVanL OscarVanL changed the title Expose master_instance_name and instance_type as module variables for… Expose master_instance_name and instance_type as module variables Dec 14, 2023
@OscarVanL OscarVanL changed the title Expose master_instance_name and instance_type as module variables feat: add master_instance_name and instance_type to mysql module Dec 14, 2023
@imrannayer
Copy link
Collaborator

@OscarVanL thx for the PR. We already have replica code where these parameters are passed. That specific code is for Master instance. Replica code is here.

https://github.com/terraform-google-modules/terraform-google-sql-db/blob/master/modules/mysql/read_replica.tf

@imrannayer imrannayer added the waiting-response Waiting for issue author to respond. label Dec 15, 2023
@OscarVanL
Copy link
Contributor Author

OscarVanL commented Dec 15, 2023

@OscarVanL thx for the PR. We already have replica code where these parameters are passed. That specific code is for Master instance. Replica code is here.

https://github.com/terraform-google-modules/terraform-google-sql-db/blob/master/modules/mysql/read_replica.tf

Hi @imrannayer

I think it would help for me to elaborate on the use-case I described in the feature request more so you have more context.

I want to create a CloudSQL instance that replicates from my on-prem MySQL instance that will at a later stage become the master.

To start with, I want to create some cascading replicas from my on-prem database in CloudSQL. The instance I changed (which currently can only act as the master) will begin as the "root" replica. In the diagram below it is the root replica:

image

Initially, there will be no master in CloudSQL, only replicas.

Eventually once I'm ready, the "root" CloudSQL instance will be promoted to the master instance and my on-premises DB will be shut down:
image

This can be achieved using the fields I have exposed here to point to my sql_source_representation_instance, then later removing this field and assigning the instance_type to promote that instance.

I hope this gives some clarity on why I want the resource I edited to act as a replica.

@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer imrannayer removed the waiting-response Waiting for issue author to respond. label Dec 18, 2023
@imrannayer imrannayer merged commit 6cda644 into terraform-google-modules:master Dec 18, 2023
4 checks passed
@OscarVanL
Copy link
Contributor Author

OscarVanL commented Dec 18, 2023

@imrannayer Hey, apologies I found a mistake in this PR. Please hold the release of 18.2.0.

I should also prevent backups being defined for the replica instance as replicas do not support backups. I will make a follow-up PR shortly.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to make this module a replica, then promote it to a master
2 participants