dynamo.tf 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #checkov:skip=CKV2_AWS_16:Auto Scaling not needed at this time
  9. resource "aws_dynamodb_table" "teleport" {
  10. name = var.instance_name
  11. read_capacity = 10
  12. write_capacity = 10
  13. hash_key = "HashKey"
  14. range_key = "FullPath"
  15. billing_mode = "PROVISIONED"
  16. server_side_encryption {
  17. kms_key_arn = aws_kms_key.s3.arn
  18. enabled = true
  19. }
  20. lifecycle {
  21. ignore_changes = [
  22. read_capacity,
  23. write_capacity,
  24. ]
  25. }
  26. attribute {
  27. name = "HashKey"
  28. type = "S"
  29. }
  30. attribute {
  31. name = "FullPath"
  32. type = "S"
  33. }
  34. point_in_time_recovery {
  35. enabled = true
  36. }
  37. stream_enabled = "true"
  38. stream_view_type = "NEW_IMAGE"
  39. ttl {
  40. attribute_name = "Expires"
  41. enabled = true
  42. }
  43. tags = merge(local.standard_tags, var.tags, { Name = var.instance_name })
  44. }
  45. // DynamoDB table for storing cluster events
  46. #checkov:skip=CKV2_AWS_16:Auto Scaling not needed at this time
  47. resource "aws_dynamodb_table" "teleport_events" {
  48. name = "${var.instance_name}-events"
  49. read_capacity = 10
  50. write_capacity = 10
  51. hash_key = "SessionID"
  52. range_key = "EventIndex"
  53. billing_mode = "PROVISIONED"
  54. server_side_encryption {
  55. kms_key_arn = aws_kms_key.s3.arn
  56. enabled = true
  57. }
  58. global_secondary_index {
  59. name = "timesearchV2"
  60. hash_key = "CreatedAtDate"
  61. range_key = "CreatedAt"
  62. write_capacity = 10
  63. read_capacity = 10
  64. projection_type = "ALL"
  65. }
  66. lifecycle {
  67. ignore_changes = [
  68. read_capacity,
  69. write_capacity,
  70. ]
  71. }
  72. attribute {
  73. name = "SessionID"
  74. type = "S"
  75. }
  76. attribute {
  77. name = "EventIndex"
  78. type = "N"
  79. }
  80. attribute {
  81. name = "CreatedAtDate"
  82. type = "S"
  83. }
  84. attribute {
  85. name = "CreatedAt"
  86. type = "N"
  87. }
  88. point_in_time_recovery {
  89. enabled = true
  90. }
  91. ttl {
  92. attribute_name = "Expires"
  93. enabled = true
  94. }
  95. tags = merge(local.standard_tags, var.tags, { Name = var.instance_name })
  96. }
  97. // DynamoDB table for simple locking mechanism
  98. #checkov:skip=CKV2_AWS_16:Auto Scaling not needed at this time
  99. resource "aws_dynamodb_table" "locks" {
  100. name = "${var.instance_name}-locks"
  101. read_capacity = 5
  102. write_capacity = 5
  103. hash_key = "Lock"
  104. billing_mode = "PROVISIONED"
  105. #checkov:skip=CKV_AWS_119:Encrypted by AWS Owned key config'd via console
  106. #tfsec:ignore:aws-dynamodb-table-customer-key AWS Owned key config'd via console
  107. #tfsec:ignore:aws-dynamodb-enable-at-rest-encryption False positive
  108. server_side_encryption {
  109. enabled = false
  110. }
  111. lifecycle {
  112. ignore_changes = [
  113. read_capacity,
  114. write_capacity,
  115. ]
  116. }
  117. attribute {
  118. name = "Lock"
  119. type = "S"
  120. }
  121. #checkov:skip=CKV_AWS_28:No need for PiTR here
  122. point_in_time_recovery {
  123. enabled = false
  124. }
  125. ttl {
  126. attribute_name = "Expires"
  127. enabled = true
  128. }
  129. tags = merge(local.standard_tags, var.tags, { Name = var.instance_name })
  130. }