DEV Community

Cover image for Play with AWS CloudShell"
Koji Ishida
Koji Ishida

Posted on

Play with AWS CloudShell"

AWS released AWS CloudShell on 15/DEC/2020. We can operate with shell environment with it.

In your AWS Console after login, you can see the link button of AWS CloudShell.

Header Menu

When you access to AWS CloudShell, you can see this information dialog.

Description

This article is the Memo that I learned about AWS CloudShell.

Cannot get EC2 Metadata

As first impression of console, it seems EC2 instance. So I tried to get Metadata but couldn't.

Preparing your terminal...
Try these commands to get started:
aws help  or  aws <command> help  or  aws <command> --cli-auto-prompt
[cloudshell-user@ip-10-0-XX-XXX ~]$ 
[cloudshell-user@ip-10-0-XX-XXX ~]$ sudo curl http://169.254.169.254/latest/meta-data/
curl: (7) Couldn't connect to server
Enter fullscreen mode Exit fullscreen mode

In official blog, there is a condition. Internal access will be available later.

Network Access - Sessions can make outbound connections to the Internet, but do not allow any type of inbound connections. Sessions cannot currently connect to resources inside of private VPC subnets, but that's also on the near-term roadmap.

About Python and Node.js environment

Version 2 and 3 for Python.

$ python --version
Python 2.7.18
$ node --version
v12.18.4
$ python3 --version
Python 3.7.9
Enter fullscreen mode Exit fullscreen mode

Initialize timing of the environment

After installing pandas with sudo command, close the console tab and open the console again. The pandas is remained as installed.

$ sudo pip3 install pandas
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pandas
  Downloading https://files.pythonhosted.org/packages/fd/70/e8eee0cbddf926bf51958c7d6a86bc69167c300fa2ba8e592330a2377d1b/pandas-1.1.5-cp37-cp37m-manylinux1_x86_64.whl (9.5MB)
    100% |████████████████████████████████| 9.5MB 126kB/s 
Collecting numpy>=1.15.4 (from pandas)
  Downloading https://files.pythonhosted.org/packages/5e/f2/9e562074f835b9b1227ca156f787be4554ae6bbe293c064337c4153cc4c8/numpy-1.19.4-cp37-cp37m-manylinux1_x86_64.whl (13.4MB)
    100% |████████████████████████████████| 13.4MB 91kB/s 
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/site-packages (from pandas)
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/site-packages (from pandas)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas)
Installing collected packages: numpy, pandas
Successfully installed numpy-1.19.4 pandas-1.1.5

$ pip3 freeze | grep pandas
pandas==1.1.5
Enter fullscreen mode Exit fullscreen mode

After close and open the tab (CloudShell console) pandas is still installed.

$ pip3 freeze | grep pandas
pandas==1.1.5
Enter fullscreen mode Exit fullscreen mode

We need to understand about timing of initializing the CloudShell environment or how we can initialize the environment.

Different IAM user, different environment

It should be. But I could confirm. For different IAM user, different CloudShell environment will be provided.

Preparing your terminal...
Try these commands to get started:
aws help  or  aws <command> help  or  aws <command> --cli-auto-prompt
[cloudshell-user@ip-10-1-XXX-XX ~]$
Enter fullscreen mode Exit fullscreen mode

As the information, when I confirmed the user who executed AWS CLI, the user was the IAM user which logged in AWS console.

$ aws sts get-caller-identity
{
    "UserId": "ABCDEFGHIJKLMNOPQRSTU",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/test"
}
Enter fullscreen mode Exit fullscreen mode

[Conclusion] Convenient environment not depended on your PC environment

With AWS CloudShell, you can avoid the situation when you replace your PC, you need to prepare AWS CLI environment. Currently internal accessing like VPC cannot be operated but it is included near future roadmap. This new service is very convenient for us to operate AWS resources.

Top comments (0)