-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathiam.tf
More file actions
80 lines (73 loc) · 1.79 KB
/
iam.tf
File metadata and controls
80 lines (73 loc) · 1.79 KB
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_iam_role" "slackConnector" {
name = "ukrops_emojiBot_slackConnector-${terraform.workspace}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow"
}
]
}
EOF
tags = {
Terraform = "true"
}
}
# Allow lambda to write logs
resource "aws_iam_role_policy" "slackConnectorLogs" {
name = "slackConnector_cloudwatch_access-${terraform.workspace}"
role = aws_iam_role.slackConnector.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}
resource "aws_iam_role_policy" "slackConnectorSecrets" {
name = "slackConnector_secrets_access-${terraform.workspace}"
role = aws_iam_role.slackConnector.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:GetParameter*"
],
"Resource": "arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/ukrops/emojiBot/${terraform.workspace}/*"
},
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": "${aws_kms_key.emojiBot_slackApi.arn}"
}
]
}
EOF
}
resource "aws_lambda_permission" "slackConnector_allow_APIGateway" {
statement_id = "AllowExecutionFromAPIGateway"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.slackConnector.function_name
principal = "apigateway.amazonaws.com"
source_arn = "${aws_api_gateway_rest_api.emojiBot.execution_arn}/*"
}