-
Notifications
You must be signed in to change notification settings - Fork 0
chore: transfer firestore definition from root to prod workspace and create dev database instance #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: transfer firestore definition from root to prod workspace and create dev database instance #7
Changes from all commits
ca1f1b5
d2261b1
1be330c
a48ce3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| output "firestore_db_id" { | ||
| description = "The Firestore database resource name." | ||
| value = google_firestore_database.this.name | ||
| value = try(google_firestore_database.this[0].name, var.database_name) | ||
| } | ||
|
|
||
| output "firestore_db_project" { | ||
| description = "The project that owns the Firestore database." | ||
| value = google_firestore_database.this.project | ||
| value = try(google_firestore_database.this[0].project, var.project_id) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,11 +68,27 @@ module "gcp_budget" { | |
| depends_on = [module.gcp_project_apis] | ||
| } | ||
|
|
||
| module "gcp_firestore" { | ||
| # production firestore instance (uncomment when needed) | ||
| # module "gcp_firestore" { | ||
| # source = "../../modules/gcp/firestore" | ||
| # | ||
| # project_id = var.gcp_project_id | ||
| # region = var.gcp_region | ||
| # database_name = "prod-payloadcms-db" | ||
| # create_database = var.create_database | ||
| # delete_protection_state = var.firestore_delete_protection_state | ||
| # | ||
| # depends_on = [module.gcp_project_apis] | ||
| # } | ||
|
|
||
| module "dev_gcp_firestore" { | ||
| source = "../../modules/gcp/firestore" | ||
|
|
||
| project_id = var.gcp_project_id | ||
| region = var.gcp_region | ||
| project_id = var.gcp_project_id | ||
| region = var.gcp_region | ||
| database_name = "dev-payloadcms-db" | ||
| create_database = var.create_database | ||
| delete_protection_state = "DELETE_PROTECTION_DISABLED" | ||
|
|
||
|
Comment on lines
+84
to
92
|
||
| depends_on = [module.gcp_project_apis] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| # Non-sensitive prod workspace defaults. | ||
| # Set prod_account_id and gcp_project_id as TFC workspace variables (sensitive for account ID). | ||
|
|
||
| aws_region = "ap-southeast-1" | ||
| gcp_project_id = "durianpy-cms" | ||
| gcp_region = "asia-southeast1" | ||
| gcp_budget_limit_usd = 1 | ||
| aws_region = "ap-southeast-1" | ||
| gcp_project_id = "durianpy-cms" | ||
| gcp_region = "asia-southeast1" | ||
| gcp_budget_limit_usd = 1 | ||
| create_database = true | ||
| firestore_delete_protection_state = "DELETE_PROTECTION_ENABLED" | ||
|
|
||
| budget_notification_email = "durianpy.davao+devops@gmail.com" | ||
| budget_limit_usd = 50 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,17 @@ variable "gcp_region" { | |||||||||||||||||||||||||||
| default = "asia-southeast1" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| variable "create_database" { | ||||||||||||||||||||||||||||
| description = "Whether the prod workspace should create/manage the Firestore database." | ||||||||||||||||||||||||||||
| type = bool | ||||||||||||||||||||||||||||
| default = true | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| variable "firestore_delete_protection_state" { | ||||||||||||||||||||||||||||
| description = "Delete protection state for the prod Firestore database." | ||||||||||||||||||||||||||||
| type = string | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+29
|
||||||||||||||||||||||||||||
| description = "Whether the prod workspace should create/manage the Firestore database." | |
| type = bool | |
| default = true | |
| } | |
| variable "firestore_delete_protection_state" { | |
| description = "Delete protection state for the prod Firestore database." | |
| type = string | |
| } | |
| description = "Whether this workspace should create/manage the Firestore database resources it currently controls." | |
| type = bool | |
| default = true | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
create_database = false,firestore_db_idfalls back tovar.database_name. That changes the output semantics from "resource attribute" to "input echo" and can be misleading (especially given the description says "resource name"). Consider returningnull(or a clearly documented placeholder) when the resource isn't created, or updating the output description/name to reflect that it may simply return the configured database ID when unmanaged.