Skip to content

Cloud CLI: Access & secrets

Cloud CLI commands for access & secrets (tags: #access #secrets #ssh).

Index
10 items

AWS5

AWS: Check which identity you are using

Safe

Account, ARN and user/role the CLI is authenticated as.

aws sts get-caller-identity
What each part does
  1. aws stsSecurity Token Service commands
  2. get-caller-identityprint the account ID, user/role ARN and user ID of the current credentials; needs no permissions

Also known as: whoami aws · AccessDenied · ExpiredToken

AWS: Log in with an SSO profile

Safe

Opens the browser for IAM Identity Center login and caches the token.

aws sso login --profile <profile>
What each part does
  1. aws sso loginopen the browser to sign in via IAM Identity Center and cache a token
  2. --profile <profile>the profile in ~/.aws/config that holds sso_start_url / sso_session

Also known as: aws sso · The SSO session associated with this profile has expired

AWS: Update kubeconfig for an EKS cluster

Safe

Adds/refreshes the EKS cluster context in ~/.kube/config.

aws eks update-kubeconfig --name <cluster> --region <region> --alias <alias>
What each part does
  1. aws eks update-kubeconfigadd or update the cluster entry in ~/.kube/config and make it current
  2. --name <cluster>the EKS cluster name
  3. --region <region>region the cluster runs in
  4. --alias <alias>short context name instead of the long cluster ARN

Also known as: eks kubeconfig · You must be logged in to the server (Unauthorized)

AWS: Start an SSM session on an instance

Safe

Shell on an EC2 instance without SSH keys or open port 22.

aws ssm start-session --target <instance-id>
What each part does
  1. aws ssm start-sessionopen a shell on an instance through Systems Manager (no SSH, no open port)
  2. --target <instance-id>the instance, e.g. i-0abc123; needs the SSM agent + Session Manager plugin

Also known as: session manager · ssm shell · ssh alternative

AWS: Read a Secrets Manager secret

Caution

Prints the secret value. Mind your terminal history and screen sharing.

aws secretsmanager get-secret-value --secret-id <secret-name> --query SecretString --output text
What each part does
  1. aws secretsmanager get-secret-valuefetch the current version of a secret
  2. --secret-id <secret-name>secret name or full ARN
  3. --query SecretStringJMESPath: keep only the secret payload, drop the metadata
  4. --output textprint it raw, without JSON quotes

Also known as: secrets manager · get secret

Azure3

Azure: Log in and select a subscription

Safe

Interactive login, then pin the subscription for following commands.

az login && az account set --subscription "<subscription>"
What each part does
  1. az loginsign in via the browser (or device code)
  2. &&run the next command only if login succeeded
  3. az account setchange the active subscription for later az commands
  4. --subscription "<subscription>"subscription name or ID

Also known as: az login · azure subscription

Azure: Get AKS cluster credentials

Safe

Merge the AKS cluster into ~/.kube/config.

az aks get-credentials -g <resource-group> -n <cluster>
What each part does
  1. az aks get-credentialsmerge the AKS cluster into ~/.kube/config and switch to it
  2. -g <resource-group>resource group that holds the cluster
  3. -n <cluster>the cluster name

Also known as: aks kubeconfig · az aks

Azure: Read a Key Vault secret

Caution

Prints a secret's current value.

az keyvault secret show --vault-name <vault> -n <secret-name> --query value -o tsv
What each part does
  1. az keyvault secret showread the current version of a Key Vault secret
  2. --vault-name <vault>the Key Vault name
  3. -n <secret-name>the secret name
  4. --query valueJMESPath: keep only the secret value
  5. -o tsvplain text output without JSON quotes

Also known as: key vault · keyvault

GCP2

GCP: Log in and set the project

Safe

Authenticate the CLI and set the default project.

gcloud auth login && gcloud config set project <project-id>
What each part does
  1. gcloud auth loginsign in via the browser
  2. &&continue only if login succeeded
  3. gcloud config set project <project-id>default project for later gcloud commands

Also known as: gcloud login · gcloud project

GCP: Get GKE cluster credentials

Safe

Adds the GKE cluster context to ~/.kube/config.

gcloud container clusters get-credentials <cluster> --region <region>
What each part does
  1. gcloud container clusters get-credentials <cluster>write the GKE cluster into ~/.kube/config and switch to it
  2. --region <region>for regional clusters; use --zone for zonal ones

Also known as: gke kubeconfig

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…