s3.tf 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. acl = "private"
  10. force_destroy = var.instance_termination_protection ? false : true # reverse of termination protection, destroy if no termination protection
  11. server_side_encryption_configuration {
  12. rule {
  13. apply_server_side_encryption_by_default {
  14. kms_master_key_id = aws_kms_key.s3.arn
  15. sse_algorithm = "aws:kms"
  16. }
  17. }
  18. }
  19. lifecycle_rule {
  20. id = "DeleteAfter90Days"
  21. enabled = true
  22. abort_incomplete_multipart_upload_days = 7
  23. expiration {
  24. days = 90
  25. }
  26. }
  27. }
  28. resource "aws_s3_bucket_public_access_block" "awsconfig_bucket_block_public_access" {
  29. block_public_acls = true
  30. block_public_policy = true
  31. bucket = aws_s3_bucket.storage.id
  32. ignore_public_acls = true
  33. restrict_public_buckets = true
  34. }