-
Notifications
You must be signed in to change notification settings - Fork 35
/
s3.tf
48 lines (39 loc) · 1.11 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
## S3 bucket and objects
resource "aws_s3_bucket" "staging" {
bucket = "operator-staging-${local.rs}"
tags = {
Name = "Operator Lab"
Environment = "Dev"
}
}
data "aws_iam_policy_document" "public_access" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.staging.arn}/*"]
effect = "Allow"
principals {
type = "*"
identifiers = ["*"]
}
}
}
resource "aws_s3_bucket_policy" "staging" {
bucket = aws_s3_bucket.staging.id
policy = data.aws_iam_policy_document.public_access.json
}
resource "aws_s3_bucket_public_access_block" "staging" {
bucket = aws_s3_bucket.staging.id
block_public_acls = false
ignore_public_acls = false
block_public_policy = false
restrict_public_buckets = false
}
resource "aws_s3_object" "template_objects" {
count = length(local.templatefiles)
bucket = aws_s3_bucket.staging.id
key = "${replace(basename(local.templatefiles[count.index].name), ".tpl", "")}"
content = local.script_contents[count.index]
}
output "storage_bucket" {
value = aws_s3_bucket.staging.id
}