# Rename an instance

Set or clear the display name an instance is shown by in the console and the API.

The name is a label in the console and the API, up to 64 characters; the machine is not changed.
Without a name, the instance is shown by its id.

## Prerequisites

- Permission for `ec2:ModifyInstanceAttribute`. Without it the **Name** field is read-only in the
  console and the API answers `403`.
- In the console, also `ec2:DescribeInstances` to open the instance's page (without it the page is
  not found).

## Rename

**Console**
1. Open **Compute**, then **Instances**, and choose the instance.
2. Choose **Settings**.
3. Under **General**, for **Name**, enter the new name, or clear it.
4. Choose **Save**. **Saved** appears next to the button, and the new name in the header.

**CLI**
```sh
dcloud ec2 instances rename i-3f9a2c07 --name web-02
```

**API**
```http
PUT /ec2/api/instances/i-3f9a2c07/name
{ "name": "web-02" }
```

Send `"name": null` to clear the name.

## Result

The answer is `{ id, name }` with the new name; an instance that is not yours answers `404`
"Instance not found". In Terraform, `name` on `dcloud_instance` changes it in
place.

## Related

- [Resize an instance](resize-an-instance.md)
- `ec2.instances.rename` · `dcloud ec2 instances rename`
