-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot.tf
65 lines (61 loc) · 1.87 KB
/
chatbot.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
data "aws_iam_policy_document" "chatbot_role_policy" {
statement {
sid = "ChatbotReadOnlyPolicy"
effect = "Deny"
actions = [
"iam:*",
"s3:GetBucketPolicy",
"ssm:*",
"sts:*",
"kms:*",
"cognito-idp:GetSigningCertificate",
"ec2:GetPasswordData",
"ecr:GetAuthorizationToken",
"gamelift:RequestUploadCredentials",
"gamelift:GetInstanceAccess",
"lightsail:DownloadDefaultKeyPair",
"lightsail:GetInstanceAccessDetails",
"lightsail:GetKeyPair",
"lightsail:GetKeyPairs",
"redshift:GetClusterCredentials",
"storagegateway:DescribeChapCredentials"
]
resources = [
"*"
]
}
}
resource "aws_iam_role_policy" "chatbot_policy" {
name = "ChatbotNotificationsPolicy"
role = aws_iam_role.chatbot_role.id
policy = data.aws_iam_policy_document.chatbot_role_policy.json
}
resource "aws_iam_role" "chatbot_role" {
name = "ChatbotNotificationsRole"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "ChatbotNotificationsAssumeRolePolicy"
Effect = "Allow"
Action = "sts:AssumeRole"
Principal = {
Service = "chatbot.amazonaws.com"
}
}
]
})
}
resource "aws_iam_policy_attachment" "chatbot_readonly_policy_attachment" {
name = "ChatbotReadOnlyPolicyAttachment"
roles = [aws_iam_role.chatbot_role.name]
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess"
}
resource "awscc_chatbot_slack_channel_configuration" "send_sns_to_slack" {
configuration_name = "RootLoginAttemptNotifications"
iam_role_arn = aws_iam_role.chatbot_role.arn
slack_channel_id = "A0B1C2D3E4F"
slack_workspace_id = "T0U1V2W3X4Y"
sns_topic_arns = [aws_sns_topic.root_console_logins.arn]
guardrail_policies = ["arn:aws:iam::aws:policy/AWSDenyAll"]
}