From 00080cd840ac24419ba189c2383de20ad055e5ff Mon Sep 17 00:00:00 2001 From: apichick Date: Wed, 26 Jun 2024 14:18:42 +0200 Subject: [PATCH] Added firestore module (#2374) --- modules/firestore/README.md | 173 +++++++++++++ modules/firestore/main.tf | 135 ++++++++++ modules/firestore/outputs.tf | 50 ++++ modules/firestore/variables.tf | 231 ++++++++++++++++++ modules/firestore/versions.tf | 27 ++ .../existing-database-with-document.yaml | 27 ++ .../examples/new-database-with-document.yaml | 14 ++ .../examples/new-database-with-field.yaml | 45 ++++ .../examples/new-database-with-index.yaml | 46 ++++ .../new-database-with-weekly-backup.yaml | 38 +++ .../firestore/examples/new-database.yaml | 31 +++ 11 files changed, 817 insertions(+) create mode 100644 modules/firestore/README.md create mode 100644 modules/firestore/main.tf create mode 100644 modules/firestore/outputs.tf create mode 100644 modules/firestore/variables.tf create mode 100644 modules/firestore/versions.tf create mode 100644 tests/modules/firestore/examples/existing-database-with-document.yaml create mode 100644 tests/modules/firestore/examples/new-database-with-document.yaml create mode 100644 tests/modules/firestore/examples/new-database-with-field.yaml create mode 100644 tests/modules/firestore/examples/new-database-with-index.yaml create mode 100644 tests/modules/firestore/examples/new-database-with-weekly-backup.yaml create mode 100644 tests/modules/firestore/examples/new-database.yaml diff --git a/modules/firestore/README.md b/modules/firestore/README.md new file mode 100644 index 00000000..474bc342 --- /dev/null +++ b/modules/firestore/README.md @@ -0,0 +1,173 @@ +# Firestore + +This module allows to crete a firestore datatabase, fields, indexes and documents. + +## Examples + +### New database + +```hcl +module "firestore" { + source = "./fabric/modules/firestore" + project_id = "my-project" + database = { + name = "my-database" + location_id = "nam5" + type = "FIRESTORE_NATIVE" + } +} +# tftest modules=1 resources=1 inventory=new-database.yaml +``` + +### New database with weekly backup + +```hcl +module "firestore" { + source = "./fabric/modules/firestore" + project_id = "my-project" + database = { + name = "my-database" + location_id = "nam5" + type = "FIRESTORE_NATIVE" + } + backup_schedule = { + retention = "86400s" + weekly_recurrence = "MONDAY" + } +} +# tftest modules=1 resources=2 inventory=new-database-with-weekly-backup.yaml +``` + +### New database with document + +```hcl +module "firestore" { + source = "./fabric/modules/firestore" + project_id = "my-project" + database = { + name = "my-database" + location_id = "nam5" + type = "FIRESTORE_NATIVE" + } + documents = { + my-doc-1 = { + collection = "my-coll" + document_id = "d3db1c14-e56d-4597-af1c-f95c2d2290c1" + fields = { + field1 = "value1" + field2 = "value2" + } + } + } +} +# tftest modules=1 resources=2 inventory=new-database-with-document.yaml +``` + +### Existing database with document + +```hcl +module "firestore" { + source = "./fabric/modules/firestore" + project_id = "my-project" + database = { + name = "my-database" + } + database_create = false + documents = { + my-doc-1 = { + collection = "my-coll" + document_id = "d3db1c14-e56d-4597-af1c-f95c2d2290c1" + fields = { + field1 = "value1" + field2 = "value2" + } + } + } +} +# tftest modules=1 resources=1 inventory=existing-database-with-document.yaml +``` + +### New database with field + +```hcl +module "firestore" { + source = "./fabric/modules/firestore" + project_id = "my-project" + database = { + name = "my-database" + location_id = "name5" + type = "FIRESTORE_NATIVE" + } + fields = { + my-field-in-my-coll = { + collection = "my-coll" + field = "my-field" + indexes = [ + { + order = "ASCENDING" + query_scope = "COLLECTION_GROUP" + }, + { + array_config = "CONTAINS" + } + ] + } + } +} +# tftest modules=1 resources=2 inventory=new-database-with-field.yaml +``` + +### New database with index + +```hcl +module "firestore" { + source = "./fabric/modules/firestore" + project_id = "my-project" + database = { + name = "my-database" + location_id = "name5" + type = "FIRESTORE_NATIVE" + } + indexes = { + my-index = { + collection = "my-coll" + fields = [ + { + field_path = "name" + order = "ASCENDING" + }, + { + field_path = "description" + order = "DESCENDING" + } + ] + } + } +} +# tftest modules=1 resources=2 inventory=new-database-with-index.yaml +``` + +## Variables + +| name | description | type | required | default | +|---|---|:---:|:---:|:---:| +| [database](variables.tf#L41) | Database attributes. | object({…}) | ✓ | | +| [project_id](variables.tf#L228) | Project id. | string | ✓ | | +| [backup_schedule](variables.tf#L17) | Backup schedule. | object({…}) | | null | +| [database_create](variables.tf#L95) | Flag indicating whether the database should be created of not. | string | | "true" | +| [documents](variables.tf#L101) | Documents. | map(object({…})) | | {} | +| [fields](variables.tf#L112) | Fields. | map(object({…})) | | {} | +| [indexes](variables.tf#L164) | Indexes. | map(object({…})) | | {} | + +## Outputs + +| name | description | sensitive | +|---|---|:---:| +| [firestore_database](outputs.tf#L17) | Firestore database. | | +| [firestore_document_ids](outputs.tf#L22) | Firestore document ids. | | +| [firestore_documents](outputs.tf#L26) | Firestore documents. | | +| [firestore_field_ids](outputs.tf#L31) | Firestore field ids. | | +| [firestore_fields](outputs.tf#L36) | Firestore fields. | | +| [firestore_index_ids](outputs.tf#L41) | Firestore index ids. | | +| [firestore_indexes](outputs.tf#L46) | Firestore indexes. | | + diff --git a/modules/firestore/main.tf b/modules/firestore/main.tf new file mode 100644 index 00000000..547d0171 --- /dev/null +++ b/modules/firestore/main.tf @@ -0,0 +1,135 @@ +/** + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +locals { + firestore_database_name = var.database_create ? google_firestore_database.firestore_database[0].name : var.database.name +} + +resource "google_firestore_database" "firestore_database" { + count = var.database_create ? 1 : 0 + provider = google-beta + project = var.project_id + name = var.database.name + location_id = var.database.location_id + type = var.database.type + concurrency_mode = var.database.concurrency_mode + app_engine_integration_mode = var.database.app_engine_integration_mode + point_in_time_recovery_enablement = var.database.point_in_time_recovery_enablement + delete_protection_state = var.database.delete_protection_state + deletion_policy = var.database.deletion_policy + + dynamic "cmek_config" { + for_each = var.database.kms_key_name == null ? [] : [""] + content { + kms_key_name = var.database.kms_key_name + } + } + lifecycle { + precondition { + condition = var.database.type != null && contains(["DATASTORE_MODE", "FIRESTORE_NATIVE"], var.database.type) + error_message = "Invalid type. Possible values: DATASTORE_MODE, FIRESTORE_NATIVE" + } + precondition { + condition = var.database.location_id != null + error_message = "location_id must be set." + } + } +} + +resource "google_firestore_backup_schedule" "firestore_backup_schedule" { + count = var.backup_schedule == null ? 0 : 1 + project = var.project_id + database = local.firestore_database_name + retention = var.backup_schedule.retention + + dynamic "daily_recurrence" { + for_each = var.backup_schedule.daily_recurrence ? [""] : [] + content { + + } + } + + dynamic "weekly_recurrence" { + for_each = var.backup_schedule.weekly_recurrence == null ? [] : [""] + content { + day = var.backup_schedule.weekly_recurrence + } + } +} + +resource "google_firestore_field" "firestore_fields" { + for_each = var.fields + project = var.project_id + database = local.firestore_database_name + collection = each.value.collection + field = each.value.field + + dynamic "index_config" { + for_each = each.value.indexes == null ? [] : [""] + content { + dynamic "indexes" { + for_each = each.value.indexes + content { + query_scope = indexes.value.query_scope + order = indexes.value.order + array_config = indexes.value.array_config + } + } + } + } + dynamic "ttl_config" { + for_each = each.value.ttl_config ? [""] : [] + content { + + } + } +} + +resource "google_firestore_document" "firestore_documents" { + for_each = var.documents + project = var.project_id + database = local.firestore_database_name + collection = each.value.collection + document_id = each.value.document_id + fields = jsonencode(each.value.fields) +} + +resource "google_firestore_index" "firestore_indexes" { + for_each = var.indexes + project = var.project_id + database = local.firestore_database_name + collection = each.value.collection + dynamic "fields" { + for_each = each.value.fields + content { + field_path = fields.value.field_path + order = fields.value.order + array_config = fields.value.array_config + dynamic "vector_config" { + for_each = fields.value.vector_config == null ? [] : [""] + content { + dimension = fields.value.vector_config.dimension + dynamic "flat" { + for_each = fields.value.vector_config.flat ? [""] : [] + content { + + } + } + } + } + } + } +} diff --git a/modules/firestore/outputs.tf b/modules/firestore/outputs.tf new file mode 100644 index 00000000..f72ba2c9 --- /dev/null +++ b/modules/firestore/outputs.tf @@ -0,0 +1,50 @@ +/** + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +output "firestore_database" { + description = "Firestore database." + value = var.database_create ? google_firestore_database.firestore_database[0] : null +} + +output "firestore_document_ids" { + description = "Firestore document ids." + value = [for v in google_firestore_document.firestore_documents : v.id] +} +output "firestore_documents" { + description = "Firestore documents." + value = google_firestore_document.firestore_documents +} + +output "firestore_field_ids" { + description = "Firestore field ids." + value = [for v in google_firestore_field.firestore_fields : v.id] +} + +output "firestore_fields" { + description = "Firestore fields." + value = google_firestore_field.firestore_fields +} + +output "firestore_index_ids" { + description = "Firestore index ids." + value = { for k, v in google_firestore_index.firestore_indexes : k => v.id } +} + +output "firestore_indexes" { + description = "Firestore indexes." + value = google_firestore_index.firestore_indexes +} + diff --git a/modules/firestore/variables.tf b/modules/firestore/variables.tf new file mode 100644 index 00000000..e51e7063 --- /dev/null +++ b/modules/firestore/variables.tf @@ -0,0 +1,231 @@ +/** + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +variable "backup_schedule" { + description = "Backup schedule." + type = object({ + retention = string + daily_recurrence = optional(bool, false) + weekly_recurrence = optional(string) + }) + default = null + + validation { + condition = (var.backup_schedule == null ? true : + can(regex("\\d+s", var.backup_schedule.retention))) + error_message = "Retention must be specified in the following format: \\d+s." + } + validation { + condition = (var.backup_schedule == null ? true : + (var.backup_schedule.daily_recurrence + && var.backup_schedule.weekly_recurrence == null) || + (!var.backup_schedule.daily_recurrence + && var.backup_schedule.weekly_recurrence != null)) + error_message = "Either daily_recurrence or weekly_recurrence must be specified, but not both." + } +} + +variable "database" { + description = "Database attributes." + type = object({ + app_engine_integration_mode = optional(string) + concurrency_mode = optional(string) + deletion_policy = optional(string) + delete_protection_state = optional(string) + kms_key_name = optional(string) + location_id = optional(string) + name = string + point_in_time_recovery_enablement = optional(string) + type = optional(string) + }) + validation { + condition = (try(var.database.app_engine_integration_mode, null) == null ? true : contains([ + "ENABLED", + "DISABLED", + ], var.database.app_engine_integration_mode)) + error_message = "Invalid app_engine_integration_mode. If set, possible values are: ENABLED, DISABLE." + } + validation { + condition = (try(var.database.concurrency_mode, null) == null ? true : contains([ + "OPTIMISTIC", + "PESSIMISTIC", + "OPTIMISTIC_WITH_ENTITY_GROUPS" + ], var.database.concurrency_mode)) + error_message = "Invalid concurrency_mode. If set, possible values are: OPTIMISTIC, PESIMISTIC, OPTIMISTIC_WITH_ENTITY_GROUPS." + } + validation { + condition = (try(var.database.deletion_policy, null) == null ? true : contains([ + "ABANDON", + "DELETE" + ], var.database.deletion_policy)) + error_message = "Invalid deletion_policy. If set, possible values are: ABANDON, DELETE." + } + validation { + condition = (try(var.database.deletion_protection_state, null) == null ? true : contains([ + "DELETE_PROTECTION_STATE_UNSPECIFIED", + "DELETE_PROTECTION_ENABLED", + "DELETE_PROTECTION_DISABLED" + ], var.database.deletion_protection_state)) + error_message = "Invalid delete_protection_state. If set, possible values are: DELETE_PROTECTION_STATE_UNSPECIFIED, DELETE_PROTECTION_ENABLED, DELETE_PROTECTION_DISABLED." + } + + validation { + condition = (try(var.database.point_in_time_recovery_enablement, null) == null ? true : contains([ + "POINT_IN_TIME_RECOVERY_ENABLED", + "POINT_IN_TIME_RECOVERY_DISABLED" + ], var.database.point_in_time_recovery_enablement)) + error_message = "Invalid point_in_time_recovery_enablement. If set, possible values are: POINT_IN_TIME_RECOVERY_ENABLED, POINT_IN_TIME_RECOVERY_DISABLED." + } + +} + +variable "database_create" { + description = "Flag indicating whether the database should be created of not." + type = string + default = true +} + +variable "documents" { + description = "Documents." + type = map(object({ + collection = string + document_id = string + fields = any + })) + default = {} + nullable = false +} + +variable "fields" { + description = "Fields." + type = map(object({ + collection = string + field = string + indexes = optional(list(object({ + query_scope = optional(string) + order = optional(string) + array_config = optional(string) + }))) + ttl_config = optional(bool, false) + })) + default = {} + nullable = false + + validation { + condition = alltrue([for v1 in var.fields : + v1.indexes == null ? true : alltrue([for v2 in coalesce(v1.indexes, []) : + v2.query_scope == null ? true : contains([ + "COLLECTION", + "COLLECTION_GROUP" + ], v2.query_scope)])]) + error_message = "Invalid query_scope. If set possible values are: COLLECTION, COLLECTION_GROUP." + } + + validation { + condition = alltrue([for v1 in var.fields : + v1.indexes == null ? true : alltrue([for v2 in coalesce(v1.indexes, []) : + v2.order == null ? true : contains([ + "ASCENDING", + "DESCENDING" + ], v2.order)])]) + error_message = "Invalid order. If set possible values are: COLLECTION, COLLECTION_GROUP." + } + + validation { + condition = alltrue([for v1 in var.fields : + v1.indexes == null ? true : alltrue([for v2 in coalesce(v1.indexes, []) : + v2.array_config == null || v2.array_config == "CONTAINS"])]) + error_message = "Invalid array_config, value must be equal to CONTAINS." + } + + + validation { + condition = alltrue([for v1 in var.fields : + v1.indexes == null ? true : alltrue([for v2 in coalesce(v1.indexes, []) : + !(v2.order != null && v2.array_config != null)])]) + error_message = "Either order or array_config should be specificied, but not both." + } + +} + +variable "indexes" { + description = "Indexes." + type = map(object({ + api_scope = optional(string) + collection = string + fields = list(object({ + field_path = optional(string) + order = optional(string) + array_config = optional(string) + vector_config = optional(object({ + dimension = optional(number) + flat = optional(bool) + })) + })) + query_scope = optional(string) + })) + default = {} + nullable = false + + validation { + condition = alltrue([for k, v in var.indexes : v.api_scope == null ? true : contains([ + "ANY_API", + "DATASTORE_MODE_API" + ], v.api_scope) + ]) + error_message = "Invalid api_scope. If set possible values are: ANY_API, DATASTORE_MODE_API." + } + + validation { + condition = alltrue([for k, v in var.indexes : v.query_scope == null ? true : contains([ + "COLLECTION", + "COLLECTION_GROUP", + "COLLECTION_RECURSIVE" + ], v.query_scope) + ]) + error_message = "Invalid query_scope. If set possible values are: COLLECTION, COLLECTION_GROUP, COLLECTION_RECURSIVE." + } + + validation { + condition = alltrue([for k1, v1 in var.indexes : + v1.fields == null ? true : alltrue([for v2 in coalesce(v1.fields, []) : + v2.order == null ? true : contains([ + "ASCENDING", + "DESCENDING" + ], v2.order)])]) + error_message = "Invalid order. If set possible values are: COLLECTION, COLLECTION_GROUP." + } + + validation { + condition = alltrue([for k1, v1 in var.indexes : + v1.fields == null ? true : alltrue([for v2 in coalesce(v1.fields, []) : + v2.array_config == null || v2.array_config == "CONTAINS"])]) + error_message = "Invalid array_config, value must be equal to CONTAINS." + } + + validation { + condition = alltrue([for k1, v1 in var.indexes : + v1.fields == null ? true : alltrue([for v2 in coalesce(v1.fields, []) : + length([for v3 in [v2.order != null, v2.array_config != null, v2.vector_config != null] : v3 if v3]) == 1])]) + error_message = "Only one of order, array_config or vector_config can be specified." + } + +} + +variable "project_id" { + description = "Project id." + type = string +} diff --git a/modules/firestore/versions.tf b/modules/firestore/versions.tf new file mode 100644 index 00000000..d1f29b96 --- /dev/null +++ b/modules/firestore/versions.tf @@ -0,0 +1,27 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +terraform { + required_version = ">= 1.7.4" + required_providers { + google = { + source = "hashicorp/google" + version = ">= 5.34.0, < 6.0.0" # tftest + } + google-beta = { + source = "hashicorp/google-beta" + version = ">= 5.34.0, < 6.0.0" # tftest + } + } +} diff --git a/tests/modules/firestore/examples/existing-database-with-document.yaml b/tests/modules/firestore/examples/existing-database-with-document.yaml new file mode 100644 index 00000000..94876baa --- /dev/null +++ b/tests/modules/firestore/examples/existing-database-with-document.yaml @@ -0,0 +1,27 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +values: + module.firestore.google_firestore_document.firestore_documents["my-doc-1"]: + collection: my-coll + database: my-database + document_id: d3db1c14-e56d-4597-af1c-f95c2d2290c1 + fields: '{"field1":"value1","field2":"value2"}' + project: my-project + timeouts: null + +counts: + google_firestore_document: 1 + modules: 1 + resources: 1 \ No newline at end of file diff --git a/tests/modules/firestore/examples/new-database-with-document.yaml b/tests/modules/firestore/examples/new-database-with-document.yaml new file mode 100644 index 00000000..fc042a9b --- /dev/null +++ b/tests/modules/firestore/examples/new-database-with-document.yaml @@ -0,0 +1,14 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/tests/modules/firestore/examples/new-database-with-field.yaml b/tests/modules/firestore/examples/new-database-with-field.yaml new file mode 100644 index 00000000..b065546b --- /dev/null +++ b/tests/modules/firestore/examples/new-database-with-field.yaml @@ -0,0 +1,45 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +values: + module.firestore.google_firestore_database.firestore_database[0]: + cmek_config: [] + deletion_policy: ABANDON + location_id: name5 + name: my-database + point_in_time_recovery_enablement: POINT_IN_TIME_RECOVERY_DISABLED + project: my-project + timeouts: null + type: FIRESTORE_NATIVE + module.firestore.google_firestore_field.firestore_fields["my-field-in-my-coll"]: + collection: my-coll + database: my-database + field: my-field + index_config: + - indexes: + - array_config: '' + order: ASCENDING + query_scope: COLLECTION_GROUP + - array_config: CONTAINS + order: '' + query_scope: COLLECTION + project: my-project + timeouts: null + ttl_config: [] + +counts: + google_firestore_database: 1 + google_firestore_field: 1 + modules: 1 + resources: 2 \ No newline at end of file diff --git a/tests/modules/firestore/examples/new-database-with-index.yaml b/tests/modules/firestore/examples/new-database-with-index.yaml new file mode 100644 index 00000000..4c8f795e --- /dev/null +++ b/tests/modules/firestore/examples/new-database-with-index.yaml @@ -0,0 +1,46 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +values: + module.firestore.google_firestore_database.firestore_database[0]: + cmek_config: [] + deletion_policy: ABANDON + location_id: name5 + name: my-database + point_in_time_recovery_enablement: POINT_IN_TIME_RECOVERY_DISABLED + project: my-project + timeouts: null + type: FIRESTORE_NATIVE + module.firestore.google_firestore_index.firestore_indexes["my-index"]: + api_scope: ANY_API + collection: my-coll + database: my-database + fields: + - array_config: null + field_path: name + order: ASCENDING + vector_config: [] + - array_config: null + field_path: description + order: DESCENDING + vector_config: [] + project: my-project + query_scope: COLLECTION + timeouts: null + +counts: + google_firestore_database: 1 + google_firestore_index: 1 + modules: 1 + resources: 2 \ No newline at end of file diff --git a/tests/modules/firestore/examples/new-database-with-weekly-backup.yaml b/tests/modules/firestore/examples/new-database-with-weekly-backup.yaml new file mode 100644 index 00000000..f79de5d2 --- /dev/null +++ b/tests/modules/firestore/examples/new-database-with-weekly-backup.yaml @@ -0,0 +1,38 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +values: + module.firestore.google_firestore_backup_schedule.firestore_backup_schedule[0]: + daily_recurrence: [] + database: my-database + project: my-project + retention: 86400s + timeouts: null + weekly_recurrence: + - day: MONDAY + module.firestore.google_firestore_database.firestore_database[0]: + cmek_config: [] + deletion_policy: ABANDON + location_id: nam5 + name: my-database + point_in_time_recovery_enablement: POINT_IN_TIME_RECOVERY_DISABLED + project: my-project + timeouts: null + type: FIRESTORE_NATIVE + +counts: + google_firestore_backup_schedule: 1 + google_firestore_database: 1 + modules: 1 + resources: 2 \ No newline at end of file diff --git a/tests/modules/firestore/examples/new-database.yaml b/tests/modules/firestore/examples/new-database.yaml new file mode 100644 index 00000000..7a226e14 --- /dev/null +++ b/tests/modules/firestore/examples/new-database.yaml @@ -0,0 +1,31 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +values: + module.firestore.google_firestore_database.firestore_database[0]: + cmek_config: [] + deletion_policy: ABANDON + location_id: nam5 + name: my-database + point_in_time_recovery_enablement: POINT_IN_TIME_RECOVERY_DISABLED + project: my-project + timeouts: null + type: FIRESTORE_NATIVE + +counts: + google_firestore_database: 1 + modules: 1 + resources: 1 + +outputs: {} \ No newline at end of file