-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
39 lines (33 loc) · 1.07 KB
/
main.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
data "archive_file" "lambda_zip" {
type = "zip"
source_dir = "${path.module}/lambda"
output_path = "lambda.zip"
}
data "aws_caller_identity" "source" {}
data "aws_caller_identity" "sink" {
provider = aws.sink
}
resource "aws_lambda_function" "sync_lambda" {
function_name = "${var.service_name}-kinesis-cross-account-sync-lambda"
handler = "index.handler"
filename = "lambda.zip"
role = aws_iam_role.lambda_execution_role.arn
runtime = "nodejs12.x"
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
environment {
variables = {
KINESIS_ASSUMED_ROLE = aws_iam_role.assume_lambda_role.arn,
STREAMS = var.sink_streams
}
}
}
data "aws_kinesis_stream" "source" {
name = var.source_stream
}
resource "aws_lambda_event_source_mapping" "kinesis_lambda_event_mapping" {
batch_size = 100
event_source_arn = data.aws_kinesis_stream.source.arn
enabled = true
function_name = aws_lambda_function.sync_lambda.arn
starting_position = "TRIM_HORIZON"
}