Skip to Content

Console, CLI and SDK

The three ways to use AWS, how each one signs in, and AWS CloudShell.

What it is

There are three ways to work with AWS:

  • The AWS Management Console: the website at console.aws.amazon.com. Sign-in uses a password, plus MFA.
  • The AWS CLI (Command Line Interface): a program that runs in a terminal. It signs in with short-term credentials from a sign-in, or with access keys.
  • The AWS SDKs (Software Development Kits): libraries called from application code. They use short-term credentials, an IAM role, or access keys.

All three do the same thing underneath: they send requests to AWS's public service APIs over HTTPS. Whatever can be clicked in the console can also be done with a CLI command or a line of code.

They exist because people work differently. The console suits learning and one-off tasks best. The CLI is faster for repeated tasks and scripts. The SDKs let applications use AWS directly, for example to save an upload to S3.

How it works

The Console, CLI and SDK all send HTTPS API calls that IAM checks before a service acts The Console, CLI and SDK all send HTTPS API calls that IAM checks before a service acts

Three ways in, one set of APIs.

On the left are the three ways in, each with how it signs in: the Management Console with a password and MFA, the AWS CLI with access keys or single sign-on, and the AWS SDK with access keys or an IAM role. All three send HTTPS requests to the same public service APIs inside AWS.

Each request is checked by IAM first: who is calling, and are they allowed to do this action? Only then does the service (EC2, S3, DynamoDB and so on) carry out the request.

Every action is one API call. Clicking Launch instance in the console, running aws ec2 run-instances and calling ec2.run_instances() in Python all send the same RunInstances request.

The AWS Management Console

The console is a website for viewing and managing resources with forms and buttons.

  • Sign-in uses an email (root user) or a user name and password (IAM user), and MFA should always be added: a second factor such as a code from an authenticator app or a security key. MFA is covered in the Identity & Access group.
  • The Region menu (top right) sets the working Region. Global services such as IAM show Global there.
  • The search bar (top) finds any service by name.
  • Each service has its own console page, with a dashboard and links to its resources.

The console is the best way to learn a service. For anything done more than twice, the CLI or code is faster and less error-prone.

The AWS CLI

The AWS CLI controls AWS through commands typed in a terminal. It's open source (github.com/aws/aws-cli) and calls the same public APIs as the console.

Commands follow one pattern: aws <service> <action> [options].

# Copy a file to an S3 bucket, then list the bucket
aws s3 cp myfile.txt s3://my-example-bucket/myfile.txt
aws s3 ls s3://my-example-bucket

# Show which identity you're signed in as
aws sts get-caller-identity

The current major version is AWS CLI v2. AWS publishes official installers for macOS, Linux and Windows. Copies from other package managers are unofficial.

Signing the CLI in

The CLI needs credentials before it can call anything. AWS lists several ways, from most to least recommended:

  1. Console sign-in: aws login. Opens a browser for the same sign-in as the console, and the CLI gets short-term credentials that refresh for up to 12 hours. Best for a personal laptop. Needs CLI 2.32.0 or later.
  2. IAM Identity Center (single sign-on): aws configure sso. Short-term credentials through the organisation's sign-in. AWS's best practice for companies.
  3. An IAM role on an EC2 instance. Nothing to configure: the CLI finds the role's short-term credentials by itself, and AWS rotates them.
  4. An IAM user's access keys: aws configure. Long-term credentials that work until someone deletes them. Use them only when nothing else works.

aws configure asks for four things: an access key ID, a secret access key, a default Region and a default output format (json, text or table). It saves them in two files in ~/.aws/: credentials and config.

Profiles keep several sets of credentials side by side, for example one per account. Add --profile <name> to a command to use one. Without it, the CLI uses the profile called default.

Access keys

An access key is a pair of values that lets the CLI or SDK act as an IAM user:

  • Access key ID, like a user name: AKIAIOSFODNN7EXAMPLE (an example from the AWS docs, not a real key).
  • Secret access key, like a password: shown only once, at creation.

Access keys are long-term: they work until someone deletes or deactivates them. Anyone who gets a copy can act as that user. Treat them like a password: never share them, never put them in code, and never commit them to git. Create and manage them in the IAM console; the Identity & Access group covers this in depth.

Updated since the slides

The slides show aws configure with access keys as the normal way to set up the CLI. AWS now recommends short-term credentials instead: aws login (added in CLI 2.32.0) for a personal machine, or IAM Identity Center for organisations. It marks long-term IAM user access keys as not recommended.

The AWS SDKs

An SDK is a set of libraries that call AWS APIs from inside an application. AWS provides SDKs for JavaScript/Node.js, Python (boto3), Java, .NET, Go, PHP, Ruby, C++, Rust, Kotlin and Swift, plus mobile and IoT device SDKs.

list_buckets.py
import boto3

s3 = boto3.client("s3")
for bucket in s3.list_buckets()["Buckets"]:
    print(bucket["Name"])

The SDKs look for credentials in the same places as the CLI. On AWS (EC2, Lambda, ECS), give the code an IAM role and the SDK picks up short-term credentials by itself. The SDKs also retry failed calls automatically, which matters for throttling.

Fun fact: the AWS CLI is built on the AWS SDK for Python.

AWS CloudShell

AWS CloudShell is a terminal that runs in the browser, opened from the console's top bar. It's useful for labs because there's nothing to install.

  • It comes with the AWS CLI, Python, Node.js and common tools already installed.
  • It's already signed in as the console user, using the console credentials: no access keys needed.
  • It has no extra charge. Only the resources the commands create are billed.
  • Each Region provides 1 GB of persistent storage in the home folder. Files elsewhere disappear when the session ends.

CloudShell is on the exam's out-of-scope list, so it won't be tested. It's the quickest place to run the CLI in these labs.

Exam tips

  • "An application on EC2 needs to call S3" → give the instance an IAM role. Never store access keys on the instance.
  • "Developers need CLI access across many accounts" → IAM Identity Center with aws configure sso (short-term credentials).
  • "Access keys were committed to a public repository" → deactivate and delete the keys straight away, then check CloudTrail for what they were used for.
  • "Automate the same task repeatedly" → CLI scripts or SDK code, or infrastructure as code (CloudFormation).
  • "Who can use the console?" → anyone with a user name and password (and MFA). The CLI and SDKs need credentials, not a password.

Exam tip

"Store access keys on the EC2 instance" or "embed access keys in the application" is almost always a wrong answer. The right answer is an IAM role.

Common traps

  • "Use the root user's access keys for the CLI." The root user shouldn't have access keys at all. Use an IAM identity with least privilege.
  • "Share one IAM user's keys among the team." Each person needs their own identity, so actions can be traced and access removed one person at a time.
  • "The CLI can do things the console can't, so it bypasses IAM." Every call goes through the same APIs and the same IAM checks.
  • "CloudShell costs money per hour." CloudShell has no charge; only the resources created are billed.

Hands-on lab: use the CLI two ways

Goal: run AWS CLI commands in CloudShell, then from your own computer with short-term credentials.

Free

These commands only read information. Nothing billable is created.

Before you start: sign in to the console in US East (N. Virginia).

Part 1: CloudShell

Open CloudShell

Choose the CloudShell icon in the console's top bar and wait for the prompt.

Check who you are

aws sts get-caller-identity

The output shows three fields: UserId, Account (your 12-digit account ID) and Arn (the full name of your identity, for example arn:aws:iam::123456789012:user/alex).

Try a few read-only commands

aws ec2 describe-regions --output table
aws s3 ls
aws iam list-users --query "Users[].UserName"

aws s3 ls prints nothing if you have no buckets yet. That's fine.

Find help

aws ec2 describe-instances help

Press q to leave the help page. Every command has one.

Part 2: your own computer

Install the AWS CLI v2

Follow Installing the AWS CLI for your system, then check the version:

aws --version

You need version 2.32.0 or later for aws login.

Sign in with your console credentials

aws login

A browser window opens. Sign in as you would to the console and approve the request. The CLI stores short-term credentials and refreshes them for up to 12 hours.

If you're signing in as an IAM user, that user needs the AWS managed policy SignInLocalDevelopmentAccess. The root user doesn't, but avoid using root for daily work.

Confirm it works

aws sts get-caller-identity
aws configure set region us-east-1
aws ec2 describe-availability-zones --output table

Sign out

aws logout

This deletes the cached short-term credentials from your computer.

Expected result: the same identity and results in CloudShell and on your computer, without ever creating an access key.

Clean up: run aws logout (done above) and close CloudShell. No resources were created.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt