Skip to content

Commit

Permalink
Merge branch 'main' of github.com:aws-samples/aws-genai-llm-chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
spugachev committed Oct 9, 2023
2 parents 0d2f681 + 9006de2 commit 6a09dbf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
25 changes: 17 additions & 8 deletions lib/chatbot-api/rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,23 @@ export class RestApi extends Construct {
}

for (const item of props.config.rag.engines.kendra.external || []) {
if (!item.roleArn) continue;

apiHandler.addToRolePolicy(
new iam.PolicyStatement({
actions: ["sts:AssumeRole"],
resources: [item.roleArn],
})
);
if (item.roleArn) {
apiHandler.addToRolePolicy(
new iam.PolicyStatement({
actions: ["sts:AssumeRole"],
resources: [item.roleArn],
})
);
} else {
apiHandler.addToRolePolicy(
new iam.PolicyStatement({
actions: ["kendra:Retrieve", "kendra:Query"],
resources: [
`arn:aws:kendra:${item.region}:${cdk.Aws.ACCOUNT_ID}:index/${item.kendraId}`,
],
})
);
}
}
}

Expand Down
25 changes: 17 additions & 8 deletions lib/model-interfaces/langchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,23 @@ export class LangChainInterface extends Construct {
}

for (const item of props.config.rag.engines.kendra.external || []) {
if (!item.roleArn) continue;

requestHandler.addToRolePolicy(
new iam.PolicyStatement({
actions: ["sts:AssumeRole"],
resources: [item.roleArn],
})
);
if (item.roleArn) {
requestHandler.addToRolePolicy(
new iam.PolicyStatement({
actions: ["sts:AssumeRole"],
resources: [item.roleArn],
})
);
} else {
requestHandler.addToRolePolicy(
new iam.PolicyStatement({
actions: ["kendra:Retrieve", "kendra:Query"],
resources: [
`arn:aws:kendra:${item.region}:${cdk.Aws.ACCOUNT_ID}:index/${item.kendraId}`,
],
})
);
}
}
}

Expand Down

0 comments on commit 6a09dbf

Please sign in to comment.