Loading...

About the AWS CLI cheat sheet

The AWS CLI is consistent once you see the pattern: a service name, an operation, and parameters that mirror the API. Almost everything follows it, which means guessing an operation name is usually productive rather than futile.

Two flags change the experience more than any others. The query option filters output client-side using JMESPath, turning a wall of JSON into the two fields you wanted, and the output option gives you table or text formats that are far easier to read or feed into a shell loop. Learning these is worth more than memorising operations.

Credentials and profiles are the usual source of confusion. The CLI resolves credentials in a defined order — environment variables, then the profile, then instance metadata — so a command that works locally and fails on a server, or vice versa, is nearly always a different identity rather than a different permission. Confirming who you actually are is the first diagnostic step.

Frequently asked questions

How do I confirm which identity I am using?

Ask STS for the caller identity, which returns the account, user or role ARN currently in effect. This is the first thing to check for any access denied error, because the most common cause is operating as a different principal than you assumed — a stale environment variable or an unexpected default profile.

How do I get kubectl access to an EKS cluster?

Use the EKS update-kubeconfig command, which writes a context using your current AWS identity. Access still depends on that identity being mapped inside the cluster's access configuration — a valid AWS identity with no cluster mapping authenticates successfully and is then denied by RBAC, which reads as a confusing error.

How do I filter output without piping to jq?

Use the query option, which applies a JMESPath expression to the response after it arrives — the filtering is client-side, so it shapes what you see rather than what is transferred. Combined with text or table output it covers most extraction without an external dependency, which matters in containers and CI images where jq may not be installed.

Why is my S3 copy so slow?

Usually many small files rather than bandwidth. The sync command parallelises, and the concurrency and chunk size settings in the CLI configuration control how aggressively. For very large numbers of objects, increasing concurrent requests helps far more than anything else. Also confirm you are in the same region as the bucket.

How do I connect to an instance without SSH?

Use Session Manager, which gives a shell through the SSM agent with no open inbound port and no key to distribute. It requires the agent running and an instance profile granting SSM permissions. This is strictly better than a bastion for most access, and it produces an audit trail by default.