-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathiam_role.tf
More file actions
76 lines (69 loc) · 2.18 KB
/
iam_role.tf
File metadata and controls
76 lines (69 loc) · 2.18 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
############################################################
# OIDC role/policy for TfAwsVeraSlackBot to SyncKnowledgeBase
############################################################
# Role for GitHub Actions to assume
resource "aws_iam_role" "kb_sync_role" {
name = "${local.bot_name}KBSyncRole"
max_session_duration = 43200 # 12 hours
assume_role_policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Sid" : "GitHubActionsOIDC",
"Effect" : "Allow",
"Principal" : {
"Federated" : "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/token.actions.githubusercontent.com"
},
"Action" : [
"sts:AssumeRoleWithWebIdentity",
"sts:TagSession"
],
"Condition" : {
"StringEquals" : {
"token.actions.githubusercontent.com:aud" : "sts.amazonaws.com"
},
StringLike : {
"token.actions.githubusercontent.com:sub" : [
"repo:YOUR_ORG/YOUR_REPO:environment:*:job_workflow_ref:YOUR_ORG/YOUR_REPO/.github/workflows/sync.yml@refs/heads/*",
]
}
}
}
]
})
}
# policy for oidc assume role
resource "aws_iam_policy" "kb_sync_policy" {
name = "${local.bot_name}KBSyncPolicy"
description = "Permissions to sync bedrock knowledge base"
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
# Bedrock
"bedrock:SyncKnowledgeBase",
"bedrock:GetKnowledgeBase",
"bedrock:GetDataSource",
"bedrock:GetIngestionJob",
"bedrock:ListIngestionJobs",
"bedrock:StartIngestionJob",
"bedrock:ListDataSources",
"bedrock:GetDataSources",
# KMS
"kms:Decrypt",
# Secrets Manager
# needed for confluence credentials
"secretsmanager:GetSecretValue",
],
Resource = "*"
}
]
})
}
# Attach policy to role
resource "aws_iam_role_policy_attachment" "kb_sync_role_policy_attach" {
role = aws_iam_role.kb_sync_role.name
policy_arn = aws_iam_policy.kb_sync_policy.arn
}