generated from DNXLabs/terraform-aws-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiam-roles.tf
105 lines (92 loc) · 2.02 KB
/
iam-roles.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
resource "aws_iam_role" "sftp" {
name = "${var.name}-transfer-server-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "transfer.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
tags = {
Name = "${var.name}-transfer-server-role"
Terraform = "true"
}
}
resource "aws_iam_role_policy" "sftp" {
// policy to allow invocation of IdP API
name = "${var.name}-sftp-server-iam-policy"
role = aws_iam_role.sftp.id
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "InvokeApi",
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": "arn:aws:execute-api:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:${aws_api_gateway_rest_api.sftp-idp-secrets.id}/${aws_api_gateway_stage.prod.stage_name}/GET/*"
},
{
"Sid": "ReadApi",
"Effect": "Allow",
"Action": [
"apigateway:GET"
],
"Resource": "*"
}
]
}
POLICY
}
resource "aws_iam_role" "sftp-logging" {
name = "${var.name}-transfer-server-logging-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "transfer.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
tags = {
Name = "${var.name}-transfer-server-logging-role"
Terraform = "true"
}
}
resource "aws_iam_role_policy" "sftp-logging" {
name = "${var.name}-sftp-logging-policy"
role = aws_iam_role.sftp-logging.id
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:CreateLogGroup",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
POLICY
}