-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.tf
53 lines (42 loc) · 1.12 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
48
49
50
51
52
53
resource "aws_s3_bucket" "s3-1" {
bucket = "sky-s3-main28"
tags = {
Environment = "terraformChamps"
Owner = "Sama"
}
force_destroy = true # force destroy even if the bucket not empty
}
resource "aws_s3_bucket_ownership_controls" "controls" {
bucket = aws_s3_bucket.s3-1.id
rule {
object_ownership = "BucketOwnerEnforced"
}
}
# Enable bucket versioning
resource "aws_s3_bucket_versioning" "ver-s3-1" {
bucket = aws_s3_bucket.s3-1.id
versioning_configuration {
status = "Enabled"
}
}
# Configure objects encryption as "SSE-S3"
resource "aws_s3_bucket_server_side_encryption_configuration" "encryption" {
bucket = aws_s3_bucket.s3-1.bucket
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
bucket_key_enabled = true # Enable Bucket key.
}
}
# Configure life cycle expiration object at 7 days
resource "aws_s3_bucket_lifecycle_configuration" "bucket-Configure" {
bucket = aws_s3_bucket.s3-1.id
rule {
id = "expiration object at 7 days"
expiration {
days = 7
}
status = "Enabled"
}
}