Skip to main content

Manages cloud_sql_proxy connections, allocating fixed ports and allowing control over starting and stopping

Project description

Cloud SQL Instance Manager

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.

Installation

Use the package manager pip to install cloud_sql_instance_manager.

pip install cloud_sql_instance_manager

You 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/EXECUTABLE

Usage

Importing from gcloud

Ensure you are authenticated with gcloud command line.

cloud_sql import

The 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-NAME

If 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 --tidy

Nicknames

By 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-NICKNAME

At any point, you can have more than one instance with the same nickname but different projects, and you can differentiate with --project PROJECT-NAME

IAM

Set whether the manager will start the proxy with --enable_iam_login

cloud_sql update NICKNAME --iam true

Starting an instance

cloud_sql start NICK-NAME

Starting all default instances

cloud_sql start default

Add --project YOUR-PROJECT to start only default instances for a particular project

Stopping an instance

cloud_sql stop NICK-NAME

Stopping all running instances

cloud_sql stop all

Listing instances

List all instances

cloud_sql list

List all instances for a project

cloud_sql list --project YOUR-PROJECT

List all running instances

cloud_sql list-running

Tests

To run with coverage

pip install coverage
coverage run -m pytest

Releasing

Install build and twine.

pip install twine build

Build with

python -m build

Release to test with

twine upload -r testpypi dist/*

Release to live with

twine upload -r pypi dist/*

Contributing

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.

License

MIT

TODO List

  • Export to DBeaver
  • Use nickname or name interchangeably

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloud_sql_instance_manager-0.2.7.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloud_sql_instance_manager-0.2.7-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file cloud_sql_instance_manager-0.2.7.tar.gz.

File metadata

File hashes

Hashes for cloud_sql_instance_manager-0.2.7.tar.gz
Algorithm Hash digest
SHA256 a0de78ab6479bc11bdb1d5a3a410080959709e5e46eeddbdf846efc4d360f30f
MD5 8d87a4f216372b545ed7e358c6cfd693
BLAKE2b-256 1964d96bd868a0a17c5f3c8057c827fad6c348034eeddbbcc7513be512f5ade3

See more details on using hashes here.

File details

Details for the file cloud_sql_instance_manager-0.2.7-py3-none-any.whl.

File metadata

File hashes

Hashes for cloud_sql_instance_manager-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b2bad9f74472db2197d6d04ad696f359f17e3e6f84371cbc813db9e1ad9f1e06
MD5 5c8b11ffa295ce713f587d6273116517
BLAKE2b-256 578e02eece12c29f158f985d58abe9c013ff8c990f78a0672793c0eb71a042f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page