-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy paths3.tf
42 lines (33 loc) · 852 Bytes
/
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
42
data "aws_kms_alias" "s3" {
name = "alias/aws/s3"
}
resource "aws_s3_bucket" "storage" {
bucket = "spacelift-events-${random_string.suffix.result}"
}
resource "aws_s3_bucket_lifecycle_configuration" "cleanup" {
bucket = aws_s3_bucket.storage.id
rule {
id = "abort-incomplete-multipart-upload"
status = "Enabled"
abort_incomplete_multipart_upload {
days_after_initiation = 1
}
}
rule {
id = "delete-old-events"
status = "Enabled"
expiration {
days = var.events_expiration_days
}
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "storage" {
bucket = aws_s3_bucket.storage.id
rule {
bucket_key_enabled = true
apply_server_side_encryption_by_default {
kms_master_key_id = data.aws_kms_alias.s3.arn
sse_algorithm = "aws:kms"
}
}
}