-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
96 lines (88 loc) · 3.02 KB
/
Copy pathvariables.tf
File metadata and controls
96 lines (88 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
variable "instance" {
description = "Managed PostgreSQL database using Google Cloud SQL with secure defaults and high availability"
type = object({
kind = string
flavor = string
version = string
spec = object({
version_config = object({
version = string
database_name = string
})
sizing = object({
tier = string
disk_size = number
read_replica_count = number
})
restore_config = optional(object({
restore_from_backup = bool
source_instance_id = optional(string)
master_username = optional(string)
master_password = optional(string)
}), { restore_from_backup = false })
network_config = optional(object({
ipv4_enabled = optional(bool, false)
require_ssl = optional(bool, true)
authorized_networks = optional(map(object({
value = string
})), {})
}))
imports = optional(object({
import_existing = optional(bool, false)
instance_id = optional(string)
database_name = optional(string)
user_name = optional(string)
master_password = optional(string)
}))
})
})
validation {
condition = contains(["13", "14", "15"], var.instance.spec.version_config.version)
error_message = "PostgreSQL version must be one of: 13, 14, 15"
}
validation {
condition = can(regex("^(db-f1-micro|db-g1-small|db-custom-[0-9]+-[0-9]+)$", var.instance.spec.sizing.tier))
error_message = "Instance tier must be either shared-core (db-f1-micro, db-g1-small) or custom tier (db-custom-CPUS-MEMORY_MB format, e.g., db-custom-2-7680)"
}
validation {
condition = var.instance.spec.sizing.disk_size >= 10 && var.instance.spec.sizing.disk_size <= 30720
error_message = "Disk size must be between 10 and 30720 GB"
}
validation {
condition = var.instance.spec.sizing.read_replica_count >= 0 && var.instance.spec.sizing.read_replica_count <= 5
error_message = "Read replica count must be between 0 and 5"
}
validation {
condition = can(regex("^[a-zA-Z][a-zA-Z0-9_]*$", var.instance.spec.version_config.database_name))
error_message = "Database name must start with a letter and contain only letters, numbers, and underscores"
}
}
variable "instance_name" {
description = "The architectural name for the resource as added in the Facets blueprint designer."
type = string
}
variable "environment" {
description = "An object containing details about the environment."
type = object({
name = string
unique_name = string
cloud_tags = map(string)
})
}
variable "inputs" {
description = "A map of inputs requested by the module developer."
type = object({
gcp_provider = object({
attributes = object({
project = string
credentials = string
})
})
network = object({
attributes = object({
vpc_self_link = string
region = string
})
})
})
}