Sub topic 10
CloudShell storage, tools, and file transfer
This chapter assumes you can launch CloudShell from the Console and run basic shell commands. Here you will learn which parts of the CloudShell environment persist, which tools come preinstalled, and how to move files in and out.
What persists and what doesn't
CloudShell runs in a temporary compute environment. Only one directory survives between sessions.
| Location | Persists? | Notes |
|---|---|---|
| `$HOME` (`/home/cloudshell-user`) | Yes | 1 GB of storage for each Region |
| Everything outside `$HOME` | No | Lost when the session ends |
Persistent storage is per Region. Files you save in CloudShell in us-east-1 do not appear in eu-west-1. AWS deletes the home directory of a Region after 120 days without use. Back up anything important elsewhere, such as an S3 bucket or a Git repository.
Preinstalled tools
CloudShell comes with the AWS CLI already installed and already authenticated as the identity you used to sign in to the Console. It also includes common tools:
- Shells: Bash, PowerShell, and Zsh
- Languages and package managers: Python with
pip, and Node.js withnpm - Utilities:
git,jq,vim,nano, andsudo
Check what is available with a few version commands:
aws --version
python3 --version
jq --version
df -h $HOMEThe last command shows how much of your home storage is in use.
Transferring files
You have two main options.
Browser upload and download
Open the Actions menu in the CloudShell toolbar:
- Choose Upload file and select a file from your computer. It arrives in your home directory.
- Choose Download file and enter the path of the file in CloudShell. Your browser then downloads it.
These actions handle single files. To move a directory, archive it first.
tar -czf project.tar.gz project/Then download project.tar.gz.
Through Amazon S3
For larger files or repeatable transfers, use S3 as the middle step. CloudShell already has credentials, so no setup is needed, provided your identity has S3 permissions.
aws s3 cp project.tar.gz s3://amzn-s3-demo-bucket/backups/
aws s3 cp s3://amzn-s3-demo-bucket/backups/project.tar.gz .The first command saves a backup. The second restores it in a later session or in a different Region.
Common mistakes
- Saving work in
/tmpor another path outside$HOME, then losing it when the session ends. - Expecting files to appear in a different Region's CloudShell.
- Filling the 1 GB limit with large downloads or build output. Check usage with
df -h $HOMEand delete what you no longer need. - Using the browser upload for a whole directory instead of an archive.
Exercise
You install a tool with sudo in CloudShell and save a script in /tmp/run.sh. You return the next day. What is still there, and what should you do differently?
Show answer
Both are gone, because the tool and /tmp/run.sh sit outside $HOME, and only the home directory persists. Save the script in $HOME, install tools at user level (for example pip install --user), or keep a setup script in $HOME and rerun it. Remember that storage is per Region, so use the same Region the next day.