-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiam.tf
50 lines (41 loc) · 1.47 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
resource "aws_iam_role" "lambda_exec" {
name = "${var.bot_name}-lambda-role"
assume_role_policy = "${data.aws_iam_policy_document.ssm_role_policy.json}"
}
data "aws_iam_policy_document" "ssm_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ssm.amazonaws.com", "lambda.amazonaws.com", "sns.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "ssm_parameter_policy" {
statement {
actions = [
"ssm:DescribeParameter*",
"ssm:GetParameter*",
"ssm:PutParameter*",
"ssm:DeleteParameter",
]
resources = ["*"]
}
}
resource "aws_iam_role_policy_attachment" "attach_ssm_parameter_policy" {
role = "${aws_iam_role.lambda_exec.name}"
policy_arn = "${aws_iam_policy.ssm_parameter_policy.arn}"
}
resource "aws_iam_policy" "ssm_parameter_policy" {
name = "ssm_parameter_policy_${var.app_version}_${var.bot_name}"
description = "Access to the Parameter store for ${var.app_version}_${var.bot_name}"
policy = "${data.aws_iam_policy_document.ssm_parameter_policy.json}"
}
resource "aws_iam_role_policy_attachment" "attach_ssm_automation" {
role = "${aws_iam_role.lambda_exec.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonSSMAutomationRole"
}
resource "aws_iam_role_policy_attachment" "basic" {
role = "${aws_iam_role.lambda_exec.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}