-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
41 lines (39 loc) · 1.23 KB
/
s3.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
##########################################
# S3 configurations for CloudTrail #
##########################################
resource "aws_s3_bucket" "cloudtrail-logging" {
bucket = "${var.s3_prefix}-aws-cloudtrail"
tags = var.tags
}
resource "aws_s3_bucket_ownership_controls" "cloudtrail-logging" {
bucket = aws_s3_bucket.cloudtrail-logging.id
rule {
object_ownership = "ObjectWriter"
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "cloudtrail-logging" {
bucket = aws_s3_bucket.cloudtrail-logging.bucket
rule {
apply_server_side_encryption_by_default {
# AES256 is the only supported option for bucket logging
# https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerLogs.html#server-access-logging-overview
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_versioning" "cloudtrail-logging" {
bucket = aws_s3_bucket.cloudtrail-logging.bucket
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket_lifecycle_configuration" "cloudtrail-logging" {
bucket = aws_s3_bucket.cloudtrail-logging.bucket
rule {
id = "Delete previous after 35 days"
status = "Enabled"
noncurrent_version_expiration {
noncurrent_days = "35"
}
}
}