A command-line tool for managing GCP cloud_sql_proxy connections to a number of instances. It can automatically import your GCP project's Cloud SQL instances, assign ports to them, and start and stop the proxies.
Use the package manager pip to install cloud_sql_instance_manager.
pip install cloud_sql_instance_managerYou will need to have gcloud command line installed and logged in with gcloud auth login
The manager will default to using the output of which cloud_sql_proxy to determine the location of the cloud_sql_proxy executable. You can override this with
cloud_sql config --path /FULL/PATH/TO/EXECUTABLEEnsure you are authenticated with gcloud command line.
cloud_sql importThe instance manager will import any (new) instances and automatically assign them ports.
If you want to specify a different project to your current default, then
cloud_sql import --project YOUR-PROJECT-NAMEIf you want to remove any old instances that are not found in your cloud project, add the --tidy flag.
cloud_sql import --project YOUR-PROJECT-NAME --tidyBy default, instances are given a nickname of everything proceeding "-instance-" in the full name. For example - test-application-instance-9956326571963535019 will get the nickname test-application
You can amend the nickname with
cloud_sql update ORIGINAL-NICKNAME --nick NEW-NICKNAMEAt any point, you can have more than one instance with the same nickname but different projects, and you can differentiate with --project PROJECT-NAME
Set whether the manager will start the proxy with --enable_iam_login
cloud_sql update NICKNAME --iam truecloud_sql start NICK-NAMEYou can filter by project with --project YOUR-PROJECT
cloud_sql start defaultAdd --project YOUR-PROJECT to start only default instances for a particular project
cloud_sql stop NICK-NAMEYou can filter by project with --project YOUR-PROJECT
cloud_sql stop allAdd --project YOUR-PROJECT to stop only instances for a particular project
List all instances
cloud_sql listList all instances for a project
cloud_sql list --project YOUR-PROJECTYou can also filter the list by providing a string after the list command. This string will be searched for in the output of each instance. For example:
cloud_sql list test-applicationThis will list all instances that have test-application in their output.
This could be in the project, nickname, port, name, region, IAM status,
or default status.
List all running instances
cloud_sql list-runningTo run with coverage
pip install coverage
coverage run -m pytestInstall build and twine.
pip install twine buildBuild with
python -m buildRelease to test with
twine upload -r testpypi dist/*Release to live with
twine upload -r pypi dist/*Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
- Export to DBeaver
- Use nickname or name interchangeably