Sub topic 3
CloudShell Storage, Tools, and File Transfer
Assume you know basic AWS concepts, can use a terminal, and can read simple JSON. CloudShell is a browser-based shell for an AWS Region. It includes AWS CLI v2 and common tools, and it uses your current console identity.
Storage, tools, and file transfer
CloudShell gives each Region a persistent home directory with limited storage. Files in that directory remain between sessions in that Region, but do not assume they are backups. Store important files in Amazon S3.
You can upload and download files from the CloudShell actions menu. You can also use the CLI:
aws s3 cp ./report.json s3://amzn-s3-demo-bucket/reports/report.json
aws s3 cp s3://amzn-s3-demo-bucket/reports/report.json ./report.jsonSign in with IAM Identity Center
For command-line work outside CloudShell, use an IAM Identity Center profile instead of a long-lived access key:
aws configure sso
aws sso login --profile dev
aws sts get-caller-identity --profile devThe last command verifies the account, role, and user or session behind the profile.
Keep access secure
Use MFA where your organization requires it. Grant roles only the permissions they need. Avoid the root user for daily work. Prefer temporary credentials from IAM Identity Center or an assumed role. Never commit credential files or access keys to source control.
Pagination and waiters
Many list operations return pages. The CLI normally follows pagination automatically. Limit the total items and page size when needed:
aws s3api list-objects-v2 \
--bucket amzn-s3-demo-bucket \
--max-items 50 \
--page-size 10A waiter repeatedly checks a known state until it is reached:
aws ec2 wait instance-running --instance-ids i-0123456789abcdef0Scripting with the CLI
Use --query and --output text to make results easier for shell scripts:
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
echo "$r: $(aws ec2 describe-vpcs --region "$r" --query 'length(Vpcs)' --output text)"
doneTroubleshooting and tool choice
Check the profile and Region when a command fails. Run aws sts get-caller-identity --profile NAME and add --region REGION. An AccessDeniedException usually means the role lacks permission.
| Tool | Best fit |
|---|---|
| Console | Visual exploration and occasional changes |
| CLI | Repeatable commands and automation |
| CloudShell | Quick CLI work without local installation |
Exercise
Which command should you run first when a CLI command reports an unexpected identity?
Show answer
Run aws sts get-caller-identity with the intended --profile and check the Region and role.