-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support for self managed kafka as an event source (#2091)
- Loading branch information
Showing
38 changed files
with
2,367 additions
and
14 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
integration/combination/test_function_with_self_managed_kafka.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from integration.helpers.base_test import BaseTest | ||
from parameterized import parameterized | ||
|
||
|
||
class TestFunctionWithSelfManagedKafka(BaseTest): | ||
@parameterized.expand( | ||
[ | ||
"combination/function_with_self_managed_kafka", | ||
"combination/function_with_self_managed_kafka_intrinsics", | ||
] | ||
) | ||
def test_function_with_self_managed_kafka(self, file_name): | ||
self.create_and_verify_stack(file_name) | ||
# Get the notification configuration and make sure Lambda Function connection is added | ||
lambda_client = self.client_provider.lambda_client | ||
function_name = self.get_physical_id_by_type("AWS::Lambda::Function") | ||
lambda_function_arn = lambda_client.get_function_configuration(FunctionName=function_name)["FunctionArn"] | ||
event_source_mapping_id = self.get_physical_id_by_type("AWS::Lambda::EventSourceMapping") | ||
event_source_mapping_result = lambda_client.get_event_source_mapping(UUID=event_source_mapping_id) | ||
event_source_mapping_function_arn = event_source_mapping_result["FunctionArn"] | ||
self.assertEqual(event_source_mapping_function_arn, lambda_function_arn) |
18 changes: 18 additions & 0 deletions
18
integration/resources/expected/combination/function_with_self_managed_kafka.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"LogicalResourceId": "KafkaFunction", | ||
"ResourceType": "AWS::Lambda::Function" | ||
}, | ||
{ | ||
"LogicalResourceId": "KafkaFunctionMyKafkaCluster", | ||
"ResourceType": "AWS::Lambda::EventSourceMapping" | ||
}, | ||
{ | ||
"LogicalResourceId": "KafkaFunctionRole", | ||
"ResourceType": "AWS::IAM::Role" | ||
}, | ||
{ | ||
"LogicalResourceId": "KafkaUserSecret", | ||
"ResourceType": "AWS::SecretsManager::Secret" | ||
} | ||
] |
18 changes: 18 additions & 0 deletions
18
integration/resources/expected/combination/function_with_self_managed_kafka_intrinsics.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"LogicalResourceId": "KafkaFunctionWithIntrinsics", | ||
"ResourceType": "AWS::Lambda::Function" | ||
}, | ||
{ | ||
"LogicalResourceId": "KafkaFunctionWithIntrinsicsMyKafkaClusterWithIntrinsics", | ||
"ResourceType": "AWS::Lambda::EventSourceMapping" | ||
}, | ||
{ | ||
"LogicalResourceId": "KafkaFunctionWithIntrinsicsRole", | ||
"ResourceType": "AWS::IAM::Role" | ||
}, | ||
{ | ||
"LogicalResourceId": "KafkaUserSecret", | ||
"ResourceType": "AWS::SecretsManager::Secret" | ||
} | ||
] |
29 changes: 29 additions & 0 deletions
29
integration/resources/templates/combination/function_with_self_managed_kafka.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Resources: | ||
KafkaFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: index.handler | ||
Runtime: nodejs12.x | ||
CodeUri: ${codeuri} | ||
MemorySize: 128 | ||
Events: | ||
MyKafkaCluster: | ||
Type: SelfManagedKafka | ||
Properties: | ||
KafkaBootstrapServers: | ||
- abc.xyz.com:9092 | ||
- 123.45.67.89:9096 | ||
Topics: | ||
- Topic1 | ||
SourceAccessConfigurations: | ||
- Type: BASIC_AUTH | ||
URI: | ||
Ref: KafkaUserSecret | ||
|
||
KafkaUserSecret: | ||
Type: AWS::SecretsManager::Secret | ||
Properties: | ||
Name: KafkaUserPassword | ||
SecretString: | ||
Fn::Sub: '{"username":"testBrokerUser","password":"testBrokerPassword"}' | ||
|
37 changes: 37 additions & 0 deletions
37
integration/resources/templates/combination/function_with_self_managed_kafka_intrinsics.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Parameters: | ||
TopicsValue: | ||
Type: CommaDelimitedList | ||
Default: Topic | ||
|
||
KafkaBootstrapServersValue: | ||
Type: String | ||
Default: abc.xyz.com:9092 | ||
|
||
Resources: | ||
KafkaFunctionWithIntrinsics: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: index.handler | ||
Runtime: nodejs12.x | ||
CodeUri: ${codeuri} | ||
MemorySize: 128 | ||
Events: | ||
MyKafkaClusterWithIntrinsics: | ||
Type: SelfManagedKafka | ||
Properties: | ||
KafkaBootstrapServers: | ||
- Ref: KafkaBootstrapServersValue | ||
Topics: | ||
Ref: TopicsValue | ||
SourceAccessConfigurations: | ||
- Type: BASIC_AUTH | ||
URI: | ||
Ref: KafkaUserSecret | ||
|
||
KafkaUserSecret: | ||
Type: AWS::SecretsManager::Secret | ||
Properties: | ||
Name: KafkaUserPassword | ||
SecretString: | ||
Fn::Sub: '{"username":"testBrokerUserWithInstrinsic","password":"testBrokerPasswordWithInstrinsic"}' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.