dynamo.tf 2.5 KB

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