AWS CloudShell is a browser-based shell that provides instant access to AWS services. As mentioned on the official AWS website, it is a terminal “that you can access from the AWS Management Console to interact with your AWS resources without installing any software on your local computer”. A preconfigured environment with vi, emacs and tmux saves the developer from local setup. It is similar to a browser version of the AWS Management Console and provides an integrated visual command line (CLI) for developing, testing, and servicing IoT products.
Key Features and Capabilities
Working with AWS resources is made easier with AWS CloudShell, which offers a comprehensive set of features:
- Preconfigured environment: “The shell environment is pre-configured with tools, utilities, runtimes and AWS SDKs” as per the AWS website. This saves you time and effort.
- Storage options: CloudShell provides 1 GB of persistent storage in each AWS Region to store frequently used scripts and configuration files between sessions. It also provides temporary storage for short term needs.
- Session management: AWS CloudShell will automatically terminate the session if it’s idle or running too long. But you can restore the session even across multiple browser tabs as this service uses tmux.
- Browsers: You can use Google Chrome, Mozilla Firefox, Microsoft Edge or Apple Safari Browsers as they are compatible with AWS CloudShell.
- File transfer: Files can be placed, downloaded or transferred between CloudShell environment and local PC using Amazon S3 buckets or .zip archives.
- Customization: AWS CloudShell can be customized with warning options, demos and safety of paste and clipboard.
- Environment variables: You can configure preferences and credentials to access AWS resources using the AWS CLI using environment variables.
Use Cases
AWS CloudShell has many use cases for working with AWS:
- Ad-hoc tasks and one off commands: If you need to run a command or execute a script, CloudShell is the tool for you. You don’t have to spin up an EC2 instance to run a single command or a short script.
- Debugging and troubleshooting AWS services: When you have issues with your AWS resources, AWS CloudShell can be super helpful in diagnosing and resolving problems. You can access your AWS Services and interact with them using the AWS CLI to look at logs or run troubleshooting commands.
- Learning and experimenting with AWS: If you are learning AWS or trying out services, CloudShell is an environment to test, experiment and learn. You don’t have to create long term resources to test a command, configuration or service in the CloudShell environment.
To learn more about cloudshell environment and how you can leverage it, contact us.
Comparison with other tools
Amazon CloudShell is a tool to interact with AWS. Here are some comparisons with existing tools:
- AWS CLI Commands: The AWS Command Line Interface (AWS CLI) is a more powerful tool for automation and scripting. But it requires local installation and configuration whereas CloudShell is browser based.
- EC2 instances: EC2 instances is a more traditional way of running AWS workloads. It provides persistent storage, more control over the environment and can run complex applications. But launching and managing EC2 instances is more time consuming and resource intensive compared to CloudShell.
Examples: Using CloudShell for common tasks
To give you a better idea of what CloudShell can do, let’s go through some practical examples of how you can use it for common AWS tasks:
1. Creating an EC2 Instance
- Launch CloudShell from the AWS Management Console.
- Use the AWS CLI to create an EC2 instance:
Bash
aws ec2 run-instances --image-id <image-id> --instance-type t2.micro --min-count 1 --max-count 1
Replace <image-id> with the desired AMI ID.
- View the instance details:
Bash
aws ec2 describe-instances
2. Configuring an S3 Bucket
- Create an S3 bucket:Bash
aws s3 mb s3://my-bucket-name
Replace my-bucket-name with your desired bucket name.
- Upload a file to the bucket:Bash
aws s3 cp my-file.txt s3://my-bucket-name/
- List the contents of the bucket:Bash
aws s3 ls s3://my-bucket-name
3. Running a Lambda Function
- Create a Lambda function:Bash
aws lambda create-function --function-name my-function --runtime python3.9 --handler index.handler --role arn:aws:iam::<account-id>:role/lambda_execution_role
Replace <account-id> with your AWS account ID.
- Upload the function code:Bash
aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip
- Invoke the function:Bash
aws lambda invoke --function-name my-function --payload '{"key": "value"}' output.json
These are just a few examples of what you can do with AWS CloudShell. With its command line interface and integration with AWS services you can manage and automate many aspects of your AWS cloud infrastructure.
Best Practices
To get the most out of AWS CloudShell you should manage your CloudShell session well. Open and close the session to ensure resources are being used as needed (not over provisioned). Make sure your AWS account is secure and intact, so always use complex passwords for all services backed by multi-factor authentication and follow cloud security best practices in an environment.
If you hit any issues with AWS resources, refer to the topics in this guide or search for troubleshooting guides from your favorite online platform. You can also use environment variables to store commonly used configuration settings and credentials so you can reuse them across multiple sessions.
Finally, do go ahead and dig deep into CloudShell features like customization and service integration with other AWS services, it will work wonders for you. Follow these and you will be able to use AWS CloudShell for your AWS tasks and get all the benefits.