Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions mmv1/products/firestore/Database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ create_url: 'projects/{{project}}/databases?databaseId={{name}}'
update_verb: :PATCH
update_mask: true
description: |
A Cloud Firestore Database. Currently only one database is allowed per
Cloud project; this database must have a `database_id` of '(default)'.
A Cloud Firestore Database.

If you wish to use Firestore with App Engine, use the
[`google_app_engine_application`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/app_engine_application)
Expand Down Expand Up @@ -54,19 +53,31 @@ import_format:
- '{{project}}/{{name}}'
- '{{name}}'
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'firestore_default_database'
primary_resource_id: 'database'
pull_external: true
test_env_vars:
org_id: :ORG_ID
ignore_read_extra:
- project
- etag
vars:
project_id: 'my-project'
- !ruby/object:Provider::Terraform::Examples
name: 'firestore_database'
primary_resource_id: 'database'
pull_external: true
test_env_vars:
org_id: :ORG_ID
billing_account: :BILLING_ACCT
ignore_read_extra:
- project
- etag
vars:
project_id: 'my-project'
- !ruby/object:Provider::Terraform::Examples
name: 'firestore_database_datastore_mode'
name: 'firestore_default_database_in_datastore_mode'
primary_resource_id: 'datastore_mode_database'
pull_external: true
test_env_vars:
Expand All @@ -76,6 +87,18 @@ examples:
- etag
vars:
project_id: 'my-project'
- !ruby/object:Provider::Terraform::Examples
name: 'firestore_database_in_datastore_mode'
primary_resource_id: 'database'
pull_external: true
test_env_vars:
org_id: :ORG_ID
billing_account: :BILLING_ACCT
ignore_read_extra:
- project
- etag
vars:
project_id: 'my-project'
properties:
- !ruby/object:Api::Type::String
name: name
Expand Down
9 changes: 5 additions & 4 deletions mmv1/templates/terraform/examples/firestore_database.tf.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
resource "google_project" "project" {
project_id = "<%= ctx[:vars]['project_id'] %>"
name = "<%= ctx[:vars]['project_id'] %>"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
project_id = "<%= ctx[:vars]['project_id'] %>"
name = "<%= ctx[:vars]['project_id'] %>"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>"
}

resource "time_sleep" "wait_60_seconds" {
Expand All @@ -20,7 +21,7 @@ resource "google_project_service" "firestore" {

resource "google_firestore_database" "<%= ctx[:primary_resource_id] %>" {
project = google_project.project.project_id
name = "(default)"
name = "my-database"
location_id = "nam5"
type = "FIRESTORE_NATIVE"
concurrency_mode = "OPTIMISTIC"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource "google_project" "project" {
project_id = "<%= ctx[:vars]['project_id'] %>"
name = "<%= ctx[:vars]['project_id'] %>"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>"
}

resource "time_sleep" "wait_60_seconds" {
depends_on = [google_project.project]
create_duration = "60s"
}

resource "google_project_service" "firestore" {
project = google_project.project.project_id
service = "firestore.googleapis.com"

# Needed for CI tests for permissions to propagate, should not be needed for actual usage
depends_on = [time_sleep.wait_60_seconds]
}

resource "google_firestore_database" "<%= ctx[:primary_resource_id] %>" {
project = google_project.project.project_id
name = "datastore-mode-database"
location_id = "nam5"
type = "DATASTORE_MODE"
concurrency_mode = "OPTIMISTIC"
app_engine_integration_mode = "DISABLED"

depends_on = [google_project_service.firestore]
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ resource "time_sleep" "wait_60_seconds" {
resource "google_project_service" "firestore" {
project = google_project.project.project_id
service = "firestore.googleapis.com"

# Needed for CI tests for permissions to propagate, should not be needed for actual usage
depends_on = [time_sleep.wait_60_seconds]
}

resource "google_firestore_database" "<%= ctx[:primary_resource_id] %>" {
project = google_project.project.project_id

name = "(default)"

project = google_project.project.project_id
name = "(default)"
location_id = "nam5"
type = "DATASTORE_MODE"
type = "FIRESTORE_NATIVE"

depends_on = [google_project_service.firestore]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource "google_project" "project" {
project_id = "tf-test%{random_suffix}"
name = "tf-test%{random_suffix}"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
}

resource "time_sleep" "wait_60_seconds" {
depends_on = [google_project.project]
create_duration = "60s"
}

resource "google_project_service" "firestore" {
project = google_project.project.project_id
service = "firestore.googleapis.com"
# Needed for CI tests for permissions to propagate, should not be needed for actual usage
depends_on = [time_sleep.wait_60_seconds]
}

resource "google_firestore_database" "<%= ctx[:primary_resource_id] %>" {
project = google_project.project.project_id

name = "(default)"

location_id = "nam5"
type = "DATASTORE_MODE"

depends_on = [google_project_service.firestore]
}