AWS CloudShell in Lightsail - Amazon Lightsail

AWS CloudShell in Lightsail

AWS CloudShell is a browser-based, pre-authenticated shell that you can launch directly from the Amazon Lightsail console. Use CloudShell to manage your Lightsail resources from the command line interface. You can run AWS Command Line Interface (AWS CLI) commands using your preferred shell, such as Bash, PowerShell, or Z shell. You can do this without downloading or installing command line tools. When you launch CloudShell, a compute environment that's based on Amazon Linux 2 is created. Within this environment, you can access an extensive range of pre-installed development tools, such as the AWS CLI. For a complete list of pre-installed tools, see Pre-installed software in the CloudShell User Guide.

Persistent storage

With AWS CloudShell, you can use up to 1 GB of persistent storage in each AWS Region at no additional cost. Persistent storage is located in your home directory ($HOME) and is private to you. Unlike ephemeral environment resources that are deleted after each shell session ends, data in your home directory persists between sessions. For more information about the retention of data in persistent storage, see Persistent storage in the CloudShell User Guide.

AWS Regions

In Lightsail, a CloudShell session will open in the AWS Region that provides the least latency to your physical location. This means that AWS Regions can change between sessions. Take note of which AWS Region--> your CloudShell session is located in so that you can use the 1 GB persistent storage. To change the session’s AWS Region, choose the Open in new browser tab icon. This provides the option to access your CloudShell session in a new browser window.

CloudShell open in new browser tab

In the navigation bar of the new browser tab, choose the name of the AWS Region that's currently displayed. Then choose the AWS Region that you want to switch to.

Change the AWS Region in CloudShell.

For more information about CloudShell, see the CloudShell User Guide.

Launch and use AWS CloudShell

Learn how to launch and use an AWS CloudShell session within Lightsail. If you don’t have permission to run CloudShell, you must add the arn:aws:iam::aws:policy/AWSCloudShellFullAccess policy to the AWS Identity and Access Management (IAM) identity that you’re using. If you already have the arn:aws:iam::aws:policy/AdministratorAccess policy attached, you should be able to access CloudShell. For more information, see Identity and access management for Amazon Lightsail.

Launch AWS CloudShell

You can launch CloudShell from the Amazon Lightsail console. After the session begins, you can switch to your preferred shell, such as Bash, PowerShell, or Z shell.

Complete the following steps to launch a new AWS CloudShell session in Lightsail:

  1. Sign in to the Lightsail console at https://lightsail.aws.amazon.com/.

  2. Choose CloudShell on the Console Toolbar, in the lower left of the console. When the command prompt displays, the shell is ready for interaction.

    AWS CloudShell on the Lightsail console toolbar.
  3. (Optional) To choose a pre-installed shell to work with, enter one of the following program names at the command line prompt:

    Bash: bash

    If you switch to Bash, the symbol at the command prompt updates to $. Bash is the default shell in AWS CloudShell.

    PowerShell: pwsh

    If you switch to PowerShell, the symbol at the command prompt updates to PS>.

    Z shell: zsh

    If you switch to Z shell, the symbol at the command prompt updates to %.

Example Lightsail API command in AWS CloudShell

There are multiple command line tools that are pre-installed on the CloudShell session for you to use. In this example, you use the Lightsail GetInstances API operation to view the instances that are in your Lightsail account. To learn more about the GetInstances API operation, see GetInstances in the Amazon Lightsail API Reference.

  1. Sign in to the Lightsail console at https://lightsail.aws.amazon.com/.

  2. Choose CloudShell on the Console Toolbar, in the lower left of the console.

  3. Enter the following command after the AWS CloudShell prompt:

    aws lightsail get-instances

    You should now see a complete list of instances that are in your Lightsail account.

Amazon Lightsail get instances API command output.

Additional information

See the following documentation for more information about AWS CloudShell: