s3.tf 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Configuration of S3 bucket for certs and replay
  3. storage. Uses server side encryption to secure
  4. session replays and SSL certificates.
  5. */
  6. // S3 bucket for cluster storage
  7. resource "aws_s3_bucket" "storage" {
  8. bucket = "${var.instance_name}-${var.environment}"
  9. force_destroy = var.instance_termination_protection ? false : true # reverse of termination protection, destroy if no termination protection
  10. }
  11. resource "aws_s3_bucket_acl" "s3_acl_storage" {
  12. bucket = aws_s3_bucket.storage.id
  13. acl = "private"
  14. }
  15. resource "aws_s3_bucket_server_side_encryption_configuration" "s3_sse_storage" {
  16. bucket = aws_s3_bucket.storage.id
  17. rule {
  18. apply_server_side_encryption_by_default {
  19. sse_algorithm = "aws:kms"
  20. }
  21. }
  22. }
  23. resource "aws_s3_bucket_lifecycle_configuration" "s3_lifecyle_storage" {
  24. bucket = aws_s3_bucket.storage.id
  25. rule {
  26. id = "DeleteAfter90Days"
  27. status = "Enabled"
  28. abort_incomplete_multipart_upload {
  29. days_after_initiation = 7
  30. }
  31. expiration {
  32. days = 90
  33. }
  34. }
  35. }
  36. resource "aws_s3_bucket_public_access_block" "awsconfig_bucket_block_public_access" {
  37. block_public_acls = true
  38. block_public_policy = true
  39. bucket = aws_s3_bucket.storage.id
  40. ignore_public_acls = true
  41. restrict_public_buckets = true
  42. }
  43. //AWS Provider outdated arguments <4.4.0
  44. /*resource "aws_s3_bucket" "storage" {
  45. bucket = "${var.instance_name}-${var.environment}"
  46. acl = "private"
  47. force_destroy = var.instance_termination_protection ? false : true # reverse of termination protection, destroy if no termination protection
  48. server_side_encryption_configuration {
  49. rule {
  50. apply_server_side_encryption_by_default {
  51. kms_master_key_id = aws_kms_key.s3.arn
  52. sse_algorithm = "aws:kms"
  53. }
  54. }
  55. }
  56. lifecycle_rule {
  57. id = "DeleteAfter90Days"
  58. enabled = true
  59. abort_incomplete_multipart_upload_days = 7
  60. expiration {
  61. days = 90
  62. }
  63. }
  64. }
  65. */