Creating a device
To create a device:
- In the management console, select the folder where you want to create a device.
- Select Yandex IoT Core.
- Select the desired registry from the list.
- In the left part of the window, select Devices.
- Click Add device.
- Specify basic parameters for the device:
- Enter a device Name. For example,
my-device
. - (optional) Add a Description with additional information about the device.
- Set a Password that you'll use to access the device.
To do this, you can use the password generator.
Don't forget to save your password because you'll need it later.
- Enter a device Name. For example,
- (optional) Add aliases:
- Click Add alias.
- Fill in the fields: enter an alias (for example,
events
) and the topic type after$devices/<deviceID>
(for example,events
).
You can use theevents
alias instead of the$devices/<deviceID>/events
topic.
- (optional) Add certificates:
- To add a file:
- Choose the File method.
- Click Select file.
- Specify the certificate file on your computer and click Open.
- Click Add.
- To add text:
- Choose the Text method.
- Insert the certificate body in the Contents field.
- Click Add.
- To add a file:
- Click Add.
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
-
View the list of registries where you can create a device or create a new registry.
-
Create a device:
$ yc iot device create --registry-name my-registry --name my-device id: b9135goeh1uc1s2i07nm registry_id: b91ki3851hab9m0l68je created_at: "2019-05-28T16:08:30.938Z" name: my-device
- Length — from 3 to 63 characters.
- The name may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter. The last character can't be a hyphen.
-
Make sure the device was created:
$ yc iot device list --registry-name my-registry +----------------------+-----------+ | ID | NAME | +----------------------+-----------+ | b9135goeh1uc1s2i07nm | my-device | +----------------------+-----------+
With Terraform, you can quickly create a cloud infrastructure in Yandex.Cloud. The infrastructure components are identified through configuration files that specify the required cloud resources and their parameters.
If you don't have Terraform yet, install it and configure the Yandex.Cloud provider.
Note
To add certificates to the device, create them in advance.
To create a device:
-
View the list of registries where you can create a device or create a new registry.
-
In the configuration file, describe the parameters of the resource to create:
yandex_iot_core_device
: Device parameters:registry_id
: ID of the registry to create a device in.name
: Device name.description
: Device description.aliases
: Topic aliases. For more information, see Creating an aliaspasswords
: List of passwords for authorization using a username and password.certificates
: List of certificates for authorization using certificates.
Sample 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("<path to the certificate file>") ] }
For more information about the resources you can create using Terraform, see the provider documentation.
-
Make sure that the configuration files are correct.
-
In the command line, go to the directory where you created the configuration file.
-
Run the check using the command:
$ terraform plan
If the configuration is described correctly, the terminal displays a list of created resources and their parameters. If there are errors in the configuration, Terraform points them out.
-
-
Deploy the cloud resources.
-
If the configuration doesn't contain any errors, run the command:
$ terraform apply
-
Confirm that you want to create the resources.
Afterwards, all the necessary resources are created in the specified folder. You can check resource availability and their settings in management console.
-