-
Notifications
You must be signed in to change notification settings - Fork 5
/
s3_bucket.tf
39 lines (31 loc) · 1016 Bytes
/
s3_bucket.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
# The S3 bucket
resource "aws_s3_bucket" "s3_bucket" {
bucket = var.s3_bucket_name
tags = merge({ Name = var.s3_bucket_name }, var.tags)
}
resource "aws_s3_bucket_acl" "name" {
bucket = aws_s3_bucket.s3_bucket.id
acl = "private"
}
resource "aws_s3_bucket_versioning" "s3_bucket" {
bucket = aws_s3_bucket.s3_bucket.id
versioning_configuration {
status = var.s3_versioning_enabled ? "Enabled" : "Suspended"
}
}
resource "aws_s3_bucket_lifecycle_configuration" "s3_bucket" {
bucket = aws_s3_bucket.s3_bucket.id
rule {
status = var.lifecycle_rule_enabled ? "Enabled" : "Disabled" #default = false
id = var.lifecycle_config_rule_id #required #default = ""
filter {
prefix = var.lifecycle_rule_prefix #default = whole bucket
}
expiration {
days = var.lifecycle_rule_expiration #default = 0
}
noncurrent_version_expiration {
noncurrent_days = var.lifecycle_rule_noncurrent_version_expiration #default = 90
}
}
}