Pritish
Pritish

Reputation: 774

How to resolve the terraform error "timeout while waiting for state to become 'done: true' (last state: 'done: false', timeout: 10m0s)"?

I am trying to create a Firestore index using terraform in GCP. Below is my Terraform script:

resource "google_firestore_index" "job_config1_index" {
  project = var.projectId

  collection = var.job_config_firestore
  depends_on = [
    "google_firestore_index.job_config4_index"
  ]

  fields {
    field_path = "customer_id"
    order      = "ASCENDING"
  }

  fields {
    field_path = "job_type"
    order      = "ASCENDING"
  }

  fields {
    field_path = "start_date_time"
    order      = "ASCENDING"
  }

  fields {
    field_path = "__name__"
    order      = "ASCENDING"
  }
}

Below are the logs:

Step #2: Error: Error waiting to create Index: Error waiting for Creating Index: timeout while waiting for state to become 'done: true' (last state: 'done: false', timeout: 10m0s)
Step #2: 
Step #2:   on firestore.tf line 298, in resource "google_firestore_index" "job_config1_index":
Step #2:  298: resource "google_firestore_index" "job_config1_index" {
Step #2: 
Step #2: 

My other Firestore indexes are creating fine. How can I increase the timeout for each index?

Upvotes: 3

Views: 25956

Answers (1)

ydaetskcoR
ydaetskcoR

Reputation: 56877

Some resources, including the google_firestore_index resource, have optionally configurable timeouts for creation, updates and/or deletes using the timeouts block:

resource "aws_db_instance" "example" {
  # ...

  timeouts {
    create = "60m"
    delete = "2h"
  }
}

So in your case you would add a create timeout to the Firestore index like this:

resource "google_firestore_index" "job_config1_index" {
  project = var.projectId

  collection = var.job_config_firestore
  depends_on = [
    "google_firestore_index.job_config4_index"
  ]

  fields {
    field_path = "customer_id"
    order      = "ASCENDING"
  }

  fields {
    field_path = "job_type"
    order      = "ASCENDING"
  }

  fields {
    field_path = "start_date_time"
    order      = "ASCENDING"
  }

  fields {
    field_path = "__name__"
    order      = "ASCENDING"
  }

  timeouts {
    create = "60m"
  }
}

Upvotes: 5

Related Questions