-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_indexer.tf
More file actions
38 lines (34 loc) · 1.17 KB
/
Copy pathlambda_indexer.tf
File metadata and controls
38 lines (34 loc) · 1.17 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
resource "aws_s3_bucket" "docstorage_chatoverflow" {
bucket = "docstorage-chatoverflow"
}
resource "aws_lambda_function" "indexer" {
function_name = "chat-overflow-indexer"
runtime = "python3.8"
role = aws_iam_role.indexer_role.arn
handler = "indexer.lambda_handler"
timeout = 15
environment {
variables = {
"ES_ENDPOINT" = "search-chat-overflow-zggssnarczx4oyczzt5h4og4bi.ap-southeast-2.es.amazonaws.com"
"ES_INDEX" = "chat_gpt"
}
}
filename = "lambda/indexer/indexer.zip"
source_code_hash = filebase64sha256("lambda/indexer/indexer.zip")
}
resource "aws_lambda_permission" "s3_permission" {
statement_id = "AllowExecutionFromS3"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.indexer.function_name
principal = "s3.amazonaws.com"
source_arn = aws_s3_bucket.docstorage_chatoverflow.arn
}
resource "aws_s3_bucket_notification" "docstorage_chatoverflow" {
bucket = aws_s3_bucket.docstorage_chatoverflow.id
lambda_function {
lambda_function_arn = aws_lambda_function.indexer.arn
events = ["s3:ObjectCreated:*"]
filter_prefix = "documents/"
filter_suffix = ".txt"
}
}