-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamodb_streams_lambda.tf
32 lines (27 loc) · 1.07 KB
/
dynamodb_streams_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
resource "aws_iam_role" "iam_for_lambda3" {
name = "iam_for_lambda3"
assume_role_policy = file("assume_role_policy.json")
}
resource "aws_iam_role_policy" "lambda_policy3" {
name = "lambda_policy"
role = aws_iam_role.iam_for_lambda3.id
policy = templatefile("lambda_policy3.tpl", {
pricesTableStreamArn = aws_dynamodb_table.stock_prices.stream_arn
sqsQueueArn = aws_sqs_queue.sqs_queue.arn
})
}
resource "aws_lambda_function" "prices_processor" {
function_name = "prices_processor"
filename = "./stock_prices_processor_lambda/prices_processor.zip"
source_code_hash = filebase64sha256("./stock_prices_processor_lambda/prices_processor.zip")
role = aws_iam_role.iam_for_lambda3.arn
handler = "stock_prices_processor.lambda_handler"
runtime = "python3.8"
reserved_concurrent_executions = 2
timeout = 3
}
resource "aws_lambda_event_source_mapping" "mapping" {
event_source_arn = aws_dynamodb_table.stock_prices.stream_arn
function_name = aws_lambda_function.prices_processor.arn
starting_position = "LATEST"
}