-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbedrock_guardrail.tf
More file actions
165 lines (149 loc) · 4.74 KB
/
bedrock_guardrail.tf
File metadata and controls
165 lines (149 loc) · 4.74 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
locals {
# Anonymize the input or output if these types of data are detected
# For example, if a US_SOCIAL_SECURITY_NUMBER is detected, it will be replaced with "US_SOCIAL_SECURITY_NUMBER"
pii_anonymize_types = [
# PII
"US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER",
"US_SOCIAL_SECURITY_NUMBER",
"VEHICLE_IDENTIFICATION_NUMBER",
"US_PASSPORT_NUMBER",
# Financial
"CREDIT_DEBIT_CARD_NUMBER",
# Banking
"SWIFT_CODE",
"INTERNATIONAL_BANK_ACCOUNT_NUMBER",
# Technical items
"AWS_SECRET_KEY",
]
# Block the input or output if these types of data are detected
pii_block_types = []
}
resource "aws_bedrock_guardrail" "guardrail" {
provider = aws.west2
name = "VeraBotGuardrail"
blocked_input_messaging = "Your input has been blocked by the content filter. Please try again. If this is an error, discuss with the DevOps team."
blocked_outputs_messaging = "The output generated by our system has been blocked by the content filter. Please try again. If this is an error, discuss with the DevOps team."
description = "Vera Guardrail"
content_policy_config {
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "INSULTS"
}
filters_config {
input_strength = "LOW" # Medium strength blocking password reset questions
output_strength = "MEDIUM"
type = "MISCONDUCT"
}
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "SEXUAL"
}
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "VIOLENCE"
}
filters_config {
input_strength = "NONE"
output_strength = "NONE"
type = "PROMPT_ATTACK"
}
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "HATE"
}
}
sensitive_information_policy_config {
dynamic "pii_entities_config" {
for_each = local.pii_anonymize_types
content {
action = "ANONYMIZE"
type = pii_entities_config.value
}
}
dynamic "pii_entities_config" {
for_each = local.pii_block_types
content {
action = "BLOCK"
type = pii_entities_config.value
}
}
}
# topic_policy_config {
# topics_config {
# name = "company_investments"
# examples = [
# "When should I buy company stock?",
# ]
# type = "DENY"
# definition = "Company investment advice refers to guidance of when to buy or sell company stock to generate profits. This is not allowed."
# }
# }
}
resource "aws_bedrock_guardrail" "ue1_guardrail" {
name = "Ue1${title(var.account_short_code)}VeraBotGuardrail"
blocked_input_messaging = "Your input has been blocked by the content filter. Please try again. If this is an error, discuss with the DevOps team."
blocked_outputs_messaging = "The output generated by our system has been blocked by the content filter. Please try again. If this is an error, discuss with the DevOps team."
description = "Vera Guardrail"
content_policy_config {
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "INSULTS"
}
filters_config {
input_strength = "LOW" # Medium strength blocking password reset questions
output_strength = "MEDIUM"
type = "MISCONDUCT"
}
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "SEXUAL"
}
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "VIOLENCE"
}
filters_config {
input_strength = "NONE"
output_strength = "NONE"
type = "PROMPT_ATTACK"
}
filters_config {
input_strength = "MEDIUM"
output_strength = "MEDIUM"
type = "HATE"
}
}
sensitive_information_policy_config {
dynamic "pii_entities_config" {
for_each = local.pii_anonymize_types
content {
action = "ANONYMIZE"
type = pii_entities_config.value
}
}
dynamic "pii_entities_config" {
for_each = local.pii_block_types
content {
action = "BLOCK"
type = pii_entities_config.value
}
}
}
# topic_policy_config {
# topics_config {
# name = "company_investments"
# examples = [
# "When should I buy company stock?",
# ]
# type = "DENY"
# definition = "Company investment advice refers to guidance of when to buy or sell company stock to generate profits. This is not allowed."
# }
# }
}