-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.tf
34 lines (28 loc) · 802 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
resource "aws_s3_bucket" "this" {
bucket = var.bucket_name
}
resource "aws_s3_bucket_public_access_block" "this" {
bucket = aws_s3_bucket.this.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
data "aws_iam_policy_document" "s3_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.this.arn}/*"]
principals {
type = "AWS"
identifiers = [aws_cloudfront_origin_access_identity.default.iam_arn]
}
}
}
resource "aws_s3_bucket_policy" "allow-cloudfront" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.s3_policy.json
}
output "bucket" {
value = aws_s3_bucket.this.bucket
description = "Name of the Bucket"
}