-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprovisionssmsessionmanager_policy.tf
55 lines (48 loc) · 1.53 KB
/
provisionssmsessionmanager_policy.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
# ------------------------------------------------------------------------------
# Create the IAM policy that allows all of the permissions necessary
# to provision the SSM Document resource and set up SSM session
# logging in this account.
# ------------------------------------------------------------------------------
data "aws_iam_policy_document" "provisionssmsessionmanager_policy_doc" {
# SSM document permissions
statement {
actions = [
"ssm:AddTagsToResource",
"ssm:CreateDocument",
"ssm:DeleteDocument",
"ssm:DescribeDocument*",
"ssm:GetDocument",
"ssm:UpdateDocument*",
]
resources = [
"arn:aws:ssm:${var.aws_region}:${local.assessment_account_id}:document/SSM-SessionManagerRunShell",
]
}
# CloudWatch log group permissions
statement {
actions = [
"logs:CreateLogGroup",
"logs:DescribeLogGroups",
"logs:ListTagsLogGroup",
]
resources = [
"*",
]
}
statement {
actions = [
"logs:DeleteLogGroup",
"logs:PutRetentionPolicy",
"logs:TagLogGroup",
]
resources = [
"arn:aws:logs:${var.aws_region}:${local.assessment_account_id}:log-group:${var.session_cloudwatch_log_group_name}:*",
]
}
}
resource "aws_iam_policy" "provisionssmsessionmanager_policy" {
provider = aws.provisionassessment
description = var.provisionssmsessionmanager_policy_description
name = var.provisionssmsessionmanager_policy_name
policy = data.aws_iam_policy_document.provisionssmsessionmanager_policy_doc.json
}