-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathec2.tf
74 lines (65 loc) · 1.67 KB
/
ec2.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
resource "aws_iam_instance_profile" "ec2_deidentification_instance_profile" {
name = "sbeacon_backend_ec2_deidentification_instance_profile"
role = aws_iam_role.ec2_deidentification_instance_role.name
}
resource "aws_iam_role" "ec2_deidentification_instance_role" {
name = "sbeacon_backend_ec2_deidentification_instance_role"
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role_policy.json
}
data "aws_iam_policy_document" "ec2_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role_policy" "ec2_deidentification_policy" {
name = "sbeacon_backend_ec2_deidentification_policy"
role = aws_iam_role.ec2_deidentification_instance_role.id
policy = data.aws_iam_policy_document.ec2_deidentification_policy.json
}
data "aws_iam_policy_document" "ec2_deidentification_policy" {
statement {
actions = [
"s3:ListBucket",
]
resources = [
aws_s3_bucket.dataportal-bucket.arn,
]
condition {
test = "StringLike"
variable = "s3:prefix"
values = [
"projects/*/",
"staging/projects/*/",
]
}
}
statement {
actions = [
"s3:GetObject",
"s3:DeleteObject",
]
resources = [
"${aws_s3_bucket.dataportal-bucket.arn}/staging/projects/*",
]
}
statement {
actions = [
"s3:PutObject",
]
resources = [
"${aws_s3_bucket.dataportal-bucket.arn}/projects/*",
]
}
statement {
actions = [
"dynamodb:UpdateItem",
]
resources = [
aws_dynamodb_table.vcfs.arn,
]
}
}