Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
      • Working with Yandex IoT Core from an Android device in Java
      • Working with Yandex IoT Core in C#
      • Working with Yandex IoT Core in Java
      • Status monitoring of geographically distributed devices
      • Sensor reading monitoring and event notifications
      • Testing message delivery
      • Emulating multiple IoT devices
      • Writing data from a device into a database

In this article:

  • Prepare your cloud
  • Install Terraform
  • From a mirror
  • From the HashiCorp website
  • Describe the infrastructure
  • Deploy cloud resources
  • Delete the resources you created
  1. Application solutions
  2. Internet of Things (IoT)
  3. Emulating multiple IoT devices

Emulating multiple IoT devices

Written by
Yandex Cloud
Updated at May 7, 2025
  • Prepare your cloud
  • Install Terraform
    • From a mirror
    • From the HashiCorp website
  • Describe the infrastructure
  • Deploy cloud resources
  • Delete the resources you created

In this scenario, you will learn to emulate multiple devices that send messages to MQTT topics. The example shows the emulation of air sensors that measure the following parameters:

  • Temperature
  • Humidity
  • Pressure
  • CO2 level

Each sensor sends its readings in JSON format, e.g.:

{
  "DeviceId":"0e3ce1d0-1504-4325-972f-55c961319814",
  "TimeStamp":"2020-05-21T22:53:16Z",
  "Values":[{
    "Type":"Float",
    "Name":"Humidity",
    "Value":"25.281837"
  },
  {
    "Type":"Float",
    "Name":"CarbonDioxide",
    "Value":"67.96608"
  },
  {
    "Type":"Float",
    "Name":"Pressure",
    "Value":"110.7021"
  },
  {
    "Type":"Float",
    "Name":"Temperature",
    "Value":"127.708824"
  }]
}

To emulate the operation of multiple devices:

  1. Prepare your cloud.
  2. Install Terraform.
  3. Describe the infrastructure.
  4. Deploy cloud resources.

If you no longer need the resources you created, delete them.

Prepare your cloudPrepare your cloud

Sign up in Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or register a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure to operate in.

Learn more about clouds and folders.

Install TerraformInstall Terraform

Using Terraform in Yandex Cloud, you can create cloud resources of any type, such as VMs, disks, or images. For more information about the resources you can create with Terraform, see the provider documentation.

From a mirrorFrom a mirror

Alert

The mirror may be unavailable.

You can download a Terraform distribution for your platform from a mirror. When the download is complete, add the path to the folder with the executable to the PATH variable:

export PATH=$PATH:/path/to/terraform

From the HashiCorp websiteFrom the HashiCorp website

Windows
Linux
macOS

Use one of the following methods:

  • Download the Terraform distribution and follow this guide to install it.

  • Install Terraform using the Chocolatey package manager and the command below:

    choco install terraform
    

Download the Terraform distribution and follow this guide to install it.

Use one of the following methods:

  • Download the Terraform distribution and follow this guide to install it.

  • Install Terraform using the Homebrew package manager and the command below:

    brew install terraform
    

Describe the infrastructureDescribe the infrastructure

  1. Create the iot-terraform folder. It will store the Terraform configuration files.

  2. Download an archive with the files you need for this scenario and unpack it to the iot-terraform directory.

    The archive contains:

    • common.tf: Terraform provider settings.
    • files.tf: Parameters for publishing code files from the local directory.
    • function.tf: Parameters of the function used to write emulated messages to devices.
    • iot_core.tf: Parameters of the registry where the devices are located.
    • output.tf.tf: Output variables.
    • publish: Files required to create a function.
    • service_account.tf: Parameters of the service account being created in this scenario.
    • trigger.tf: Parameters of the trigger to invoke a function with a specified timeout.
    • variables.tf: Applicable variables and their values.
  3. Edit the variables.tf file specifying the following emulation parameters:

    • token: OAuth token for Yandex Cloud access.

    • cloud_id: Cloud ID.

    • folder_id: Folder ID.

    • zone: Availability zone.

    • device_count: Number of emulated devices.

      Note

      To emulate the operation of over 1000 devices, you need to increase quotas by making a request to technical support.

    • subtopic_for_publish: Subtopic in $devices/<device_ID>/events/<subtopic> format.

    • publish_execution_timeout: Timeout for sending messages in seconds.

    • publish_cron_expression: Schedule for sending messages to an MQTT topic as a cron expression. By default, messages are sent every minute.

    You can leave the remaining files unchanged.

Deploy cloud resourcesDeploy cloud resources

  1. Go to the iot-terraform folder and check the configuration using the following command:

    terraform validate
    

    Result:

    Success! The configuration is valid.
    
  2. Format the configuration files in the current folder and subfolders:

    terraform fmt
    

    Result:

    main.tf
    variables.tf
    
  3. After checking the configuration, run the command:

    terraform plan
    

    The terminal will display a list of resources with parameters. This is a test step; no resources will be created. If the configuration contains any errors, Terraform will point them out.

    Alert

    You will be charged for all the resources created with Terraform. Check the pricing plan carefully.

  4. To create resources, run the command:

    terraform apply
    
  5. Confirm creating the resources: type yes in the terminal and press Enter.

    Result:

    Outputs:
    
    function = "d4erep.......aq085f0"
    iot_core = "are.......ht10enkb3u"
    service_account = "ajestqfepa.......0l6"
    trigger = "a1sva8sse.......7kf6"
    

    Terraform will create all the required resources, and the terminal will display the IDs of the resources created. You can check the new resources and their configuration using the management console.

Delete the resources you createdDelete the resources you created

Management console
  1. Delete the registry:
    1. Go to your working folder.
    2. In the list of services, select IoT Core.
    3. To the right of the registry you created, click and select Delete.
    4. Click Delete.
  2. Delete the devices:
    1. Go to your working folder.
    2. In the list of services, select IoT Core.
    3. Select the registry.
    4. Go to the Devices tab.
    5. To the right of the device you created, click and select Delete.
    6. Click Delete.
  3. Delete the function:
    1. Go to your working folder.
    2. In the list of services, select Cloud Functions.
    3. To the right of the function you created, click and select Delete.
    4. Click Delete.
  4. Delete the trigger:
    1. Go to your working folder.
    2. In the list of services, select Cloud Functions.
    3. Go to the Triggers tab.
    4. To the right of the trigger you created, click and select Delete.
    5. Click Delete.
  5. Delete the service account:
    1. Go to your working folder.
    2. In the list of services, select Identity and Access Management.
    3. In the left-hand panel, select Service accounts.
    4. In the row with the name of the service account you created, click and select Delete.
    5. Click Delete.

Was the article helpful?

Previous
Testing message delivery
Next
Writing data from a device into a database
© 2025 Direct Cursus Technology L.L.C.