forked from Tohmua/terraform-aws-bastion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buckets.tf
56 lines (45 loc) · 1.23 KB
/
buckets.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
resource "aws_s3_bucket" "bucket" {
bucket = var.bucket_name
force_destroy = var.bucket_force_destroy
tags = merge(var.tags)
}
resource "aws_s3_bucket_server_side_encryption_configuration" "bucket" {
bucket = aws_s3_bucket.bucket.id
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = aws_kms_key.key.id
sse_algorithm = "aws:kms"
}
}
}
resource "aws_s3_bucket_acl" "bucket" {
bucket = aws_s3_bucket.bucket.id
acl = "private"
}
resource "aws_s3_bucket_versioning" "bucket" {
bucket = aws_s3_bucket.bucket.id
versioning_configuration {
status = var.bucket_versioning ? "Enabled" : "Suspended"
}
}
resource "aws_s3_bucket_lifecycle_configuration" "bucket" {
bucket = aws_s3_bucket.bucket.id
rule {
id = "log"
status = var.enable_logs_s3_sync && var.log_auto_clean ? "Enabled" : "Disabled"
filter {
prefix = "logs/"
}
transition {
days = var.log_standard_ia_days
storage_class = "STANDARD_IA"
}
transition {
days = var.log_glacier_days
storage_class = "GLACIER"
}
expiration {
days = var.log_expiry_days
}
}
}