Skip to content

Cloud CLI

The commands you actually use across AWS, GCP, Azure, Kubernetes, and Terraform.

AWS CLI

Identity & Auth

Check who you're authenticated as:

aws sts get-caller-identity

List configured profiles:

aws configure list-profiles

Use a specific profile:

export AWS_PROFILE=production

S3

List buckets:

aws s3 ls

Sync a local directory to S3:

aws s3 sync ./dist s3://my-bucket/app --delete

Download a file:

aws s3 cp s3://my-bucket/data.json .

CloudWatch Logs

Tail logs in real time:

aws logs tail /aws/lambda/my-function --follow

Install: brew install awscli · pip install awscli


Google Cloud (gcloud)

Auth & Config

Login interactively:

gcloud auth login

Set the active project:

gcloud config set project my-project-id

List active configuration:

gcloud config list

Compute

SSH into a VM:

gcloud compute ssh my-instance --zone us-central1-a

Cloud Run

Deploy a container:

gcloud run deploy my-service --source . --region us-central1

Install: brew install google-cloud-sdk


Azure (az)

Login:

az login

List subscriptions:

az account list --output table

Set active subscription:

az account set --subscription "My Subscription"

Install: brew install azure-cli


kubectl (Kubernetes)

Context & Namespace

List contexts:

kubectl config get-contexts

Switch context:

kubectl config use-context production

Set default namespace:

kubectl config set-context --current --namespace=my-app

Pods

List pods:

kubectl get pods

View logs:

kubectl logs -f deployment/my-app

Exec into a pod:

kubectl exec -it my-pod -- /bin/sh

Port-forward a service to localhost:

kubectl port-forward svc/my-service 8080:80

Quick Debug

Get events sorted by time:

kubectl get events --sort-by=.lastTimestamp

Describe a failing pod:

kubectl describe pod my-pod

Install: brew install kubectl · comes with Docker Desktop


Terraform

Workflow

Initialize a project:

terraform init

Preview changes:

terraform plan

Apply changes:

terraform apply

Destroy all managed resources:

terraform destroy

Warning

Always run terraform plan before apply in production environments.

State

List managed resources:

terraform state list

Show a specific resource:

terraform state show aws_instance.web

Install: brew install terraform · winget install Hashicorp.Terraform