Skip to content

Commit ee41186

Browse files
authored
feat: Added support for self managed kafka in event source mapping (#278)
1 parent 638485b commit ee41186

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

examples/complete/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Note that this example may create resources which cost money. Run `terraform des
5454
|------|------|
5555
| [aws_sqs_queue.dlq](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
5656
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
57+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
5758

5859
## Inputs
5960

examples/event-source-mapping/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@ module "lambda_function" {
6363
}
6464
]
6565
}
66+
# self_managed_kafka = {
67+
# batch_size = 1
68+
# starting_position = "TRIM_HORIZON"
69+
# topics = ["topic1", "topic2"]
70+
# self_managed_event_source = [
71+
# {
72+
# endpoints = {
73+
# KAFKA_BOOTSTRAP_SERVERS = "kafka1.example.com:9092,kafka2.example.com:9092"
74+
# }
75+
# }
76+
# ]
77+
# source_access_configuration = [
78+
# {
79+
# type = "SASL_SCRAM_512_AUTH",
80+
# uri = "SECRET_AUTH_INFO"
81+
# },
82+
# {
83+
# type = "VPC_SECURITY_GROUP",
84+
# uri = "security_group:sg-12345678"
85+
# },
86+
# {
87+
# type = "VPC_SUBNET"
88+
# uri = "subnet:subnet-12345678"
89+
# }
90+
# ]
91+
# }
6692
}
6793

6894
allowed_triggers = {

main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ resource "aws_lambda_event_source_mapping" "this" {
231231

232232
function_name = aws_lambda_function.this[0].arn
233233

234-
event_source_arn = each.value.event_source_arn
234+
event_source_arn = try(each.value.event_source_arn, null)
235235

236236
batch_size = try(each.value.batch_size, null)
237237
maximum_batching_window_in_seconds = try(each.value.maximum_batching_window_in_seconds, null)
@@ -255,6 +255,13 @@ resource "aws_lambda_event_source_mapping" "this" {
255255
}
256256
}
257257

258+
dynamic "self_managed_event_source" {
259+
for_each = try(each.value.self_managed_event_source, [])
260+
content {
261+
endpoints = self_managed_event_source.value.endpoints
262+
}
263+
}
264+
258265
dynamic "source_access_configuration" {
259266
for_each = try(each.value.source_access_configuration, [])
260267
content {

0 commit comments

Comments
 (0)