130 lines
4.6 KiB
HCL
130 lines
4.6 KiB
HCL
#
|
|
# PostgreSQL server on a dedicated network.
|
|
#
|
|
# The module creates the dedicated network and subnet, the security groups, the
|
|
# data and WAL volumes, the two ports (main network and dedicated network) and
|
|
# the instance. Nothing is read from another state here: the caller passes in
|
|
# everything that comes from the other workspaces.
|
|
#
|
|
# Sizing and dedicated network belong to the service, so they have defaults
|
|
# here. The address on the main private network does not: it is part of the
|
|
# address plan of the project, and it is passed in by the caller.
|
|
#
|
|
|
|
variable "postgresql_data" {
|
|
description = "Instance, volumes and dedicated network of the PostgreSQL server"
|
|
type = object({
|
|
name = optional(string, "postgresql")
|
|
description = optional(string, "PostgreSQL server")
|
|
flavor = optional(string, "m1.large")
|
|
boot_vol_size = optional(number, 20)
|
|
# Address on the dedicated network, the only one the service listens on
|
|
server_ip = optional(string, "192.168.0.5")
|
|
server_cidr = optional(string, "192.168.0.5/32")
|
|
# Dedicated network and subnet
|
|
network_name = optional(string, "postgresql-srv-net")
|
|
network_description = optional(string, "Network used to communicate with the postgresql service")
|
|
subnet_name = optional(string, "postgresql-srv-subnet")
|
|
subnet_description = optional(string, "Subnet used to connect to the postgresql service")
|
|
network_cidr = optional(string, "192.168.0.0/22")
|
|
allocation_pool_start = optional(string, "192.168.0.100")
|
|
allocation_pool_end = optional(string, "192.168.3.254")
|
|
# Port the service listens on
|
|
port = optional(number, 5432)
|
|
# Port of the Prometheus postgres_exporter, on the MAIN network: the
|
|
# exporter is monitoring, not database traffic, and it is scraped over the
|
|
# administration interface
|
|
exporter_port = optional(number, 9187)
|
|
# Data and WAL volumes. m1.large is RAM 8 - VCPUs 4
|
|
vol_data_name = optional(string, "postgresql-data")
|
|
vol_data_size = optional(number, 100)
|
|
vol_data_device = optional(string, "/dev/vdb")
|
|
vol_wal_name = optional(string, "postgresql-wal")
|
|
vol_wal_size = optional(number, 100)
|
|
vol_wal_device = optional(string, "/dev/vdc")
|
|
volume_type = optional(string, "CephSSD")
|
|
})
|
|
default = {}
|
|
}
|
|
|
|
# Part of the address plan of the project: no default on purpose
|
|
variable "postgresql_main_ip" {
|
|
type = string
|
|
description = "Address of the server on the main private network, used for the administration (ansible, monitoring, backups)"
|
|
}
|
|
|
|
# Also part of the address plan of the project, same rationale: it is the
|
|
# address of a shared service, so it is declared once in s2i2s/variables and
|
|
# passed in, instead of being duplicated as a module default
|
|
variable "prometheus_cidr" {
|
|
type = string
|
|
description = "CIDR of the Prometheus server, the only source allowed to reach the postgres_exporter"
|
|
}
|
|
|
|
# Data that comes from the network/DNS and project setup workspaces
|
|
variable "main_private_network_id" {
|
|
type = string
|
|
description = "ID of the main private network of the project"
|
|
}
|
|
|
|
variable "main_private_subnet_id" {
|
|
type = string
|
|
description = "ID of the main private subnet of the project"
|
|
}
|
|
|
|
variable "default_security_group_id" {
|
|
type = string
|
|
description = "ID of the 'default_for_all' security group of the project"
|
|
}
|
|
|
|
variable "dns_zone_name" {
|
|
type = string
|
|
description = "Name of the DNS zone of the project, with the trailing dot"
|
|
}
|
|
|
|
variable "resolvers_ip" {
|
|
type = list(string)
|
|
description = "DNS resolvers configured on the dedicated subnet"
|
|
}
|
|
|
|
variable "mtu_size" {
|
|
type = number
|
|
description = "MTU of the dedicated network"
|
|
}
|
|
|
|
variable "main_region" {
|
|
type = string
|
|
description = "OpenStack region of the dedicated network"
|
|
}
|
|
|
|
variable "availability_zone" {
|
|
type = string
|
|
description = "Availability zone hint of the instance"
|
|
}
|
|
|
|
variable "image" {
|
|
description = "Image of the instance: uuid and cloud-init user data file"
|
|
type = object({
|
|
uuid = string
|
|
user_data_file = string
|
|
})
|
|
}
|
|
|
|
variable "ssh_key_name" {
|
|
type = string
|
|
description = "Name of the SSH key pair injected by cloud-init"
|
|
}
|
|
|
|
# Optional DNS record, useful when the service has to be reached by name
|
|
variable "dns_zone_id" {
|
|
type = string
|
|
default = ""
|
|
description = "ID of the DNS zone. Required when postgresql_recordset_name is set"
|
|
}
|
|
|
|
variable "postgresql_recordset_name" {
|
|
type = string
|
|
default = ""
|
|
description = "Name of an A record pointing to the main network address, with the trailing dot. Empty means no record"
|
|
}
|