-
Notifications
You must be signed in to change notification settings - Fork 2
/
s3.tf
47 lines (38 loc) · 1.21 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
42
43
44
45
46
47
locals {
bucket_region = var.create_bucket ? aws_s3_bucket.warpstream[0].region : data.aws_s3_bucket.warpstream[0].region
bucket_arn = var.create_bucket ? aws_s3_bucket.warpstream[0].arn : data.aws_s3_bucket.warpstream[0].arn
tags = {
"Managed-By" = "warpstream"
}
}
data "aws_s3_bucket" "warpstream" {
count = var.create_bucket ? 0 : 1
bucket = var.bucket_name
}
resource "aws_s3_bucket" "warpstream" {
count = var.create_bucket ? 1 : 0
bucket = var.bucket_name
tags = merge(local.tags, {
Name = var.bucket_name
})
}
resource "aws_s3_bucket_metric" "warpstream" {
count = var.create_bucket ? 1 : 0
bucket = aws_s3_bucket.warpstream[0].id
name = "EntireBucket"
}
resource "aws_s3_bucket_lifecycle_configuration" "warpstream" {
count = var.create_bucket ? 1 : 0
bucket = aws_s3_bucket.warpstream[0].id
# Automatically cancel all multi-part uploads after 7d so we don't accumulate an infinite
# number of partial uploads.
rule {
id = "7d multi-part"
status = "Enabled"
abort_incomplete_multipart_upload {
days_after_initiation = 7
}
}
# No other lifecycle policy. The WarpStream Agent will automatically clean up and
# deleted expired files.
}