-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarget-bucket.tf
45 lines (40 loc) · 941 Bytes
/
target-bucket.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
resource "aws_s3_bucket" "target" {
bucket = var.target_bucket_name
force_destroy = true
}
resource "aws_iam_policy" "target_bucket_access" {
name = "${var.target_bucket_name}-access"
policy = data.aws_iam_policy_document.target_bucket_access.json
}
data "aws_iam_policy_document" "target_bucket_access" {
statement {
effect = "Allow"
actions = [
"s3:PutAccountPublicAccessBlock",
"s3:GetAccountPublicAccessBlock",
"s3:ListAllMyBuckets",
"s3:ListJobs",
"s3:CreateJob",
"s3:ListBucket"
]
resources = [
"*",
]
}
statement {
effect = "Allow"
actions = [
"s3:*"
]
resources = [
aws_s3_bucket.target.arn,
"${aws_s3_bucket.target.arn}/*",
"arn:aws:s3:*:*:job/*",
]
}
}
resource "aws_s3_object" "file" {
bucket = aws_s3_bucket.target.id
key = var.s3_object_key
source = "${path.module}/files/ric-flair-woo.gif"
}