Getting Started with AWS Cloud Shell
This comprehensive guide will equip you with the skills to effectively utilize the AWS Command Line Interface (CLI) and Cloud Shell for interacting with Amazon Bedrock. We'll cover foundational CLI commands, JSON processing, and essential Bedrock interactions, all within the convenient environment of Cloud Shell.
Why Cloud Shell?
AWS Cloud Shell is a browser-based shell that provides a pre-configured environment for managing AWS resources. Here's why it's ideal for working with the AWS CLI:
- Pre-authenticated: No need to configure AWS credentials or API keys.
- Accessible: Use it from any device with a web browser.
- Pre-configured: The AWS CLI is already installed and ready to use.
- Persistent storage: Your files and scripts are saved for future sessions.
Launching Cloud Shell
- Navigate to the AWS Management Console.
- Click the Cloud Shell icon in the top navigation bar.
Verifying Your Environment
Before we dive into CLI commands, let's ensure we're in the correct region:
echo $AWS_REGION
Bedrock is currently available in us-east-1
. If your region is different, use the region selector in the Cloud Shell top bar to switch.
Next, verify your AWS identity:
aws sts get-caller-identity
This confirms you're authenticated and ready to interact with AWS services.
Essential CLI Commands
Let's explore some fundamental CLI commands:
ls -l
: List files in your home directory.pwd
: Print the current working directory.date
: Display the current date and time.
These commands are standard Linux commands that you can use within Cloud Shell.
Getting Help with the CLI
The AWS CLI provides extensive help documentation:
aws help
: Display general help information for the AWS CLI.aws s3 help
: Get help for the S3 service.aws s3 ls --help
: Get help for thels
command within the S3 service.
Working with JSON Output
Many AWS CLI commands return output in JSON format. To make this output more readable, we can use the jq
command:
aws ec2 describe-regions
: List available AWS regions (raw JSON output).aws ec2 describe-regions | jq '.Regions[].RegionName'
: List available AWS regions (formatted withjq
).
Interacting with Amazon Bedrock
Now, let's use the CLI to interact with Amazon Bedrock:
aws bedrock list-foundation-models --region us-east-1
: List available foundation models in Bedrock.aws bedrock list-foundation-models --region us-east-1 | jq -r '.modelSummaries[] | select(.modelId | startswith("anthropic.claude-3")) | .modelId'
: List available Claude models in Bedrock (filtered withjq
).
Conclusion
By mastering the AWS CLI and Cloud Shell, you gain a powerful and efficient way to manage AWS services, including Amazon Bedrock. This foundation will enable you to explore the Bedrock API and build innovative AI/ML applications.