[Yandex Cloud documentation](../../../index.md) > [Yandex IoT Core](../../index.md) > [Step-by-step guides](../index.md) > Managing devices > Creating a device

# Creating a device

{% note warning %}

Yandex IoT Core is no longer available to new users. 

Current users can create resources until November 1, 2026. Afterwards, the service will go read-only and cease to operate on December 1, 2026. For more information on the timing and procedure, see [Service shutdown](../../sunset.md).

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

   1. In the [management console](https://console.yandex.cloud), select a folder to create a device in.
   1. Navigate to **IoT Core**.
   1. Select the required registry from the list.
   1. Select **Devices** in the left pane of the window.
   1. Click **Add device**.
   1. Under **General information**, add:

      * Device **Name**, e.g., `my-device`.
      * (Optional) **Description** with additional information about the device.
      * (Optional) **Password** that you will use to access the device. To create a password, you can use [this password generator](https://passwordsgenerator.net/).

         {% note info %}

         Make sure to save your password, as you will need it for [authentication](../../concepts/authorization.md).

         {% endnote %}

   1. (Optional) Add [aliases](../../concepts/topic/usage.md#aliases):

      1. Click **Add alias**.
      1. Fill out the fields: enter an alias, e.g., `events`, and the topic type after `$devices/<device_ID>`, e.g., `events`. You will be able to use the `events` alias instead of the `$devices/<device_ID>/events` topic.

   1. (Optional) Add a [certificate](../certificates/create-certificates.md):

      * To add a file:

         1. Select the `File` method.
         1. Click **Attach file**.
         1. Select the file with the public key of the certificate and click **Open**.
         1. Click **Add**.

      * To add text:

         1. Select the `Text` method.
         1. Paste the certificate's public key to the **Content** field.
         1. Click **Add**.

   1. Click **Create**.

- CLI {#cli}

   If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

   1. [Review a list of the registries](../registry/registry-list.md#registry-list) where you can create a device or [create a new registry](../registry/registry-create.md).

   1. Create a device:

      ```bash
      yc iot device create \
         --registry-name <registry_name> \
         --name <device_name>
      ```

      The device naming requirements are as follows:

      * Length: between 3 and 63 characters.
      * It can only contain lowercase Latin letters, numbers, and hyphens.
      * It must start with a letter and cannot end with a hyphen.

      Result:

      ```text
      id: b9135goeh**********
      registry_id: b91ki3851h**********
      created_at: "2019-05-28T16:08:30.938Z"
      name: <device_name>
      status: ACTIVE
      ```

   1. (Optional) Assign the device a password for authentication with a [username and password](../../concepts/authorization.md#log-pass):

      ```bash
      yc iot device password add --device-name <device_name>
      ```

      You will be prompted to enter a password. Password requirements:

      * The password must contain numbers, upper-case and lower-case letters, and special characters.
      * It must be at least 14 characters long.

      Result:

      ```text
      device_id: b9135goeh**********
      id: aoek49ghmk*********
      created_at: "2019-05-28T16:12:30.938Z"
      ```

   1. (Optional) Add to the registry a certificate for authentication with [certificates](../../concepts/authorization.md#certs):

      ```bash
      yc iot device certificate add \
         --device-name <device_name> \
         --certificate-file <certificate>
      ```

      Where:

      * `--device-name`: Device name.
      * `--certificate-file`: Path to the public key of the certificate, e.g., `cert.pem`.

      Result:

      ```text
      device_id: b9135goeh**********
      fingerprint: 589ce16050****
      certificate_data: |
         -----BEGIN CERTIFICATE-----
         MIIE/jCCAuagAwIBAgIJAPRA...
         -----END CERTIFICATE-----
      created_at: "2019-05-28T16:15:30.938Z"
      ```

   1. (Optional) Add [aliases](../../concepts/topic/usage.md#aliases):

      ```bash
      yc iot device add-topic-aliases \
         --name <device_name> \
         --topic-aliases <alias>='<topic>'
      ```

      Here is an example:

      ```bash
      yc iot device add-topic-aliases \
         --name my-device \
         --topic-aliases events='$devices/are0ej5kpik1********/events'
      ```

      Result:

      ```text
      id: aoek49ghmk*********
      registry_id: b91ki3851h**********
      created_at: "2019-05-28T16:17:30.938Z"
      name: <device_name>
      topic_aliases:
        <alias>: <topic>
      status: ACTIVE
      ```

- Terraform {#tf}

   With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
   
   Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
   
   For more information about the provider resources, see the guides on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

   If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
   
   
   To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.
   
   {% note info %}

   To add certificates to a device, [generate](../certificates/create-certificates.md) them in advance.

   {% endnote %}

   To create a device: 
   
   1. [Review a list of the registries](../registry/registry-list.md#registry-list) where you can create a device or [create a new registry](../registry/registry-create.md).

   1. In the configuration file, describe the resource you want to create:

      * `yandex_iot_core_device`: Device properties:

         * `registry_id`: ID of the registry where the device will be created.
         * `name`: Device name.
         * `description`: Device description.
         * `aliases`: Topic aliases. Read more in [Creating an alias](alias/alias-create.md).
         * `passwords`: List of passwords for authentication with a [username and password](../../concepts/authorization.md#log-pass).
         * `certificates`: List of certificates for authentication with [certificates](../../concepts/authorization.md#certs).

      {% note info %}

      Make sure to use only one of the two authentication methods.

      {% endnote %}

      Here is an example of the resource structure in the configuration file:
      
      ```
      resource "yandex_iot_core_device" "my_device" {
        registry_id = "<registry_ID>"
        name        = "test-device"
        description = "test device for terraform provider documentation"
        
        aliases = {
          "some-alias1/subtopic" = "$devices/{id}/events/somesubtopic",
          "some-alias2/subtopic" = "$devices/{id}/events/aaa/bbb",
        }
        
        passwords = [
          "<password>",
        ]
        
        certificates = [
          file("<certificate_file_path>")
        ]
      }
      ```
      
      For more information about resources you can create with Terraform, see [this provider guide](../../../terraform/index.md).
      
   1. Make sure the configuration files are correct.
      
      1. In the terminal, navigate to the directory where you created your configuration file.
      1. Run a check using this command:
         ```
         terraform plan
         ```
      If the configuration is correct, the terminal will display a list of the resources and their settings. Otherwise, Terraform will show any detected errors. 
         
   1. Deploy the cloud resources.

      1. If the configuration is correct, run this command:
         ```
         terraform apply
         ```
      1. Confirm creating the resources.
      
      This will create all the resources you need in the specified folder. You can check the new resources and their settings using the [management console](https://console.yandex.cloud).

- API {#api}

  To create a device, use the [create](../../api-ref/Device/create.md) REST API method for the [Device](../../api-ref/Device/index.md) resource or the [DeviceService/Create](../../api-ref/grpc/Device/create.md) gRPC API call.

{% endlist %}