-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3_admin.tf
80 lines (69 loc) Β· 1.75 KB
/
s3_admin.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
resource "aws_s3_bucket" "repick_admin_bucket" {
bucket = "repick-admin-bucket"
tags = {
Name = "repick-admin-bucket"
}
}
resource "aws_s3_bucket_public_access_block" "repick_admin_bucket_public_access_block" {
bucket = aws_s3_bucket.repick_admin_bucket.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
resource "aws_s3_bucket_policy" "repick_admin_bucket_policy" {
bucket = aws_s3_bucket.repick_admin_bucket.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "s3:GetObject"
Effect = "Allow"
Resource = "${aws_s3_bucket.repick_admin_bucket.arn}/*"
Principal = "*"
},
{
Action = "s3:PutObject"
Effect = "Allow"
Resource = "${aws_s3_bucket.repick_admin_bucket.arn}/*"
Principal = "*"
}
]
})
}
resource "aws_iam_role" "repick_admin_bucket_upload_role" {
name = "s3_upload_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "ec2.amazonaws.com"
}
Action = "sts:AssumeRole"
}
]
})
}
resource "aws_iam_role_policy" "repick_admin_bucket_upload_policy" {
name = "s3_upload_policy"
role = aws_iam_role.repick_admin_bucket_upload_role.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket"
]
Resource = [
aws_s3_bucket.repick_admin_bucket.arn,
"${aws_s3_bucket.repick_admin_bucket.arn}/*"
]
}
]
})
}