-
Notifications
You must be signed in to change notification settings - Fork 5
/
data.tf
54 lines (49 loc) · 1.56 KB
/
data.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
data "aws_caller_identity" "current" {}
data "aws_partition" "current" {}
data "aws_region" "current" {}
locals {
region = data.aws_region.current.name
account_id = data.aws_caller_identity.current.account_id
partition = data.aws_partition.current.partition
}
data "aws_iam_policy_document" "agent_trust" {
count = var.create_agent ? 1 : 0
statement {
actions = ["sts:AssumeRole"]
principals {
identifiers = ["bedrock.amazonaws.com"]
type = "Service"
}
condition {
test = "StringEquals"
values = [local.account_id]
variable = "aws:SourceAccount"
}
condition {
test = "ArnLike"
values = ["arn:${local.partition}:bedrock:${local.region}:${local.account_id}:agent/*"]
variable = "AWS:SourceArn"
}
}
}
data "aws_iam_policy_document" "agent_permissions" {
count = var.create_agent ? 1 : 0
statement {
actions = [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
]
resources = [
"arn:${local.partition}:bedrock:${local.region}::foundation-model/${var.foundation_model}",
"arn:${local.partition}:bedrock:*::foundation-model/${var.foundation_model}",
"arn:${local.partition}:bedrock:${local.region}:${local.account_id}:inference-profile/*.${var.foundation_model}",
]
}
}
data "aws_iam_policy_document" "knowledge_base_permissions" {
count = var.create_kb ? 1 : 0
statement {
actions = ["bedrock:Retrieve"]
resources = ["arn:${local.partition}:bedrock:${local.region}:${local.account_id}:knowledge-base/*"]
}
}