dynamo.tf 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. DynamoDB is used to store cluster state, event
  3. metadata, and a simple locking mechanism for SSL
  4. cert generation and renewal.
  5. */
  6. // DynamoDB table for storing cluster state
  7. resource "aws_dynamodb_table" "teleport" {
  8. name = var.cluster_name
  9. read_capacity = 10
  10. write_capacity = 10
  11. hash_key = "HashKey"
  12. range_key = "FullPath"
  13. server_side_encryption {
  14. enabled = true
  15. }
  16. lifecycle {
  17. ignore_changes = [
  18. read_capacity,
  19. write_capacity,
  20. ]
  21. }
  22. attribute {
  23. name = "HashKey"
  24. type = "S"
  25. }
  26. attribute {
  27. name = "FullPath"
  28. type = "S"
  29. }
  30. stream_enabled = "true"
  31. stream_view_type = "NEW_IMAGE"
  32. ttl {
  33. attribute_name = "Expires"
  34. enabled = true
  35. }
  36. tags = {
  37. TeleportCluster = var.cluster_name
  38. }
  39. }
  40. // DynamoDB table for storing cluster events
  41. resource "aws_dynamodb_table" "teleport_events" {
  42. name = "${var.cluster_name}-events"
  43. read_capacity = 10
  44. write_capacity = 10
  45. hash_key = "SessionID"
  46. range_key = "EventIndex"
  47. server_side_encryption {
  48. enabled = true
  49. }
  50. global_secondary_index {
  51. name = "timesearch"
  52. hash_key = "EventNamespace"
  53. range_key = "CreatedAt"
  54. write_capacity = 10
  55. read_capacity = 10
  56. projection_type = "ALL"
  57. }
  58. lifecycle {
  59. ignore_changes = [
  60. read_capacity,
  61. write_capacity,
  62. ]
  63. }
  64. attribute {
  65. name = "SessionID"
  66. type = "S"
  67. }
  68. attribute {
  69. name = "EventIndex"
  70. type = "N"
  71. }
  72. attribute {
  73. name = "EventNamespace"
  74. type = "S"
  75. }
  76. attribute {
  77. name = "CreatedAt"
  78. type = "N"
  79. }
  80. ttl {
  81. attribute_name = "Expires"
  82. enabled = true
  83. }
  84. tags = {
  85. TeleportCluster = var.cluster_name
  86. }
  87. }
  88. // DynamoDB table for simple locking mechanism
  89. resource "aws_dynamodb_table" "teleport_locks" {
  90. name = "${var.cluster_name}-locks"
  91. read_capacity = 5
  92. write_capacity = 5
  93. hash_key = "Lock"
  94. billing_mode = "PROVISIONED"
  95. lifecycle {
  96. ignore_changes = [
  97. read_capacity,
  98. write_capacity,
  99. ]
  100. }
  101. attribute {
  102. name = "Lock"
  103. type = "S"
  104. }
  105. ttl {
  106. attribute_name = "Expires"
  107. enabled = true
  108. }
  109. tags = {
  110. TeleportCluster = var.cluster_name
  111. }
  112. }