Sub topic 9
Launching AWS CloudShell
This chapter assumes you can sign in to the Management Console, know what an AWS Region is, and can run basic shell commands. It covers how to open CloudShell, how it authenticates, and what to check first.
What CloudShell is
AWS CloudShell is a browser-based shell that you open from the Console. It runs in a managed environment with the AWS CLI already installed. You don't install anything or run aws configure.
Opening a session
You can start CloudShell in any of these ways:
- Choose the CloudShell icon in the Console navigation bar.
- Search for "CloudShell" in the Console search box.
- Choose the CloudShell link in the Console's bottom-left toolbar, where it is shown.
The first launch takes a short while, because AWS provisions the environment. After that, a terminal opens in the browser at the bottom of the Console. You can also use tabs and split panes.
How it authenticates
CloudShell uses the credentials from your Console sign-in. The CLI inside it acts as the same identity you used to sign in. If you signed in through IAM Identity Center with a role, commands run with that role's permissions.
It also uses the Region shown in the Console's Region selector. Each Region has its own CloudShell environment.
First checks
Run these two commands as soon as the prompt appears:
aws --version
aws sts get-caller-identityThe first confirms the CLI version. The second prints the account ID and the ARN of the identity in use. For a role sign-in, the ARN contains assumed-role. Check this before you run anything that changes resources.
You can also check the Region the session is using:
aws configure listBecause the session takes its Region from the Console, you can switch Regions in the Console and open a new environment there. You can also override the Region on one command with --region.
Session behavior
- Timeouts: A session ends after a period of inactivity. Running processes stop when it ends. Don't rely on CloudShell for long-running jobs.
- Shells: You can choose between Bash, PowerShell, and Zsh. Bash is the default.
- Home directory: Files in your home directory persist between sessions in that Region. Files elsewhere do not. The next chapter covers storage in more detail.
When it fits
CloudShell suits quick checks, one-off commands, and situations where you can't install the CLI locally. It's also useful when you want to confirm that a command works with your Console permissions.
Exercise
You open CloudShell while the Console Region selector is set to Europe (Ireland). You run aws sts get-caller-identity and then list your EC2 instances, but you see none, even though you know you launched one in us-east-1. What is the most likely reason, and how do you fix it?
Show answer
CloudShell uses the Console's selected Region by default, so the list call queried eu-west-1, where the instance doesn't exist. Either switch the Console Region to US East (N. Virginia) and use CloudShell there, or run the command with --region us-east-1.