-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.tf
54 lines (45 loc) · 1.47 KB
/
lambda.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
####################################################
# Lambda Function (building from source)
####################################################
module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"
version = "7.14.0"
function_name = "bedrock-lambda-function-${random_pet.this.id}"
description = "AWS Lambda function to invoke Amazon Bedrock model"
handler = "index.handler"
runtime = "python3.9"
publish = true
timeout = 60
create_lambda_function_url = true
source_path = "${path.module}/src"
environment_variables = {
BEDROCK_KB_ID: awscc_bedrock_knowledge_base.genai-bedrock-kb.knowledge_base_id,
GEN_AI_MODEL_ARN: local.genai_model_arn
}
attach_policies = true
policies = ["arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"]
attach_policy_statements = true
policy_statements = {
invoke_bedrock_model = {
effect = "Allow",
actions = [
"bedrock:InvokeModel"
],
resources = [
local.genai_model_arn
]
},
retrieve_and_generate = {
effect = "Allow",
actions = [
"bedrock:RetrieveAndGenerate",
"bedrock:Retrieve",
],
resources = [
awscc_bedrock_knowledge_base.genai-bedrock-kb.knowledge_base_arn
]
}
}
tags = var.aws_resource_tags
depends_on = [awscc_bedrock_knowledge_base.genai-bedrock-kb]
}