Last active
April 28, 2024 17:38
-
-
Save ihommani/4773ec72f4aa11fbbafe44e1e81d40df to your computer and use it in GitHub Desktop.
Gcloud how to
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Updapte components | |
| gcloud components update | |
| # Display local configuration folder | |
| gcloud info --format='get(config.paths.global_config_dir)' | |
| # display help | |
| gcloud [command] -h | |
| # Create a configuration (project + profile) | |
| gcloud init // then follow the instructions ### TIP: You can use this command to reset previous config. For instance when you need to switch project ### | |
| OR | |
| gcloud config configurations create | |
| # list your created configurations | |
| gcloud config configurations list // the active configuration shoudl set with IS_ACTIVE at true | |
| # View current configuration Cloud SDK properties | |
| gcloud config list | |
| # Describe a configuration (display properties in a yaml format) | |
| gcloud config configurations describe [config_name] | |
| # Switch between configurations | |
| gcloud config configurations activate [config_name] | |
| # Set specific value in the configuration | |
| gcloud config set [...] | |
| e.g: gcloud config set project [PROJECT-ID] | |
| # Use an SSH connection to connect a compute engine instance | |
| gcloud compute ssh [USER@]INSTANCE [optional flags] [-- SSH_ARGS ...] | |
| e.g: gcloud compute ssh staging --zone europe-west1-b | |
| # Copy files | |
| gcloud compute copy-files [[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC ...] [[USER@]INSTANCE:]DEST [optional flags] | |
| # Manage credentials | |
| gcloud auth | |
| # List credential account | |
| gcloud auth list | |
| # Authenticate through service account and manage GAE with these credentials | |
| gcloud auth activate-service-account [ACCOUNT] --key-file=KEY_FILE [optional flags] | |
| # Manage active application default credential (used by maven plugin for instance or application layer GoolgleCredential.getDefaultApplication() ) | |
| gcloud auth application-default login | |
| # Set the active account | |
| gcloud config set account `ACCOUNT` | |
| # Set the current project | |
| gcloud config set project PROJECT_ID | |
| # Get manual according a term | |
| gcloud alpha search-help is now available in alpha. Run gcloud alpha | |
| search-help [TERM] to find gcloud commands whose help text contains | |
| [TERM]. | |
| # Rollback to a previous version | |
| gcloud components update --version XXXX | |
| ### AUTHENTICATION ### | |
| # Authorize access to GCP, impersonating a given service account | |
| gcloud auth activate-service-account --key-file [PATH] | |
| # List credential account (user or service account) | |
| gcloud auth list | |
| # Internal detailed about specified credentials (input is account from list command) useful to get some data like token | |
| gcloud auth describe [account] | |
| # Print token for the active account | |
| gcloud auth print-access-token | |
| gcloud auth print-refresh-token | |
| # Acquire new user credential to call the Google API with gcloud | |
| gcloud auth application-default login | |
| # Print the access token for your current application default credential | |
| gcloud auth application-default print-access-token | |
| # Revoke previously generated Application Default Credentials. | |
| gcloud auth application-default revoke | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment