main.tf 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. variable "project_id" {}
  2. provider "google" {
  3. project = var.project_id
  4. }
  5. resource "google_firestore_index" "default_db_index" {
  6. collection = "composite-index-test-collection"
  7. for_each = local.indexes
  8. dynamic "fields" {
  9. for_each = distinct(flatten([for k, v in local.indexes : [
  10. for i in each.value : {
  11. field_path = i.field_path
  12. order = can(i.order) ? i.order : null
  13. array_config = can(i.array_config) ? i.array_config : null
  14. }]]))
  15. content {
  16. field_path = fields.value.field_path
  17. order = fields.value.order
  18. array_config = fields.value.array_config
  19. }
  20. }
  21. }
  22. resource "google_firestore_index" "default_db_collection_group_index" {
  23. collection = "composite-index-test-collection"
  24. query_scope = "COLLECTION_GROUP"
  25. for_each = local.collection_group_indexes
  26. dynamic "fields" {
  27. for_each = distinct(flatten([for k, v in local.indexes : [
  28. for i in each.value : {
  29. field_path = i.field_path
  30. order = can(i.order) ? i.order : null
  31. array_config = can(i.array_config) ? i.array_config : null
  32. }]]))
  33. content {
  34. field_path = fields.value.field_path
  35. order = fields.value.order
  36. array_config = fields.value.array_config
  37. }
  38. }
  39. }
  40. resource "google_firestore_index" "named_db_index" {
  41. collection = "composite-index-test-collection"
  42. database = "test-db"
  43. for_each = local.indexes
  44. dynamic "fields" {
  45. for_each = distinct(flatten([for k, v in local.indexes : [
  46. for i in each.value : {
  47. field_path = i.field_path
  48. order = can(i.order) ? i.order : null
  49. array_config = can(i.array_config) ? i.array_config : null
  50. }]]))
  51. content {
  52. field_path = fields.value.field_path
  53. order = fields.value.order
  54. array_config = fields.value.array_config
  55. }
  56. }
  57. }
  58. resource "google_firestore_index" "named_db_collection_group_index" {
  59. collection = "composite-index-test-collection"
  60. database = "test-db"
  61. query_scope = "COLLECTION_GROUP"
  62. for_each = local.collection_group_indexes
  63. dynamic "fields" {
  64. for_each = distinct(flatten([for k, v in local.indexes : [
  65. for i in each.value : {
  66. field_path = i.field_path
  67. order = can(i.order) ? i.order : null
  68. array_config = can(i.array_config) ? i.array_config : null
  69. }]]))
  70. content {
  71. field_path = fields.value.field_path
  72. order = fields.value.order
  73. array_config = fields.value.array_config
  74. }
  75. }
  76. }