Skip to content

Commit 76a2e4b

Browse files
srikxcipherclaudeunni-facets
authored
fix(datastore): make restore_config optional() to match x-ui-overrides-only (#367)
Several datastore modules marked restore_config x-ui-overrides-only in facets.yaml (not a primary spec field) but declared it as a non-optional attribute in variables.tf. A spec that omitted restore_config passed schema validation, then failed terraform plan with `attribute "restore_config" is required` — no signal until plan time. Wrap restore_config in optional(...) with a safe default (restore_from_backup = false; {} for the all-optional azure mysql block) so the un-set case just works. Existing validations already short-circuit on the no-restore path, so behavior is unchanged when the block is provided. Modules fixed: mysql/aws-rds, postgres/aws-rds, mysql/gcp-cloudsql, postgres/gcp-cloudsql, mysql/flexible_server, redis/gcp-memorystore. (imports was already optional everywhere; azure postgres + aws redis already clean.) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: unni-facets <krishnanunni.menon@facets.cloud>
1 parent 2ff7227 commit 76a2e4b

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

modules/datastore/mysql/aws-rds/1.0/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ variable "instance" {
1717
storage_type = string
1818
read_replica_count = number
1919
})
20-
restore_config = object({
20+
restore_config = optional(object({
2121
restore_from_backup = bool
2222
source_db_instance_identifier = optional(string)
2323
restore_master_username = optional(string)
2424
restore_master_password = optional(string)
25-
})
25+
}), { restore_from_backup = false })
2626
imports = optional(object({
2727
import_existing = optional(bool, false)
2828
db_instance_identifier = optional(string)

modules/datastore/mysql/flexible_server/1.0/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ variable "instance" {
1818
storage_tier = string
1919
read_replica_count = number
2020
})
21-
restore_config = object({
21+
restore_config = optional(object({
2222
restore_from_backup = optional(bool)
2323
source_server_id = optional(string)
2424
restore_point_in_time = optional(string)
2525
administrator_login = optional(string)
2626
administrator_password = optional(string)
27-
})
27+
}), {})
2828
imports = optional(object({
2929
import_existing = optional(bool, false)
3030
server_id = optional(string)

modules/datastore/mysql/gcp-cloudsql/1.0/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ variable "instance" {
1414
disk_size = number
1515
read_replica_count = number
1616
})
17-
restore_config = object({
17+
restore_config = optional(object({
1818
restore_from_backup = bool
1919
source_instance_id = optional(string)
2020
master_username = optional(string)
2121
master_password = optional(string)
22-
})
22+
}), { restore_from_backup = false })
2323
imports = optional(object({
2424
import_existing = optional(bool, false)
2525
instance_name = optional(string)

modules/datastore/postgres/aws-rds/1.0/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ variable "instance" {
1717
security_config = object({
1818
deletion_protection = bool
1919
})
20-
restore_config = object({
20+
restore_config = optional(object({
2121
restore_from_backup = bool
2222
source_db_instance_identifier = optional(string)
2323
master_username = optional(string)
2424
master_password = optional(string)
25-
})
25+
}), { restore_from_backup = false })
2626
imports = optional(object({
2727
import_existing = optional(bool, false)
2828
db_instance_identifier = optional(string)

modules/datastore/postgres/gcp-cloudsql/1.0/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ variable "instance" {
1414
disk_size = number
1515
read_replica_count = number
1616
})
17-
restore_config = object({
17+
restore_config = optional(object({
1818
restore_from_backup = bool
1919
source_instance_id = optional(string)
2020
master_username = optional(string)
2121
master_password = optional(string)
22-
})
22+
}), { restore_from_backup = false })
2323
network_config = optional(object({
2424
ipv4_enabled = optional(bool, false)
2525
require_ssl = optional(bool, true)

modules/datastore/redis/gcp-memorystore/1.0/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ variable "instance" {
1515
memory_size_gb = number
1616
tier = string
1717
})
18-
restore_config = object({
18+
restore_config = optional(object({
1919
restore_from_backup = bool
2020
source_instance_id = optional(string)
21-
})
21+
}), { restore_from_backup = false })
2222
security = object({
2323
enable_tls = bool
2424
})

0 commit comments

Comments
 (0)