variables.tf 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. variable "name" {
  2. type = string
  3. description = "Bucket name. Unique across all of Spaces in the region. 3 to 63 characters: lowercase letters, digits and hyphens, starting and ending with a letter or digit."
  4. validation {
  5. condition = can(regex("^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$", var.name))
  6. error_message = "name must be 3 to 63 characters: lowercase letters, digits and hyphens, starting and ending with a letter or digit."
  7. }
  8. }
  9. variable "region" {
  10. type = string
  11. description = "Spaces region slug, such as tor1 (three letters and a digit)."
  12. validation {
  13. condition = can(regex("^[a-z]{3}[0-9]$", var.region))
  14. error_message = "region must be a Spaces region slug: three lowercase letters and a digit, such as tor1."
  15. }
  16. }
  17. variable "acl" {
  18. type = string
  19. default = "private"
  20. description = "Bucket ACL. Only private is accepted: the bucket holds daemon state and must never be listable or readable by the public. The variable exists so that a public value fails loudly instead of being ignored."
  21. validation {
  22. condition = var.acl == "private"
  23. error_message = "acl must be private. public-read, public-read-write and every other value are refused."
  24. }
  25. }
  26. variable "noncurrent_version_expiration_days" {
  27. type = number
  28. default = 90
  29. description = "Days after which a noncurrent (overwritten or deleted) object version expires. This is how long a restore from a previous version stays possible."
  30. validation {
  31. condition = var.noncurrent_version_expiration_days == floor(var.noncurrent_version_expiration_days) && var.noncurrent_version_expiration_days >= 1 && var.noncurrent_version_expiration_days <= 3650
  32. error_message = "noncurrent_version_expiration_days must be a whole number from 1 to 3650."
  33. }
  34. }
  35. variable "create_access_keys" {
  36. type = bool
  37. default = false
  38. description = "Create the Spaces access keys named in access_key_names. Off by default: a key's secret lands in OpenTofu state, which the stage 3 design accepts only once state access is restricted; until then create keys by hand and keep them in Doppler."
  39. }
  40. variable "access_key_names" {
  41. type = list(string)
  42. default = []
  43. description = "Names of the access keys to create, one per daemon. Each key gets readwrite on this one bucket and nothing else. Only used when create_access_keys is true."
  44. validation {
  45. condition = alltrue([for n in var.access_key_names : can(regex("^[a-z0-9][a-z0-9-]{0,62}$", n))])
  46. error_message = "Each access key name must be 1 to 63 characters: lowercase letters, digits and hyphens, starting with a letter or digit."
  47. }
  48. validation {
  49. condition = length(var.access_key_names) == length(distinct(var.access_key_names))
  50. error_message = "access_key_names must not repeat a name."
  51. }
  52. }