Skip to content

Commit 9c69ea0

Browse files
bnusunnySmoothex
authored andcommitted
feat: Add observability config for Kafka based event sources
1 parent b56d3cb commit 9c69ea0

18 files changed

Lines changed: 1250 additions & 32 deletions

.cfnlintrc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ ignore_templates:
107107
- tests/translator/output/**/function_with_snapstart.json # Snapstart intentionally not attached to a lambda version which causes lint issues
108108
- tests/translator/output/**/managed_policies_everything.json # intentionally contains wrong arns
109109
- tests/translator/output/**/function_with_metrics_config.json
110+
- tests/translator/output/**/function_with_self_managed_kafka_and_schema_registry.json # cfnlint is not updated to recognize the SchemaRegistryConfig property
111+
- tests/translator/output/**/function_with_msk_with_schema_registry_config.json # cfnlint is not updated to recognize the SchemaRegistryConfig property
112+
- tests/translator/output/**/function_with_logging_config.json # cfnlint is not updated to recognize the LoggingConfig property
110113
- tests/translator/output/aws-*/*capacity_provider*.json # Ignore Capacity Provider test format in non-aws partitions
111114

112115
ignore_checks:

samtranslator/internal/schema_source/aws_serverless_function.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,20 @@ class HttpApiEvent(BaseModel):
412412

413413
class MSKEventProperties(BaseModel):
414414
ConsumerGroupId: Optional[PassThroughProp] = mskeventproperties("ConsumerGroupId")
415-
Enabled: Optional[PassThroughProp] # TODO: it doesn't show up in docs yet
415+
Enabled: Optional[PassThroughProp] = mskeventproperties("Enabled")
416416
FilterCriteria: Optional[PassThroughProp] = mskeventproperties("FilterCriteria")
417-
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
417+
KmsKeyArn: Optional[PassThroughProp] = mskeventproperties("KmsKeyArn")
418418
MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = mskeventproperties("MaximumBatchingWindowInSeconds")
419419
StartingPosition: Optional[PassThroughProp] = mskeventproperties("StartingPosition")
420420
StartingPositionTimestamp: Optional[PassThroughProp] = mskeventproperties("StartingPositionTimestamp")
421421
Stream: PassThroughProp = mskeventproperties("Stream")
422422
Topics: PassThroughProp = mskeventproperties("Topics")
423423
SourceAccessConfigurations: Optional[PassThroughProp] = mskeventproperties("SourceAccessConfigurations")
424-
DestinationConfig: Optional[PassThroughProp] # TODO: add documentation
425-
ProvisionedPollerConfig: Optional[PassThroughProp]
426-
SchemaRegistryConfig: Optional[PassThroughProp]
424+
DestinationConfig: Optional[PassThroughProp] = mskeventproperties("DestinationConfig")
425+
ProvisionedPollerConfig: Optional[PassThroughProp] = mskeventproperties("ProvisionedPollerConfig")
426+
SchemaRegistryConfig: Optional[PassThroughProp] = mskeventproperties("SchemaRegistryConfig")
427+
MetricsConfig: Optional[PassThroughProp] = mskeventproperties("MetricsConfig")
428+
LoggingConfig: Optional[PassThroughProp] = mskeventproperties("LoggingConfig")
427429
BisectBatchOnFunctionError: Optional[PassThroughProp] = mskeventproperties("BisectBatchOnFunctionError")
428430
FunctionResponseTypes: Optional[PassThroughProp] = mskeventproperties("FunctionResponseTypes")
429431
MaximumRecordAgeInSeconds: Optional[PassThroughProp] = mskeventproperties("MaximumRecordAgeInSeconds")
@@ -461,13 +463,15 @@ class SelfManagedKafkaEventProperties(BaseModel):
461463
KafkaBootstrapServers: Optional[List[SamIntrinsicable[str]]] = selfmanagedkafkaeventproperties(
462464
"KafkaBootstrapServers"
463465
)
464-
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
466+
KmsKeyArn: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("KmsKeyArn")
465467
SourceAccessConfigurations: PassThroughProp = selfmanagedkafkaeventproperties("SourceAccessConfigurations")
466-
StartingPosition: Optional[PassThroughProp] # TODO: add documentation
467-
StartingPositionTimestamp: Optional[PassThroughProp] # TODO: add documentation
468+
StartingPosition: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("StartingPosition")
469+
StartingPositionTimestamp: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("StartingPositionTimestamp")
468470
Topics: PassThroughProp = selfmanagedkafkaeventproperties("Topics")
469-
ProvisionedPollerConfig: Optional[PassThroughProp]
470-
SchemaRegistryConfig: Optional[PassThroughProp]
471+
MetricsConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("MetricsConfig")
472+
ProvisionedPollerConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("ProvisionedPollerConfig")
473+
SchemaRegistryConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("SchemaRegistryConfig")
474+
LoggingConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("LoggingConfig")
471475
BisectBatchOnFunctionError: Optional[PassThroughProp] = selfmanagedkafkaeventproperties(
472476
"BisectBatchOnFunctionError"
473477
)

samtranslator/internal/schema_source/sam-docs.json

Lines changed: 11 additions & 0 deletions
Large diffs are not rendered by default.

samtranslator/model/eventsources/pull.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class PullEventSource(ResourceMacro, metaclass=ABCMeta):
6161
"ProvisionedPollerConfig": PropertyType(False, IS_DICT),
6262
"SchemaRegistryConfig": PropertyType(False, IS_DICT),
6363
"MetricsConfig": PropertyType(False, IS_DICT),
64+
"LoggingConfig": PropertyType(False, IS_DICT),
6465
}
6566

6667
BatchSize: Optional[Intrinsicable[int]]
@@ -87,6 +88,7 @@ class PullEventSource(ResourceMacro, metaclass=ABCMeta):
8788
ProvisionedPollerConfig: Optional[Dict[str, Any]]
8889
SchemaRegistryConfig: Optional[Dict[str, Any]]
8990
MetricsConfig: Optional[Dict[str, Any]]
91+
LoggingConfig: Optional[Dict[str, Any]]
9092

9193
@abstractmethod
9294
def get_policy_arn(self) -> Optional[str]:
@@ -159,6 +161,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P
159161
lambda_eventsourcemapping.ScalingConfig = self.ScalingConfig
160162
lambda_eventsourcemapping.ProvisionedPollerConfig = self.ProvisionedPollerConfig
161163
lambda_eventsourcemapping.MetricsConfig = self.MetricsConfig
164+
lambda_eventsourcemapping.LoggingConfig = self.LoggingConfig
162165
self._validate_filter_criteria()
163166

164167
if self.KafkaBootstrapServers:

samtranslator/model/lambda_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class LambdaEventSourceMapping(Resource):
135135
"ScalingConfig": GeneratedProperty(),
136136
"ProvisionedPollerConfig": GeneratedProperty(),
137137
"MetricsConfig": GeneratedProperty(),
138+
"LoggingConfig": GeneratedProperty(),
138139
}
139140

140141
runtime_attrs = {"name": lambda self: ref(self.logical_id)}

0 commit comments

Comments
 (0)