Skip to content

Commit c4418fb

Browse files
authored
Merge pull request #51 from scribd/kinesis_not_supported
feat! Kinesis no more supported
2 parents 43e6444 + b173b40 commit c4418fb

File tree

5 files changed

+24
-177
lines changed

5 files changed

+24
-177
lines changed

README.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22
*Terraform module to manage oxbow Lambda and its components.
33
We can have the following components in AWS:
44
1. Lambda
5-
2. Kinesis Data Firehose
6-
3. SQS
7-
4. SQS dead letters
8-
5. IAM policy
9-
6. S3 bucket notifications
10-
7. Dynamo DB table
11-
8. Glue catalog
12-
9. Glue table
5+
2. SQS
6+
3. SQS dead letters
7+
4. IAM policy
8+
5. S3 bucket notifications
9+
6. Dynamo DB table
10+
7. Glue catalog
11+
8. Glue table
1312

1413
### examples:
1514
if we need Glue catalog and table
1615
```
1716
enable_aws_glue_catalog_table = true
18-
```
19-
if we need Kinesis Data Firehose delivery stream
20-
```
21-
enable_kinesis_firehose_delivery_stream = true
17+
2218
```
2319
if we need s3 bucket notification
2420
```
@@ -35,7 +31,6 @@ module "terraform-oxbow" {
3531
source = ""
3632
3733
enable_aws_glue_catalog_table = true
38-
enable_kinesis_firehose_delivery_stream = true
3934
enable_bucket_notification = false
4035
4136
@@ -46,8 +41,6 @@ module "terraform-oxbow" {
4641
4742
# the place where we store files
4843
s3_path = ""
49-
50-
lambda_kinesis_role_name = ""
5144
lambda_function_name = ""
5245
lambda_description = ""
5346
lambda_s3_key = ""
@@ -60,20 +53,10 @@ module "terraform-oxbow" {
6053
sqs_queue_name = "${var.env}--queue"
6154
sqs_queue_name_dl = "${var.env}--queue-dl"
6255
dynamodb_table_name = "${var.env}-oxbow-lock"
63-
64-
kinesis_delivery_stream_name = ""
65-
kinesis_s3_prefix = ""
66-
kinesis_s3_errors_prefix = ""
67-
kinesis_policy_name = ""
68-
kinesis_policy_description = ""
69-
70-
# We have dedicated service Database for Kinesis file conversions
7156
glue_database_name = ""
7257
glue_table_name = ""
7358
glue_location_uri = ""
7459
glue_table_description = ""
75-
# this schema is required by Kinesis to convert input into Parquet
76-
parquet_schema = ["parquet_schema]
7760
aws_s3_locking_provider = "dynamodb"
7861
7962
enabled_dead_letters_monitoring = true

autotagging.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ data "aws_iam_policy_document" "auto_tagging_assume_role" {
164164
resource "aws_iam_role" "auto_tagging_lambda" {
165165
count = var.enable_auto_tagging == true ? 1 : 0
166166

167-
name = "${var.lambda_kinesis_role_name}-auto_tagging"
167+
name = "${var.oxbow_lambda_role_name}-auto_tagging"
168168
assume_role_policy = data.aws_iam_policy_document.auto_tagging_assume_role[0].json
169169
managed_policy_arns = [aws_iam_policy.auto_tagging_lambda[0].arn]
170170

main.tf

Lines changed: 12 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
# This module creates Kinesis Firehose service (optionally), SQS, lambda function OXBOW
1+
# This module creates SQS, lambda function OXBOW
22
# to receive data and convert it into parquet then Delta log is added by Oxbow lambda
33
data "aws_caller_identity" "current" {}
44
data "aws_region" "current" {}
55

66
locals {
7-
enable_aws_glue_catalog_table = var.enable_aws_glue_catalog_table
8-
enable_kinesis_firehose_delivery_stream = var.enable_kinesis_firehose_delivery_stream
9-
enable_bucket_notification = var.enable_bucket_notification
10-
enable_group_events = var.enable_group_events
7+
enable_aws_glue_catalog_table = var.enable_aws_glue_catalog_table
8+
enable_bucket_notification = var.enable_bucket_notification
9+
enable_group_events = var.enable_group_events
1110
}
1211

1312

@@ -41,43 +40,6 @@ resource "aws_glue_catalog_table" "this_glue_table" {
4140
}
4241
}
4342

44-
resource "aws_kinesis_firehose_delivery_stream" "this_kinesis" {
45-
count = local.enable_kinesis_firehose_delivery_stream ? 1 : 0
46-
name = var.kinesis_delivery_stream_name
47-
destination = "extended_s3"
48-
extended_s3_configuration {
49-
buffering_size = 128
50-
role_arn = aws_iam_role.this_iam_role_lambda_kinesis.arn
51-
bucket_arn = var.warehouse_bucket_arn
52-
error_output_prefix = var.kinesis_s3_errors_prefix
53-
prefix = var.kinesis_s3_prefix
54-
55-
cloudwatch_logging_options {
56-
enabled = true
57-
log_group_name = "/aws/kinesisfirehose/${var.kinesis_delivery_stream_name}"
58-
log_stream_name = "DestinationDelivery"
59-
}
60-
data_format_conversion_configuration {
61-
input_format_configuration {
62-
deserializer {
63-
open_x_json_ser_de {}
64-
}
65-
}
66-
output_format_configuration {
67-
serializer {
68-
parquet_ser_de {}
69-
}
70-
}
71-
schema_configuration {
72-
database_name = var.glue_database_name
73-
role_arn = aws_iam_role.this_iam_role_lambda_kinesis.arn
74-
table_name = var.glue_table_name
75-
region = "us-east-2"
76-
}
77-
}
78-
}
79-
tags = var.tags
80-
}
8143
locals {
8244
oxbow_lambda_unwrap_sns_event = var.enable_group_events == true ? {} : var.sns_topic_arn == "" ? {} : { UNWRAP_SNS_ENVELOPE = true }
8345
group_eventlambda_unwrap_sns_event = var.sns_topic_arn == "" ? {} : { UNWRAP_SNS_ENVELOPE = true }
@@ -91,7 +53,7 @@ resource "aws_lambda_function" "this_lambda" {
9153
s3_key = var.lambda_s3_key
9254
s3_bucket = var.lambda_s3_bucket
9355
function_name = var.lambda_function_name
94-
role = aws_iam_role.this_iam_role_lambda_kinesis.arn
56+
role = aws_iam_role.oxbow_lambda_role.arn
9557
handler = "provided"
9658
runtime = "provided.al2023"
9759
memory_size = var.lambda_memory_size
@@ -119,7 +81,7 @@ resource "aws_lambda_function" "group_events_lambda" {
11981
s3_key = var.events_lambda_s3_key
12082
s3_bucket = var.events_lambda_s3_bucket
12183
function_name = var.events_lambda_function_name
122-
role = aws_iam_role.this_iam_role_lambda_kinesis.arn
84+
role = aws_iam_role.oxbow_lambda_role.arn
12385
handler = "provided"
12486
runtime = "provided.al2023"
12587

@@ -328,11 +290,8 @@ data "aws_iam_policy_document" "this_services_assume_role" {
328290
statement {
329291
effect = "Allow"
330292
principals {
331-
type = "Service"
332-
identifiers = concat(
333-
["lambda.amazonaws.com"],
334-
local.enable_kinesis_firehose_delivery_stream ? ["firehose.amazonaws.com"] : []
335-
)
293+
type = "Service"
294+
identifiers = ["lambda.amazonaws.com"]
336295
}
337296
actions = [
338297
"sts:AssumeRole",
@@ -462,67 +421,11 @@ data "aws_iam_policy_document" "this_dead_letter_queue_policy" {
462421
}
463422
}
464423

424+
resource "aws_iam_role" "oxbow_lambda_role" {
425+
name = var.oxbow_lambda_role_name
426+
assume_role_policy = data.aws_iam_policy_document.this_services_assume_role.json
427+
managed_policy_arns = [aws_iam_policy.this_lambda_permissions.arn]
465428

466-
data "aws_iam_policy_document" "this_kinesis_policy_data" {
467-
count = local.enable_kinesis_firehose_delivery_stream ? 1 : 0
468-
statement {
469-
sid = "GlueAccess"
470-
effect = "Allow"
471-
actions = [
472-
"glue:GetTable",
473-
"glue:GetTableVersion",
474-
"glue:GetTableVersions",
475-
]
476-
resources = [
477-
"arn:aws:glue:us-east-2:${data.aws_caller_identity.current.account_id}:catalog",
478-
"arn:aws:glue:us-east-2:${data.aws_caller_identity.current.account_id}:database/${var.glue_database_name}",
479-
"arn:aws:glue:us-east-2:${data.aws_caller_identity.current.account_id}:table/${var.glue_database_name}/${var.glue_table_name}"
480-
]
481-
}
482-
statement {
483-
sid = "S3Access"
484-
effect = "Allow"
485-
actions = [
486-
"s3:AbortMultipartUpload",
487-
"s3:GetBucketLocation",
488-
"s3:GetObject",
489-
"s3:ListBucket",
490-
"s3:ListBucketMultipartUploads",
491-
"s3:PutObject"
492-
]
493-
resources = [
494-
"${var.warehouse_bucket_arn}/${var.s3_path}",
495-
"${var.warehouse_bucket_arn}/${var.s3_path}/*"
496-
]
497-
}
498-
statement {
499-
sid = "LogsAccess"
500-
effect = "Allow"
501-
actions = [
502-
"logs:PutLogEvents"
503-
]
504-
resources = [
505-
"arn:aws:logs:us-east-2:${data.aws_caller_identity.current.account_id}:log-group:/aws/kinesisfirehose/${var.kinesis_delivery_stream_name}:log-stream:*"
506-
]
507-
}
508-
}
509-
510-
resource "aws_iam_policy" "this_kinesis_policy" {
511-
count = local.enable_kinesis_firehose_delivery_stream ? 1 : 0
512-
name = var.kinesis_policy_name
513-
description = var.kinesis_policy_description
514-
policy = data.aws_iam_policy_document.this_kinesis_policy_data[0].json
515-
tags = var.tags
516-
}
517-
518-
519-
resource "aws_iam_role" "this_iam_role_lambda_kinesis" {
520-
name = var.lambda_kinesis_role_name
521-
assume_role_policy = data.aws_iam_policy_document.this_services_assume_role.json
522-
managed_policy_arns = concat(
523-
local.enable_kinesis_firehose_delivery_stream ? [aws_iam_policy.this_kinesis_policy[0].arn] : [],
524-
[aws_iam_policy.this_lambda_permissions.arn]
525-
)
526429
tags = var.tags
527430
}
528431

outputs.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
output "kinesis_stream_arn" {
2-
description = "Kinesis stream arn"
3-
value = local.enable_kinesis_firehose_delivery_stream ? aws_kinesis_firehose_delivery_stream.this_kinesis[0].arn : ""
4-
}
1+
52

63
output "lambda_arn" {
74
description = "Lambda arn"

variables.tf

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ variable "parquet_schema" {
2828
default = []
2929
}
3030

31-
variable "kinesis_s3_prefix" {
32-
default = ""
33-
type = string
34-
description = "Kinesis s3 prefix - s3 location where the files will be output"
35-
}
36-
37-
variable "kinesis_delivery_stream_name" {
38-
type = string
39-
default = ""
40-
description = "Kinesis delivery stream name"
41-
}
42-
4331
variable "warehouse_bucket_arn" {
4432
type = string
4533
description = "Warehouse bucket arn"
@@ -50,12 +38,6 @@ variable "warehouse_bucket_name" {
5038
description = "Warehouse bucket name"
5139
}
5240

53-
variable "kinesis_s3_errors_prefix" {
54-
type = string
55-
default = ""
56-
description = "Kinesiss3 errors prefix - s3 location where the files will be output"
57-
}
58-
5941
variable "lambda_function_name" {
6042
type = string
6143
description = "Lambda function name"
@@ -130,18 +112,6 @@ variable "lambda_reserved_concurrent_executions" {
130112
default = 1
131113
}
132114

133-
variable "kinesis_policy_name" {
134-
type = string
135-
default = ""
136-
description = "Kinesis policy name"
137-
}
138-
139-
variable "kinesis_policy_description" {
140-
type = string
141-
description = "Kinesis policy description"
142-
default = ""
143-
}
144-
145115
variable "rust_log_deltalake_debug_level" {
146116
type = string
147117
description = "Rust log deltalake debug level"
@@ -221,9 +191,9 @@ variable "sqs_queue_name_dl" {
221191
description = "Sqs queue name - dead letters"
222192
}
223193

224-
variable "lambda_kinesis_role_name" {
194+
variable "oxbow_lambda_role_name" {
225195
type = string
226-
description = "Lambda kinesis IAM role name"
196+
description = "Lambda oxbow IAM role name"
227197
}
228198

229199
variable "tags" {
@@ -283,12 +253,6 @@ variable "enable_aws_glue_catalog_table" {
283253
default = false
284254
}
285255

286-
variable "enable_kinesis_firehose_delivery_stream" {
287-
type = bool
288-
description = "Enable firehose delivery stream"
289-
default = false
290-
}
291-
292256
variable "enable_bucket_notification" {
293257
type = bool
294258
description = "Enable enable_bucket_notification"

0 commit comments

Comments
 (0)