-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathiam.tf
63 lines (53 loc) · 1.59 KB
/
iam.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
data "aws_iam_policy_document" "transfer_server_assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["transfer.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "transfer_server_assume_policy" {
statement {
effect = "Allow"
actions = [
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:GetObjectVersion",
"s3:ListBucket",
"s3:PutObject",
]
resources = [
var.bucket_arn,
"${var.bucket_arn}/*"
]
}
}
data "aws_iam_policy_document" "transfer_server_to_cloudwatch_assume_policy" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
]
resources = ["*"]
}
}
resource "aws_iam_role" "transfer_server_role" {
name = "${var.transfer_server_name}-transfer_server_role"
assume_role_policy = data.aws_iam_policy_document.transfer_server_assume_role.json
}
resource "aws_iam_role_policy" "transfer_server_policy" {
name = "${var.transfer_server_name}-transfer_server_policy"
role = aws_iam_role.transfer_server_role.name
policy = data.aws_iam_policy_document.transfer_server_assume_policy.json
}
resource "aws_iam_role_policy" "transfer_server_to_cloudwatch_policy" {
name = "${var.transfer_server_name}-transfer_server_to_cloudwatch_policy"
role = aws_iam_role.transfer_server_role.name
policy = data.aws_iam_policy_document.transfer_server_to_cloudwatch_assume_policy.json
}