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

fix: Don't define backup_configuration if default DB is configured as a replica #559

Conversation

OscarVanL
Copy link
Contributor

@OscarVanL OscarVanL commented Dec 18, 2023

I made a mistake in my last PR #556 which allow backups to be created if the default DB is configured as a replica (via master_instance_name), when this is not a valid configuration.

CloudSQL does not allow you to create backups of replicas, so this block should be blanked if the intance is configured as a replica.

@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer
Copy link
Collaborator

@OscarVanL integration test failed with following error:

TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185: Error: Reference to undeclared input variable
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185: 
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185:   on ../../../modules/mysql/main.tf line 71, in resource "google_sql_database_instance" "default":
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185:   71:       for_each = var.master_instance_name != null ? [] : [var.backup_configuration]
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185: 
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185: An input variable with the name "master_instance_name" has not been declared.
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185: This variable can be declared with a variable "master_instance_name" {}
TestMySqlHaModule 2023-12-19T14:08:05Z command.go:185: block.
TestMySqlHaModule 2023-12-19T14:08:05Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; 
Error: Reference to undeclared input variable

  on ../../../modules/mysql/main.tf line 71, in resource "google_sql_database_instance" "default":
  71:       for_each = var.master_instance_name != null ? [] : [var.backup_configuration]

An input variable with the name "master_instance_name" has not been declared.
This variable can be declared with a variable "master_instance_name" {}
block.}
    validate.go:11: 
        	Error Trace:	/builder/home/go/pkg/mod/github.com/gruntwork-io/terratest@v0.46.7/modules/terraform/validate.go:11
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.10.2/pkg/tft/terraform.go:411
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.10.2/pkg/tft/terraform.go:442
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.10.2/pkg/tft/terraform.go:469
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.10.2/pkg/utils/stages.go:31
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.10.2/pkg/tft/terraform.go:469
        	Error:      	Received unexpected error:
        	            	FatalError{Underlying: error while running command: exit status 1; 
        	            	Error: Reference to undeclared input variable
        	            	
        	            	  on ../../../modules/mysql/main.tf line 71, in resource "google_sql_database_instance" "default":
        	            	  71:       for_each = var.master_instance_name != null ? [] : [var.backup_configuration]
        	            	
        	            	An input variable with the name "master_instance_name" has not been declared.
        	            	This variable can be declared with a variable "master_instance_name" {}
        	            	block.}
        	Test:       	TestMySqlHaModule
--- FAIL: TestMySqlHaModule (9.55s)
FAIL

@OscarVanL
Copy link
Contributor Author

@imrannayer What version of the module is that testing against? That variable was only added in my last commit: 6cda644, so if it is pinned on the latest release (v18.1.0) that wouldn't include the variable. That variable will exist if it runs against HEAD of this repo.

@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer imrannayer merged commit 52224ad into terraform-google-modules:master Dec 25, 2023
4 checks passed
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.

None yet

2 participants