@@ -1136,7 +1136,7 @@ data "aws_iam_role" "opensearch" {
11361136
11371137resource "aws_iam_role" "bedrock_kb_role" {
11381138 name = %[1]q
1139-
1139+
11401140 assume_role_policy = jsonencode({
11411141 Version = "2012-10-17"
11421142 Statement = [
@@ -1150,19 +1150,16 @@ resource "aws_iam_role" "bedrock_kb_role" {
11501150 StringEquals = {
11511151 "aws:SourceAccount": data.aws_caller_identity.current.account_id
11521152 },
1153- ArnLike = {
1154- "aws:SourceArn": "arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:knowledge-base/*"
1155- }
11561153 }
11571154 }
11581155 ]
11591156 })
11601157}
11611158
11621159resource "aws_iam_policy" "bedrock_models_access" {
1163- name = "bedrock-%[1]s"
1160+ name. = "bedrock-%[1]s"
11641161 description = "IAM policy for Amazon Bedrock to access embedding models"
1165-
1162+
11661163 policy = jsonencode({
11671164 Version = "2012-10-17"
11681165 Statement = [
@@ -1195,9 +1192,9 @@ resource "aws_iam_policy" "bedrock_models_access" {
11951192}
11961193
11971194resource "aws_iam_policy" "opensearch_access" {
1198- name = "os-%[1]s"
1195+ name = "os-%[1]s"
11991196 description = "IAM policy for Amazon Bedrock to access OpenSearch domain"
1200-
1197+
12011198 policy = jsonencode({
12021199 Version = "2012-10-17"
12031200 Statement = [
@@ -1217,7 +1214,7 @@ resource "aws_iam_policy" "opensearch_access" {
12171214 Effect = "Allow"
12181215 Action = [
12191216 "es:DescribeDomain",
1220- "es:DescribeElasticsearchDomain"
1217+ "es:DescribeElasticsearchDomain"
12211218 ]
12221219 Resource = [
12231220 "*"
@@ -1253,7 +1250,7 @@ resource "random_password" "opensearch_master" {
12531250}
12541251
12551252resource "aws_opensearch_domain" "knowledge_base" {
1256- domain_name = substr(%[1]q, 0, 28)
1253+ domain_name = substr(%[1]q, 0, 28)
12571254 engine_version = "OpenSearch_3.1"
12581255 access_policies = local.opensearch_access_policy
12591256
@@ -1291,6 +1288,7 @@ resource "aws_opensearch_domain" "knowledge_base" {
12911288 advanced_security_options {
12921289 enabled = true
12931290 internal_user_database_enabled = true
1291+
12941292 master_user_options {
12951293 master_user_name = "admin"
12961294 master_user_password = random_password.opensearch_master.result
@@ -1372,7 +1370,7 @@ resource "opensearch_index" "vector_index" {
13721370 number_of_shards = "5"
13731371 number_of_replicas = "1"
13741372 index_knn = true
1375-
1373+
13761374 # Mappings for Bedrock Knowledge Base compatibility
13771375 mappings = jsonencode({
13781376 "properties": {
0 commit comments