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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Message Queue
    • Overview
    • Configuring the AWS CLI
    • Creating a new message queue
    • Sending messages
    • Receiving and deleting messages
    • Deleting a message queue
    • Managing queue labels
    • Monitoring processes in queues
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Public materials
  • FAQ
  1. Step-by-step guides
  2. Creating a new message queue

Creating a new message queue

Written by
Yandex Cloud
Updated at April 22, 2025

Message queues in Message Queue enable messaging between components of distributed applications. Messages can be sent to queues using the API or other supported tools.

To create a new message queue:

Management console
AWS CLI
Terraform
  1. In the management console, select the folder to create your queue in.
  2. Select Message Queue.
  3. Click Create queue.
  4. Under Basic parameters, fill in the following fields:
    • Name: Enter a name for the queue.

      The name may contain lowercase Latin letters, numbers, hyphens, and underscores. The FIFO queue name must end with the .fifo suffix. The name may not be longer than 80 characters.

    • Type: Select the Standard or FIFO queue type.

    • Standard visibility timeout: Specify the standard visibility timeout to be applied to enqueued messages after they are read by a consumer.

    • Message retention: Set the maximum period for retaining messages in the queue.

    • Maximum message size: Specify the maximum message size.

    • Delivery delay: Specify the amount of time during which a new message cannot be picked from the queue.

    • Timeout for receiving messages: Specify the message receipt timeout.

  5. To redirect undelivered messages to the dead letter queue (DLQ), do the following under Configure undelivered message queues:
    • Enable Redirect undelivered messages.
    • Specify Undelivered messages queue.
    • Set Maximum number of read attempts.
  6. Click Create.
  1. Install and configure the AWS CLI.

  2. Run the following command in the terminal:

    aws sqs create-queue \
      --queue-name <queue_name> \
      --endpoint <endpoint>
    

    Where:

    • --queue-name: Name of the new queue, e.g., sample-queue.
    • --endpoint: Endpoint in the https://message-queue.api.cloud.yandex.net/ value.

    Result:

    {
        "QueueUrl": "https://message-queue.api.cloud.yandex.net/aoeaql9r10cd********/000000000000********/sample-queue"
    }
    

With Terraform, 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. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

To create a message queue:

  1. In the configuration file, describe the parameters of the queue to create:

    Sample configuration file for a standard queue:

    provider "yandex" {
       token     = "<OAuth or service account static key>"
       folder_id = "<folder ID>"
       zone      = "ru-central1-a"
    }
    
    resource "yandex_message_queue" "example_queue" {
      name                        = "mq-terraform-example"
      visibility_timeout_seconds  = 600
      receive_wait_time_seconds   = 20
      message_retention_seconds   = 1209600
      access_key                  = "<ID_of_the_static_access_key>"
      secret_key                  = "<secret_part_of_the_static_access_key>"
    }
    

    Sample configuration file for a FIFO queue:

    provider "yandex" {
        token     = "<OAuth_or_service_account_static_key>"
        folder_id = "<folder_ID>"
        zone      = "ru-central1-a"
      }
    
    resource "yandex_message_queue" "example-fifo-queue" {
      name                        = "mq-terraform-example.fifo"
      visibility_timeout_seconds  = 600
      receive_wait_time_seconds   = 20
      message_retention_seconds   = 1209600
      fifo_queue                  = true
      access_key                  = "<ID_of_the_static_access_key>"
      secret_key                  = "<secret_part_of_the_static_access_key>"
    }
    

    Sample configuration file for a queue with a redrive policy for moving undelivered messages to a DLQ named mq_terraform_deadletter_example:

    provider "yandex" {
       token     = "<OAuth_or_service_account_static_key>"
       folder_id = "<folder_ID>"
       zone      = "ru-central1-a"
    }
    
    resource "yandex_message_queue" "example_fifo_queue" {
      name                        = "mq-terraform-example"
      visibility_timeout_seconds  = 600
      receive_wait_time_seconds   = 20
      message_retention_seconds   = 1209600
      redrive_policy              = jsonencode({
        deadLetterTargetArn = yandex_message_queue.example_deadletter_queue.arn
        maxReceiveCount     = 3
      })
      access_key                  = "<ID_of_the_static_access_key>"
      secret_key                  = "<secret_part_of_the_static_access_key>"
    }
    
    resource "yandex_message_queue" "example_deadletter_queue" {
      name                        = "mq_terraform_deadletter_example"
      access_key                  = "<ID_of_the_static_access_key>"
      secret_key                  = "<secret_part_of_the_static_access_key>"
    }
    

    Where:

    • name: Queue name.

    • visibility_timeout_seconds: Visibility timeout.

    • receive_wait_time_seconds: Waiting time for messages to enter the queue if Long Polling is used. The valid values are from 0 to 20 seconds. The default value is 0 seconds.

    • message_retention_seconds: Time, in seconds, to retain a message in the queue.

    • redrive_policy: Redirect policy for moving messages to a dead-letter queue.

      • deadLetterTargetArn: ARN of the DLQ that messages are moved to.
      • maxReceiveCount: Number of attempts to read a message from the queue before redriving it to the DLQ.
    • fifo_queue: Indicates that a FIFO queue is created.

    • content_based_deduplication: Enables content-based deduplication in FIFO queues.

    • access_key: ID of the service account static access key for the queue. If it is not specified in the queue configuration, the ID from the provider configuration is used.

    • secret_key: Secret part of the static access key. If no secret key is set in the queue configuration, the key from the provider configuration is used.

    For more information about resources you can create with Terraform, see the provider documentation.

  2. Make sure the configuration files are correct.

    1. In the command line, go to the directory where you created the configuration file.

    2. Run a check using this command:

      terraform plan
      

    If the configuration is described correctly, the terminal will display a list of created resources and their parameters. If the configuration contains any errors, Terraform will point them out.

  3. Deploy cloud resources.

    1. If the configuration does not contain any errors, run this command:

      terraform apply
      
    2. Confirm that you want to create the resources.

    All the resources you need will then be created in the specified folder. You can check the new resources and their configuration using the management console. To delete the created resources, run the terraform destroy command.

When the limit on the maximum number of queues is reached, the Cannot create queue: Too many queues error occurs. To increase the limit, contact technical support.

Was the article helpful?

Previous
Configuring the AWS CLI
Next
Sending messages
Yandex project
© 2025 Yandex.Cloud LLC