# Cloud shell

A terminal in your browser, signed in as you, with the CLI and the usual tools.

Ready to use, **with your own permissions**: the `dcloud` CLI, `kubectl`, `helm`, `terraform`,
`git`, `psql`, `mysql`, `redis-cli`, `jq`, `python3` and the usual tools. It is free, with the
fair-use limits below.

Open it from **Cloud shell** in the console's top bar, or with `` Ctrl+` `` (backtick). It opens as a panel at the
bottom of the console and stays open while you move between pages. Drag its top edge to make it
taller (the height is remembered in your browser), minimise it to a bar, or open it in a tab of its
own at `/cloudshell`. On a phone, open it from your user menu (top right). The **ⓘ** button in the
panel shows your home directory, this week's hours and the limits, and has **End shell** and
**Delete home**.

Select text to copy it; paste with ⌘V or Ctrl+V (Ctrl+Shift+C and Ctrl+Shift+V work too).

## What it is

- **Your own sandbox**: an isolated Linux session with its own kernel, 1 vCPU and 2 GiB, with open outbound
  internet (git, package registries, the Deutsche Cloud API). It runs on the shared sandbox hosts, one of
  which is always up with the shell image pulled, so a shell starts in seconds; it reaches no other
  sandbox on the host. With [hosts of your own](/docs/sandbox#where-sandboxes-run-shared-hosts-or-your-own)
  switched on, shells run there instead, and the first of the day waits about 40 seconds for a host.
- **Signed in as you**: a temporary access key of your own IAM user, valid 1 hour, renewed every 30
  minutes while the shell is open in the console, and **deleted when you log out** (it is bound to your console
  session). It is never a long-lived key. Whatever your policies allow, it may not create access keys
  or open another cloud shell. Every call it makes is in the audit log as you; the key's description
  names the shell (`cloud shell sbx-…`).
- **A home that is kept**: `~` (`/home/<your user name>`, up to 1 GiB) is saved when the shell ends and
  every 5 minutes while you use it, and restored the next time. Everything outside your home is reset.
  A home unused for 90 days is deleted (the date is under the panel's ⓘ button). **Delete home** deletes it now.
- **Ends** after 20 minutes with no terminal open and no activity, and after 8 hours in any case. The
  home is saved first.

## Who may use it (IAM)

| Action                           | What it allows                                                        |
| -------------------------------- | --------------------------------------------------------------------- |
| `cloudshell:StartSession`        | Open your own shell (from the console only, never with an access key) |
| `cloudshell:DescribeEnvironment` | See an environment: running or not, home size, when it is deleted     |
| `cloudshell:DeleteEnvironment`   | Delete an environment: end its shell and delete its home              |

The resource is `rn:ews:de1:<org>:cloudshell:environment/<iam user id>`. Nobody opens another
person's shell, an administrator included: it holds that person's credentials. An administrator can
deny it (`Deny cloudshell:StartSession`) and delete someone's environment
(`DELETE /cloudshell/api/environments/<iam user id>`).

## Cost and fair use

**Free.** A shell does not count as sandbox time and is not on your bill; the 1 GiB home is included.
The limits that keep it free:

| Limit                                    | Value                                   | Quota                          |
| ---------------------------------------- | --------------------------------------- | ------------------------------ |
| Shells per person                        | 1                                       |                                |
| Size                                     | 1 vCPU, 2 GiB memory                    |                                |
| Ends                                     | after 20 idle minutes, or after 8 hours |                                |
| Hours per person per week                | 50 (10 on trial quotas)                 | `cloudshell.hours-per-week`    |
| Shells open at once in your organization | 10 (2 on trial quotas), per region      | `cloudshell.concurrent-shells` |

The week starts Monday 00:00 UTC; the panel's ⓘ button shows the hours used and when they come back. When a limit
is reached, opening a shell says which one and until when; a shell open when the weekly hours run
out ends (the home is saved first). Both quotas are on **Service quotas**, where you can ask for an
increase. When every host the platform keeps for shells is full, the start says so and you try
again a few minutes later.

## API

```
GET    /cloudshell/api/environment        your environment
POST   /cloudshell/api/session            open your shell (202 while it starts; 201 with the terminal)
POST   /cloudshell/api/session/end        end it now (the home is saved first)
DELETE /cloudshell/api/environment        delete your environment and home
GET    /cloudshell/api/environments       everyone's (DescribeEnvironment on the org)
DELETE /cloudshell/api/environments/{id}  delete someone's (DeleteEnvironment on theirs)
```

The terminal is a WebSocket to your sandbox's host (`connection.terminalUrl`), subprotocols
`ews.terminal` and `ews.token.<token>`, the same as a sandbox terminal.

Where the cloud shell is not available yet, the top bar has no **Cloud shell** entry, `/cloudshell`
says so in one sentence, and `POST /cloudshell/api/session` answers `503` with `error` (that
sentence) and a `code` such as `cloudshell_image_missing`. The command line tool works the same on
your own machine.

## Related

- A terminal on one of your instances: [Instance access](/docs/instance-access).
