-
Notifications
You must be signed in to change notification settings - Fork 1
/
s3.tf
38 lines (31 loc) · 856 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
resource "aws_s3_bucket" "postgres" {
bucket = local.bucket-name
versioning {
enabled = true
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
acl = "private"
}
resource "aws_s3_bucket_object" "stuff" {
for_each = fileset(path.module, "postgres/**")
bucket = aws_s3_bucket.postgres.bucket
key = each.value
source = "${path.module}/${each.value}"
etag = filemd5("${path.module}/${each.value}")
}
resource "aws_s3_bucket_public_access_block" "access" {
bucket = aws_s3_bucket.postgres.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
locals {
bucket-name = "postgres-init-${data.aws_caller_identity.current.account_id}"
}