Google Cloud Tasks Queue

This page shows how to write Terraform for Cloud Tasks Queue and write them securely.

google_cloud_tasks_queue (Terraform)

The Queue in Cloud Tasks can be configured in Terraform with the resource name google_cloud_tasks_queue. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L11
resource "google_cloud_tasks_queue" "inspector_queue" {
  project = var.project
  location = var.region
  name = var.inspector_queue

  # DLP Limits:
task_queues.tf#L1
resource "google_cloud_tasks_queue" "upload-removal" {
  name     = "upload-removal"
  location = var.region

  rate_limits {
    max_concurrent_dispatches = 100
task_queues.tf#L1
resource "google_cloud_tasks_queue" "upload-removal" {
  name     = "upload-removal"
  location = "europe-west3"

  rate_limits {
    max_concurrent_dispatches = 100
cloud_tasks.tf#L5
resource "google_cloud_tasks_queue" "calendar_notifier" {
  name     = var.name
  location = var.location

  rate_limits {
    max_dispatches_per_second = 100
payment_cloud_task.tf#L1
resource "google_cloud_tasks_queue" "payment_charge_status_queue" {
  provider = google-beta
  name     = "payment-charge-status-queue"
  location = var.cloud_tasks_region
  project  = var.project_id

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

The location of the queue

The queue name.

  • project optional computed - string
  • app_engine_routing_override list block
    • host optional computed - string

    The host that the task is sent to.

    App instance. By default, the task is sent to an instance which is available when the task is attempted.

    App service. By default, the task is sent to the service which is the default service when the task is attempted.

    App version. By default, the task is sent to the version which is the default version when the task is attempted.

  • rate_limits list block

    The max burst size. Max burst size limits how fast tasks in queue are processed when many tasks are in the queue and the rate is high. This field allows the queue to have a high rate so processing starts shortly after a task is enqueued, but still limits resource usage when many tasks are enqueued in a short period of time.

    The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched for this queue. After this threshold has been reached, Cloud Tasks stops dispatching tasks until the number of concurrent requests decreases.

    The maximum rate at which tasks are dispatched from this queue. If unspecified when the queue is created, Cloud Tasks will pick the default.

  • retry_config list block

    Number of attempts per task. Cloud Tasks will attempt the task maxAttempts times (that is, if the first attempt fails, then there will be maxAttempts - 1 retries). Must be >= -1. If unspecified when the queue is created, Cloud Tasks will pick the default. -1 indicates unlimited attempts.

    A task will be scheduled for retry between minBackoff and maxBackoff duration after it fails, if the queue's RetryConfig specifies that the task should be retried.

    The time between retries will double maxDoublings times. A task's retry interval starts at minBackoff, then doubles maxDoublings times, then increases linearly, and finally retries retries at intervals of maxBackoff up to maxAttempts times.

    If positive, maxRetryDuration specifies the time limit for retrying a failed task, measured from when the task was first attempted. Once maxRetryDuration time has passed and the task has been attempted maxAttempts times, no further attempts will be made and the task will be deleted. If zero, then the task age is unlimited.

    A task will be scheduled for retry between minBackoff and maxBackoff duration after it fails, if the queue's RetryConfig specifies that the task should be retried.

  • stackdriver_logging_config list block

    Specifies the fraction of operations to write to Stackdriver Logging. This field may contain any value between 0.0 and 1.0, inclusive. 0.0 is the default and means that no operations are logged.

  • timeouts single block

Explanation in Terraform Registry

A named resource to which messages are sent by publishers.

Warning: This resource requires an App Engine application to be created on the project you're provisioning it on. If you haven't already enabled it, you can create a google_app_engine_application resource to do so. This resource's location will be the same as the App Engine location specified.

Frequently asked questions

What is Google Cloud Tasks Queue?

Google Cloud Tasks Queue is a resource for Cloud Tasks of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Cloud Tasks Queue?

For Terraform, the kwadie/bq-pii-classifier, covid19cz/erouska-firebase and covid19cz/erouska-firebase source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.