diff --git a/.cfnlintrc.yaml b/.cfnlintrc.yaml index 5eee5ce53..560779164 100644 --- a/.cfnlintrc.yaml +++ b/.cfnlintrc.yaml @@ -107,6 +107,9 @@ ignore_templates: - tests/translator/output/**/function_with_snapstart.json # Snapstart intentionally not attached to a lambda version which causes lint issues - tests/translator/output/**/managed_policies_everything.json # intentionally contains wrong arns - tests/translator/output/**/function_with_metrics_config.json + - tests/translator/output/**/function_with_self_managed_kafka_and_schema_registry.json # cfnlint is not updated to recognize the SchemaRegistryConfig property + - tests/translator/output/**/function_with_msk_with_schema_registry_config.json # cfnlint is not updated to recognize the SchemaRegistryConfig property + - tests/translator/output/**/function_with_logging_config.json # cfnlint is not updated to recognize the LoggingConfig property - tests/translator/output/aws-*/*capacity_provider*.json # Ignore Capacity Provider test format in non-aws partitions ignore_checks: diff --git a/samtranslator/__init__.py b/samtranslator/__init__.py index ecac91a49..bf025ed9a 100644 --- a/samtranslator/__init__.py +++ b/samtranslator/__init__.py @@ -1 +1 @@ -__version__ = "1.106.0" +__version__ = "1.107.0" diff --git a/samtranslator/internal/schema_source/aws_serverless_function.py b/samtranslator/internal/schema_source/aws_serverless_function.py index 1ff13cb87..46b3ec4bd 100644 --- a/samtranslator/internal/schema_source/aws_serverless_function.py +++ b/samtranslator/internal/schema_source/aws_serverless_function.py @@ -412,18 +412,20 @@ class HttpApiEvent(BaseModel): class MSKEventProperties(BaseModel): ConsumerGroupId: Optional[PassThroughProp] = mskeventproperties("ConsumerGroupId") - Enabled: Optional[PassThroughProp] # TODO: it doesn't show up in docs yet + Enabled: Optional[PassThroughProp] = mskeventproperties("Enabled") FilterCriteria: Optional[PassThroughProp] = mskeventproperties("FilterCriteria") - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation + KmsKeyArn: Optional[PassThroughProp] = mskeventproperties("KmsKeyArn") MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = mskeventproperties("MaximumBatchingWindowInSeconds") StartingPosition: Optional[PassThroughProp] = mskeventproperties("StartingPosition") StartingPositionTimestamp: Optional[PassThroughProp] = mskeventproperties("StartingPositionTimestamp") Stream: PassThroughProp = mskeventproperties("Stream") Topics: PassThroughProp = mskeventproperties("Topics") SourceAccessConfigurations: Optional[PassThroughProp] = mskeventproperties("SourceAccessConfigurations") - DestinationConfig: Optional[PassThroughProp] # TODO: add documentation - ProvisionedPollerConfig: Optional[PassThroughProp] - SchemaRegistryConfig: Optional[PassThroughProp] + DestinationConfig: Optional[PassThroughProp] = mskeventproperties("DestinationConfig") + ProvisionedPollerConfig: Optional[PassThroughProp] = mskeventproperties("ProvisionedPollerConfig") + SchemaRegistryConfig: Optional[PassThroughProp] = mskeventproperties("SchemaRegistryConfig") + MetricsConfig: Optional[PassThroughProp] = mskeventproperties("MetricsConfig") + LoggingConfig: Optional[PassThroughProp] = mskeventproperties("LoggingConfig") BisectBatchOnFunctionError: Optional[PassThroughProp] = mskeventproperties("BisectBatchOnFunctionError") FunctionResponseTypes: Optional[PassThroughProp] = mskeventproperties("FunctionResponseTypes") MaximumRecordAgeInSeconds: Optional[PassThroughProp] = mskeventproperties("MaximumRecordAgeInSeconds") @@ -461,13 +463,15 @@ class SelfManagedKafkaEventProperties(BaseModel): KafkaBootstrapServers: Optional[List[SamIntrinsicable[str]]] = selfmanagedkafkaeventproperties( "KafkaBootstrapServers" ) - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation + KmsKeyArn: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("KmsKeyArn") SourceAccessConfigurations: PassThroughProp = selfmanagedkafkaeventproperties("SourceAccessConfigurations") - StartingPosition: Optional[PassThroughProp] # TODO: add documentation - StartingPositionTimestamp: Optional[PassThroughProp] # TODO: add documentation + StartingPosition: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("StartingPosition") + StartingPositionTimestamp: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("StartingPositionTimestamp") Topics: PassThroughProp = selfmanagedkafkaeventproperties("Topics") - ProvisionedPollerConfig: Optional[PassThroughProp] - SchemaRegistryConfig: Optional[PassThroughProp] + MetricsConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("MetricsConfig") + ProvisionedPollerConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("ProvisionedPollerConfig") + SchemaRegistryConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("SchemaRegistryConfig") + LoggingConfig: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("LoggingConfig") BisectBatchOnFunctionError: Optional[PassThroughProp] = selfmanagedkafkaeventproperties( "BisectBatchOnFunctionError" ) diff --git a/samtranslator/internal/schema_source/sam-docs.json b/samtranslator/internal/schema_source/sam-docs.json index 8e6bf5365..98eeb87c6 100644 --- a/samtranslator/internal/schema_source/sam-docs.json +++ b/samtranslator/internal/schema_source/sam-docs.json @@ -321,12 +321,18 @@ "ConsumerGroupId": "A string that configures how events will be read from Kafka topics\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`AmazonManagedKafkaConfiguration`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "DestinationConfig": "A configuration object that specifies the destination of an event after Lambda processes it\\. \nUse this property to specify the destination of failed invocations from the Amazon MSK event source\\. \n*Type*: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)` property of an `AWS::Lambda::EventSourceMapping` resource\\.", "FilterCriteria": "A object that defines the criteria that determines whether Lambda should process an event\\. For more information, see [AWS Lambda event filtering](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) in the *AWS Lambda Developer Guide*\\. \n*Type*: [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FilterCriteria`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "Enabled": "Disables the event source mapping to pause polling and invocation\\. \n*Type*: Boolean \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Enabled`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "MaximumBatchingWindowInSeconds": "The maximum amount of time to gather records before invoking the function, in seconds\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumBatchingWindowInSeconds`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "SourceAccessConfigurations": "An array of the authentication protocol, VPC components, or virtual host to secure and define your event source\\. \n*Valid values*: `CLIENT_CERTIFICATE_TLS_AUTH` \n*Type*: List of [SourceAccessConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SourceAccessConfigurations`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "StartingPosition": "The position in a stream from which to start reading\\. \n+ `AT_TIMESTAMP` \u2013 Specify a time from which to start reading records\\.\n+ `LATEST` \u2013 Read only new records\\.\n+ `TRIM_HORIZON` \u2013 Process all available records\\.\n*Valid values*: `AT_TIMESTAMP` \\| `LATEST` \\| `TRIM_HORIZON` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPosition`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "StartingPositionTimestamp": "The time from which to start reading, in Unix time seconds\\. Define `StartingPositionTimestamp` when `StartingPosition` is specified as `AT_TIMESTAMP`\\. \n*Type*: Double \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPositionTimestamp`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "Stream": "The Amazon Resource Name \\(ARN\\) of the data stream or a stream consumer\\. \n*Type*: String \n*Required*: Yes \n*AWS CloudFormation compatibility*: This property is passed directly to the [`EventSourceArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "Topics": "The name of the Kafka topic\\. \n*Type*: List \n*Required*: Yes \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Topics`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-topics) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "KmsKeyArn": "The ARN of the AWS Key Management Service \\(AWS KMS\\) customer managed key to use for encryption\\. Only the key ID or key ARN is supported\\. The key alias is not supported\\. If you don't specify a customer managed key, Lambda uses an AWS owned key for encryption\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`KMSKeyArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "LoggingConfig": "A configuration object that specifies the logging configuration for the event source mapping\\. \n*Type*: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`LoggingConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "MetricsConfig": "A configuration object that specifies the metrics configuration for the event source mapping\\. \n*Type*: [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MetricsConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "ProvisionedPollerConfig": "A configuration object that specifies the provisioned poller configuration for the event source mapping\\. \n*Type*: [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`ProvisionedPollerConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "SchemaRegistryConfig": "A configuration object that specifies the schema registry configuration for the event source mapping\\. \n*Type*: [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SchemaRegistryConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "BisectBatchOnFunctionError": "If the function returns an error, split the batch in two and retry\\. \n*Type*: Boolean \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`BisectBatchOnFunctionError`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "FunctionResponseTypes": "A list of the response types currently applied to the event source mapping\\. For more information, see [Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n*Valid values*: `ReportBatchItemFailures` \n*Type*: List \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "MaximumRecordAgeInSeconds": "The maximum age of a record that Lambda sends to a function for processing\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumRecordAgeInSeconds`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds) property of an `AWS::Lambda::EventSourceMapping` resource\\.", @@ -412,6 +418,11 @@ "StartingPosition": "The position in a stream from which to start reading\\. \n+ `AT_TIMESTAMP` \u2013 Specify a time from which to start reading records\\.\n+ `LATEST` \u2013 Read only new records\\.\n+ `TRIM_HORIZON` \u2013 Process all available records\\.\n*Valid values*: `AT_TIMESTAMP` \\| `LATEST` \\| `TRIM_HORIZON` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPosition`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "StartingPositionTimestamp": "The time from which to start reading, in Unix time seconds\\. Define `StartingPositionTimestamp` when `StartingPosition` is specified as `AT_TIMESTAMP`\\. \n*Type*: Double \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPositionTimestamp`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "Topics": "The name of the Kafka topic\\. \n*Type*: List \n*Required*: Yes \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Topics`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-topics) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "KmsKeyArn": "The ARN of the AWS Key Management Service \\(AWS KMS\\) customer managed key to use for encryption\\. Only the key ID or key ARN is supported\\. The key alias is not supported\\. If you don't specify a customer managed key, Lambda uses an AWS owned key for encryption\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`KMSKeyArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "LoggingConfig": "A configuration object that specifies the logging configuration for the event source mapping\\. \n*Type*: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`LoggingConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "MetricsConfig": "A configuration object that specifies the metrics configuration for the event source mapping\\. \n*Type*: [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MetricsConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "ProvisionedPollerConfig": "A configuration object that specifies the provisioned poller configuration for the event source mapping\\. \n*Type*: [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`ProvisionedPollerConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "SchemaRegistryConfig": "A configuration object that specifies the schema registry configuration for the event source mapping\\. \n*Type*: [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SchemaRegistryConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "BisectBatchOnFunctionError": "If the function returns an error, split the batch in two and retry\\. \n*Type*: Boolean \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`BisectBatchOnFunctionError`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "FunctionResponseTypes": "A list of the response types currently applied to the event source mapping\\. For more information, see [Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n*Valid values*: `ReportBatchItemFailures` \n*Type*: List \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "MaximumRecordAgeInSeconds": "The maximum age of a record that Lambda sends to a function for processing\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumRecordAgeInSeconds`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds) property of an `AWS::Lambda::EventSourceMapping` resource\\.", diff --git a/samtranslator/model/eventsources/pull.py b/samtranslator/model/eventsources/pull.py index 6e3a7d778..8719ac037 100644 --- a/samtranslator/model/eventsources/pull.py +++ b/samtranslator/model/eventsources/pull.py @@ -61,6 +61,7 @@ class PullEventSource(ResourceMacro, metaclass=ABCMeta): "ProvisionedPollerConfig": PropertyType(False, IS_DICT), "SchemaRegistryConfig": PropertyType(False, IS_DICT), "MetricsConfig": PropertyType(False, IS_DICT), + "LoggingConfig": PropertyType(False, IS_DICT), } BatchSize: Optional[Intrinsicable[int]] @@ -87,6 +88,7 @@ class PullEventSource(ResourceMacro, metaclass=ABCMeta): ProvisionedPollerConfig: Optional[Dict[str, Any]] SchemaRegistryConfig: Optional[Dict[str, Any]] MetricsConfig: Optional[Dict[str, Any]] + LoggingConfig: Optional[Dict[str, Any]] @abstractmethod def get_policy_arn(self) -> Optional[str]: @@ -159,6 +161,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P lambda_eventsourcemapping.ScalingConfig = self.ScalingConfig lambda_eventsourcemapping.ProvisionedPollerConfig = self.ProvisionedPollerConfig lambda_eventsourcemapping.MetricsConfig = self.MetricsConfig + lambda_eventsourcemapping.LoggingConfig = self.LoggingConfig self._validate_filter_criteria() if self.KafkaBootstrapServers: diff --git a/samtranslator/model/lambda_.py b/samtranslator/model/lambda_.py index 243a069d5..11dfae55a 100644 --- a/samtranslator/model/lambda_.py +++ b/samtranslator/model/lambda_.py @@ -135,6 +135,7 @@ class LambdaEventSourceMapping(Resource): "ScalingConfig": GeneratedProperty(), "ProvisionedPollerConfig": GeneratedProperty(), "MetricsConfig": GeneratedProperty(), + "LoggingConfig": GeneratedProperty(), } runtime_attrs = {"name": lambda self: ref(self.logical_id)} diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index ac74f8de4..49552205c 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -183029,7 +183029,7 @@ "additionalProperties": false, "properties": { "SystemLogLevel": { - "markdownDescription": "Set this property to filter the system logs for your function that Lambda sends to CloudWatch. Lambda only sends system logs at the selected level of detail and lower, where `DEBUG` is the highest level and `WARN` is the lowest.", + "markdownDescription": "The system log level for your Lambda function.", "title": "SystemLogLevel", "type": "string" } @@ -183043,7 +183043,7 @@ "items": { "type": "string" }, - "markdownDescription": "The metrics you want your event source mapping to produce. Include `EventCount` to receive event source mapping metrics related to the number of events processed by your event source mapping. For more information about these metrics, see [Event source mapping metrics](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html#event-source-mapping-metrics) .", + "markdownDescription": "The metrics you want your event source mapping to produce. For more information about these metrics, see [Event source mapping metrics](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html#event-source-mapping-metrics) .", "title": "Metrics", "type": "array" } @@ -353934,10 +353934,22 @@ "title": "ConsumerGroupId" }, "DestinationConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the destination of an event after Lambda processes it\\. \nUse this property to specify the destination of failed invocations from the Amazon MSK event source\\. \n*Type*: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)` property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "DestinationConfig" }, "Enabled": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "Disables the event source mapping to pause polling and invocation\\. \n*Type*: Boolean \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Enabled`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "Enabled" }, "FilterCriteria": { "allOf": [ @@ -353958,7 +353970,22 @@ "title": "FunctionResponseTypes" }, "KmsKeyArn": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The ARN of the AWS Key Management Service \\(AWS KMS\\) customer managed key to use for encryption\\. Only the key ID or key ARN is supported\\. The key alias is not supported\\. If you don't specify a customer managed key, Lambda uses an AWS owned key for encryption\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`KMSKeyArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "KmsKeyArn" + }, + "LoggingConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the logging configuration for the event source mapping\\. \n*Type*: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`LoggingConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "LoggingConfig" }, "MaximumBatchingWindowInSeconds": { "allOf": [ @@ -353987,11 +354014,32 @@ "markdownDescription": "The maximum number of times to retry when the function returns an error\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumRetryAttempts`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "title": "MaximumRetryAttempts" }, + "MetricsConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the metrics configuration for the event source mapping\\. \n*Type*: [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MetricsConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "MetricsConfig" + }, "ProvisionedPollerConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the provisioned poller configuration for the event source mapping\\. \n*Type*: [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`ProvisionedPollerConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "ProvisionedPollerConfig" }, "SchemaRegistryConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the schema registry configuration for the event source mapping\\. \n*Type*: [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SchemaRegistryConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "SchemaRegistryConfig" }, "SourceAccessConfigurations": { "allOf": [ @@ -354882,7 +354930,22 @@ "type": "array" }, "KmsKeyArn": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The ARN of the AWS Key Management Service \\(AWS KMS\\) customer managed key to use for encryption\\. Only the key ID or key ARN is supported\\. The key alias is not supported\\. If you don't specify a customer managed key, Lambda uses an AWS owned key for encryption\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`KMSKeyArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "KmsKeyArn" + }, + "LoggingConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the logging configuration for the event source mapping\\. \n*Type*: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`LoggingConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "LoggingConfig" }, "MaximumRecordAgeInSeconds": { "allOf": [ @@ -354902,11 +354965,32 @@ "markdownDescription": "The maximum number of times to retry when the function returns an error\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumRetryAttempts`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "title": "MaximumRetryAttempts" }, + "MetricsConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the metrics configuration for the event source mapping\\. \n*Type*: [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MetricsConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "MetricsConfig" + }, "ProvisionedPollerConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the provisioned poller configuration for the event source mapping\\. \n*Type*: [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`ProvisionedPollerConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "ProvisionedPollerConfig" }, "SchemaRegistryConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the schema registry configuration for the event source mapping\\. \n*Type*: [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SchemaRegistryConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "SchemaRegistryConfig" }, "SourceAccessConfigurations": { "allOf": [ @@ -354918,10 +355002,22 @@ "title": "SourceAccessConfigurations" }, "StartingPosition": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The position in a stream from which to start reading\\. \n+ `AT_TIMESTAMP` \u2013 Specify a time from which to start reading records\\.\n+ `LATEST` \u2013 Read only new records\\.\n+ `TRIM_HORIZON` \u2013 Process all available records\\.\n*Valid values*: `AT_TIMESTAMP` \\| `LATEST` \\| `TRIM_HORIZON` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPosition`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "StartingPosition" }, "StartingPositionTimestamp": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The time from which to start reading, in Unix time seconds\\. Define `StartingPositionTimestamp` when `StartingPosition` is specified as `AT_TIMESTAMP`\\. \n*Type*: Double \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPositionTimestamp`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "StartingPositionTimestamp" }, "Topics": { "allOf": [ diff --git a/schema_source/cloudformation.schema.json b/schema_source/cloudformation.schema.json index b39a8c19f..185ae9a28 100644 --- a/schema_source/cloudformation.schema.json +++ b/schema_source/cloudformation.schema.json @@ -183137,6 +183137,31 @@ }, "type": "object" }, + "AWS::Lambda::EventSourceMapping.MetricsConfig": { + "additionalProperties": false, + "properties": { + "Metrics": { + "items": { + "type": "string" + }, + "markdownDescription": "The metrics you want your event source mapping to produce. For more information about these metrics, see [Event source mapping metrics](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html#event-source-mapping-metrics) .", + "title": "Metrics", + "type": "array" + } + }, + "type": "object" + }, + "AWS::Lambda::EventSourceMapping.LoggingConfig": { + "additionalProperties": false, + "properties": { + "SystemLogLevel": { + "markdownDescription": "The system log level for your Lambda function.", + "title": "SystemLogLevel", + "type": "string" + } + }, + "type": "object" + }, "AWS::Lambda::EventSourceMapping.SourceAccessConfiguration": { "additionalProperties": false, "properties": { diff --git a/schema_source/sam.schema.json b/schema_source/sam.schema.json index eb9ec1dc3..6c6459a4b 100644 --- a/schema_source/sam.schema.json +++ b/schema_source/sam.schema.json @@ -2543,10 +2543,22 @@ "title": "ConsumerGroupId" }, "DestinationConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the destination of an event after Lambda processes it\\. \nUse this property to specify the destination of failed invocations from the Amazon MSK event source\\. \n*Type*: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)` property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "DestinationConfig" }, "Enabled": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "Disables the event source mapping to pause polling and invocation\\. \n*Type*: Boolean \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Enabled`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "Enabled" }, "FilterCriteria": { "allOf": [ @@ -2567,7 +2579,22 @@ "title": "FunctionResponseTypes" }, "KmsKeyArn": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The ARN of the AWS Key Management Service \\(AWS KMS\\) customer managed key to use for encryption\\. Only the key ID or key ARN is supported\\. The key alias is not supported\\. If you don't specify a customer managed key, Lambda uses an AWS owned key for encryption\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`KMSKeyArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "KmsKeyArn" + }, + "LoggingConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the logging configuration for the event source mapping\\. \n*Type*: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`LoggingConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "LoggingConfig" }, "MaximumBatchingWindowInSeconds": { "allOf": [ @@ -2596,11 +2623,32 @@ "markdownDescription": "The maximum number of times to retry when the function returns an error\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumRetryAttempts`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "title": "MaximumRetryAttempts" }, + "MetricsConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the metrics configuration for the event source mapping\\. \n*Type*: [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MetricsConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "MetricsConfig" + }, "ProvisionedPollerConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the provisioned poller configuration for the event source mapping\\. \n*Type*: [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`ProvisionedPollerConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "ProvisionedPollerConfig" }, "SchemaRegistryConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the schema registry configuration for the event source mapping\\. \n*Type*: [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SchemaRegistryConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "SchemaRegistryConfig" }, "SourceAccessConfigurations": { "allOf": [ @@ -3422,7 +3470,22 @@ "type": "array" }, "KmsKeyArn": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The ARN of the AWS Key Management Service \\(AWS KMS\\) customer managed key to use for encryption\\. Only the key ID or key ARN is supported\\. The key alias is not supported\\. If you don't specify a customer managed key, Lambda uses an AWS owned key for encryption\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`KMSKeyArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "KmsKeyArn" + }, + "LoggingConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the logging configuration for the event source mapping\\. \n*Type*: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`LoggingConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "LoggingConfig" }, "MaximumRecordAgeInSeconds": { "allOf": [ @@ -3442,11 +3505,32 @@ "markdownDescription": "The maximum number of times to retry when the function returns an error\\. \n*Type*: Integer \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MaximumRetryAttempts`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts) property of an `AWS::Lambda::EventSourceMapping` resource\\.", "title": "MaximumRetryAttempts" }, + "MetricsConfig": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the metrics configuration for the event source mapping\\. \n*Type*: [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`MetricsConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "MetricsConfig" + }, "ProvisionedPollerConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the provisioned poller configuration for the event source mapping\\. \n*Type*: [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`ProvisionedPollerConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "ProvisionedPollerConfig" }, "SchemaRegistryConfig": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "A configuration object that specifies the schema registry configuration for the event source mapping\\. \n*Type*: [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`SchemaRegistryConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "SchemaRegistryConfig" }, "SourceAccessConfigurations": { "allOf": [ @@ -3458,10 +3542,22 @@ "title": "SourceAccessConfigurations" }, "StartingPosition": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The position in a stream from which to start reading\\. \n+ `AT_TIMESTAMP` \u2013 Specify a time from which to start reading records\\.\n+ `LATEST` \u2013 Read only new records\\.\n+ `TRIM_HORIZON` \u2013 Process all available records\\.\n*Valid values*: `AT_TIMESTAMP` \\| `LATEST` \\| `TRIM_HORIZON` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPosition`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "StartingPosition" }, "StartingPositionTimestamp": { - "$ref": "#/definitions/PassThroughProp" + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "The time from which to start reading, in Unix time seconds\\. Define `StartingPositionTimestamp` when `StartingPosition` is specified as `AT_TIMESTAMP`\\. \n*Type*: Double \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`StartingPositionTimestamp`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp) property of an `AWS::Lambda::EventSourceMapping` resource\\.", + "title": "StartingPositionTimestamp" }, "Topics": { "allOf": [ diff --git a/tests/model/eventsources/test_msk_event_source.py b/tests/model/eventsources/test_msk_event_source.py index 21850dffd..6163df28d 100644 --- a/tests/model/eventsources/test_msk_event_source.py +++ b/tests/model/eventsources/test_msk_event_source.py @@ -338,3 +338,56 @@ def test_to_cloudformation_with_provisioned_poller_config_including_poller_group # Verify that ProvisionedPollerConfig is correctly set with all properties including PollerGroupName expected_config = {"MinimumPollers": 5, "MaximumPollers": 10, "PollerGroupName": "my-poller-group"} self.assertEqual(event_source_mapping.ProvisionedPollerConfig, expected_config) + + def test_to_cloudformation_with_logging_config_different_levels(self): + # Test different SystemLogLevel values + test_levels = ["WARN", "INFO", "DEBUG"] + + for level in test_levels: + with self.subTest(level=level): + # Set up the event source with LoggingConfig + self.kafka_event_source.LoggingConfig = {"SystemLogLevel": level} + + # Set up mock function + function = Mock() + function.get_runtime_attr = Mock() + function.get_runtime_attr.return_value = "arn:aws:lambda:mock" + function.get_passthrough_resource_attributes = Mock() + function.get_passthrough_resource_attributes.return_value = {} + + # Set up mock role with proper attributes + role = Mock() + role.ManagedPolicyArns = [] + role.Policies = [] + + # Call to_cloudformation + resources = self.kafka_event_source.to_cloudformation(function=function, role=role) + + # Verify that LoggingConfig is passed through correctly + self.assertEqual(len(resources), 1) + event_source_mapping = resources[0] + self.assertEqual(event_source_mapping.LoggingConfig, {"SystemLogLevel": level}) + + def test_to_cloudformation_with_metrics_config_multiple_metrics(self): + # Set up the event source with MetricsConfig containing multiple metrics including KafkaMetrics + self.kafka_event_source.MetricsConfig = {"Metrics": ["EventCount", "ErrorCount", "KafkaMetrics"]} + + # Set up mock function + function = Mock() + function.get_runtime_attr = Mock() + function.get_runtime_attr.return_value = "arn:aws:lambda:mock" + function.get_passthrough_resource_attributes = Mock() + function.get_passthrough_resource_attributes.return_value = {} + + # Set up mock role with proper attributes + role = Mock() + role.ManagedPolicyArns = [] + role.Policies = [] + + # Call to_cloudformation + resources = self.kafka_event_source.to_cloudformation(function=function, role=role) + + # Verify that MetricsConfig is passed through to EventSourceMapping + self.assertEqual(len(resources), 1) + event_source_mapping = resources[0] + self.assertEqual(event_source_mapping.MetricsConfig, {"Metrics": ["EventCount", "ErrorCount", "KafkaMetrics"]}) diff --git a/tests/model/eventsources/test_self_managed_kafka_event_source.py b/tests/model/eventsources/test_self_managed_kafka_event_source.py index 4c00653fb..325e45602 100644 --- a/tests/model/eventsources/test_self_managed_kafka_event_source.py +++ b/tests/model/eventsources/test_self_managed_kafka_event_source.py @@ -709,3 +709,66 @@ def test_to_cloudformation_with_provisioned_poller_config_including_poller_group # Verify that ProvisionedPollerConfig is correctly set with all properties including PollerGroupName expected_config = {"MinimumPollers": 3, "MaximumPollers": 15, "PollerGroupName": "self-managed-poller-group"} self.assertEqual(event_source_mapping.ProvisionedPollerConfig, expected_config) + + @parameterized.expand([("WARN",), ("INFO",), ("DEBUG",)]) + def test_to_cloudformation_with_logging_config_different_levels(self, level): + # Set up the event source with required properties + self.kafka_event_source.SourceAccessConfigurations = [ + {"Type": "BASIC_AUTH", "URI": "SECRET_URI"}, + {"Type": "VPC_SUBNET", "URI": "SECRET_URI"}, + {"Type": "VPC_SECURITY_GROUP", "URI": "SECRET_URI"}, + ] + self.kafka_event_source.Topics = ["Topics"] + self.kafka_event_source.KafkaBootstrapServers = ["endpoint1", "endpoint2"] + self.kafka_event_source.LoggingConfig = {"SystemLogLevel": level} + + # Set up mock function + function = Mock() + function.get_runtime_attr = Mock() + function.get_runtime_attr.return_value = "arn:aws:lambda:mock" + function.get_passthrough_resource_attributes = Mock() + function.get_passthrough_resource_attributes.return_value = {} + + # Set up mock role with proper attributes + role = Mock() + role.ManagedPolicyArns = [] + role.Policies = [] + + # Call to_cloudformation + resources = self.kafka_event_source.to_cloudformation(function=function, role=role) + + # Verify that LoggingConfig is passed through correctly + self.assertEqual(len(resources), 1) + event_source_mapping = resources[0] + self.assertEqual(event_source_mapping.LoggingConfig, {"SystemLogLevel": level}) + + def test_to_cloudformation_with_metrics_config_multiple_metrics(self): + # Set up the event source with required properties and MetricsConfig containing multiple metrics including KafkaMetrics + self.kafka_event_source.SourceAccessConfigurations = [ + {"Type": "BASIC_AUTH", "URI": "SECRET_URI"}, + {"Type": "VPC_SUBNET", "URI": "SECRET_URI"}, + {"Type": "VPC_SECURITY_GROUP", "URI": "SECRET_URI"}, + ] + self.kafka_event_source.Topics = ["Topics"] + self.kafka_event_source.KafkaBootstrapServers = ["endpoint1", "endpoint2"] + self.kafka_event_source.MetricsConfig = {"Metrics": ["EventCount", "ErrorCount", "KafkaMetrics"]} + + # Set up mock function + function = Mock() + function.get_runtime_attr = Mock() + function.get_runtime_attr.return_value = "arn:aws:lambda:mock" + function.get_passthrough_resource_attributes = Mock() + function.get_passthrough_resource_attributes.return_value = {} + + # Set up mock role with proper attributes + role = Mock() + role.ManagedPolicyArns = [] + role.Policies = [] + + # Call to_cloudformation + resources = self.kafka_event_source.to_cloudformation(function=function, role=role) + + # Verify that MetricsConfig is passed through to EventSourceMapping + self.assertEqual(len(resources), 1) + event_source_mapping = resources[0] + self.assertEqual(event_source_mapping.MetricsConfig, {"Metrics": ["EventCount", "ErrorCount", "KafkaMetrics"]}) diff --git a/tests/translator/input/function_with_logging_config.yaml b/tests/translator/input/function_with_logging_config.yaml new file mode 100644 index 000000000..b56b7a38e --- /dev/null +++ b/tests/translator/input/function_with_logging_config.yaml @@ -0,0 +1,52 @@ +Resources: + LoggingConfigFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/loggingConfig.zip + Handler: index.handler + Runtime: nodejs16.x + Events: + MSKEvent: + Type: MSK + Properties: + Stream: !GetAtt MSKCluster.Arn + StartingPosition: LATEST + Topics: + - my-topic + LoggingConfig: + SystemLogLevel: DEBUG + SelfManagedKafkaEvent: + Type: SelfManagedKafka + Properties: + KafkaBootstrapServers: + - broker1:9092 + - broker2:9092 + Topics: + - my-topic + SourceAccessConfigurations: + - Type: SASL_SCRAM_256_AUTH + URI: !Ref KafkaSecret + LoggingConfig: + SystemLogLevel: WARN + + MSKCluster: + Type: AWS::MSK::Cluster + Properties: + ClusterName: test-cluster + KafkaVersion: 2.8.0 + NumberOfBrokerNodes: 2 + BrokerNodeGroupInfo: + InstanceType: kafka.t3.small + ClientSubnets: + - subnet-12345 + - subnet-67890 + + KafkaSecret: + Type: AWS::SecretsManager::Secret + Properties: + Description: Kafka SASL credentials + SecretString: !Sub |- + { + "username": "kafka-user", + "password": "kafka-password" + } diff --git a/tests/translator/input/function_with_metrics_config.yaml b/tests/translator/input/function_with_metrics_config.yaml index e1b581efb..46fd400ab 100644 --- a/tests/translator/input/function_with_metrics_config.yaml +++ b/tests/translator/input/function_with_metrics_config.yaml @@ -37,6 +37,33 @@ Resources: FilterCriteria: Filters: - Pattern: '{"name": "value"}' + MSKEvent: + Type: MSK + Properties: + Stream: !GetAtt MSKCluster.Arn + StartingPosition: LATEST + MetricsConfig: + Metrics: + - EventCount + - ErrorCount + - KafkaMetrics + Topics: + - my-topic + SelfManagedKafkaEvent: + Type: SelfManagedKafka + Properties: + KafkaBootstrapServers: + - broker1:9092 + - broker2:9092 + Topics: + - my-topic + SourceAccessConfigurations: + - Type: SASL_SCRAM_256_AUTH + URI: !Ref KafkaSecret + MetricsConfig: + Metrics: + - ErrorCount + - KafkaMetrics KinesisStream: Type: AWS::Kinesis::Stream @@ -56,3 +83,25 @@ Resources: MySqsQueue: Type: AWS::SQS::Queue + + MSKCluster: + Type: AWS::MSK::Cluster + Properties: + ClusterName: test-cluster + KafkaVersion: 2.8.0 + NumberOfBrokerNodes: 2 + BrokerNodeGroupInfo: + InstanceType: kafka.t3.small + ClientSubnets: + - subnet-12345 + - subnet-67890 + + KafkaSecret: + Type: AWS::SecretsManager::Secret + Properties: + Description: Kafka SASL credentials + SecretString: !Sub | + { + "username": "kafka-user", + "password": "kafka-password" + } diff --git a/tests/translator/output/aws-cn/function_with_logging_config.json b/tests/translator/output/aws-cn/function_with_logging_config.json new file mode 100644 index 000000000..7b314f630 --- /dev/null +++ b/tests/translator/output/aws-cn/function_with_logging_config.json @@ -0,0 +1,152 @@ +{ + "Resources": { + "KafkaSecret": { + "Properties": { + "Description": "Kafka SASL credentials", + "SecretString": { + "Fn::Sub": "{\n \"username\": \"kafka-user\",\n \"password\": \"kafka-password\"\n}" + } + }, + "Type": "AWS::SecretsManager::Secret" + }, + "LoggingConfigFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "loggingConfig.zip" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "LoggingConfigFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs16.x", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "LoggingConfigFunctionMSKEvent": { + "Properties": { + "EventSourceArn": { + "Fn::GetAtt": [ + "MSKCluster", + "Arn" + ] + }, + "FunctionName": { + "Ref": "LoggingConfigFunction" + }, + "LoggingConfig": { + "SystemLogLevel": "DEBUG" + }, + "StartingPosition": "LATEST", + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "LoggingConfigFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole" + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": { + "Ref": "KafkaSecret" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" + } + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + }, + "LoggingConfigFunctionSelfManagedKafkaEvent": { + "Properties": { + "FunctionName": { + "Ref": "LoggingConfigFunction" + }, + "LoggingConfig": { + "SystemLogLevel": "WARN" + }, + "SelfManagedEventSource": { + "Endpoints": { + "KafkaBootstrapServers": [ + "broker1:9092", + "broker2:9092" + ] + } + }, + "SourceAccessConfigurations": [ + { + "Type": "SASL_SCRAM_256_AUTH", + "URI": { + "Ref": "KafkaSecret" + } + } + ], + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "MSKCluster": { + "Properties": { + "BrokerNodeGroupInfo": { + "ClientSubnets": [ + "subnet-12345", + "subnet-67890" + ], + "InstanceType": "kafka.t3.small" + }, + "ClusterName": "test-cluster", + "KafkaVersion": "2.8.0", + "NumberOfBrokerNodes": 2 + }, + "Type": "AWS::MSK::Cluster" + } + } +} diff --git a/tests/translator/output/aws-cn/function_with_metrics_config.json b/tests/translator/output/aws-cn/function_with_metrics_config.json index eae07b130..0c99192bf 100644 --- a/tests/translator/output/aws-cn/function_with_metrics_config.json +++ b/tests/translator/output/aws-cn/function_with_metrics_config.json @@ -92,6 +92,31 @@ }, "Type": "AWS::Lambda::EventSourceMapping" }, + "FilteredEventsFunctionMSKEvent": { + "Properties": { + "EventSourceArn": { + "Fn::GetAtt": [ + "MSKCluster", + "Arn" + ] + }, + "FunctionName": { + "Ref": "FilteredEventsFunction" + }, + "MetricsConfig": { + "Metrics": [ + "EventCount", + "ErrorCount", + "KafkaMetrics" + ] + }, + "StartingPosition": "LATEST", + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, "FilteredEventsFunctionMySqsQueue": { "Properties": { "EventSourceArn": { @@ -140,8 +165,28 @@ "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole", "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole", + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole", "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole" ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": { + "Ref": "KafkaSecret" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" + } + ], "Tags": [ { "Key": "lambda:createdBy", @@ -151,12 +196,69 @@ }, "Type": "AWS::IAM::Role" }, + "FilteredEventsFunctionSelfManagedKafkaEvent": { + "Properties": { + "FunctionName": { + "Ref": "FilteredEventsFunction" + }, + "MetricsConfig": { + "Metrics": [ + "ErrorCount", + "KafkaMetrics" + ] + }, + "SelfManagedEventSource": { + "Endpoints": { + "KafkaBootstrapServers": [ + "broker1:9092", + "broker2:9092" + ] + } + }, + "SourceAccessConfigurations": [ + { + "Type": "SASL_SCRAM_256_AUTH", + "URI": { + "Ref": "KafkaSecret" + } + } + ], + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "KafkaSecret": { + "Properties": { + "Description": "Kafka SASL credentials", + "SecretString": { + "Fn::Sub": "{\n \"username\": \"kafka-user\",\n \"password\": \"kafka-password\"\n}\n" + } + }, + "Type": "AWS::SecretsManager::Secret" + }, "KinesisStream": { "Properties": { "ShardCount": 1 }, "Type": "AWS::Kinesis::Stream" }, + "MSKCluster": { + "Properties": { + "BrokerNodeGroupInfo": { + "ClientSubnets": [ + "subnet-12345", + "subnet-67890" + ], + "InstanceType": "kafka.t3.small" + }, + "ClusterName": "test-cluster", + "KafkaVersion": "2.8.0", + "NumberOfBrokerNodes": 2 + }, + "Type": "AWS::MSK::Cluster" + }, "MySqsQueue": { "Type": "AWS::SQS::Queue" } diff --git a/tests/translator/output/aws-us-gov/function_with_logging_config.json b/tests/translator/output/aws-us-gov/function_with_logging_config.json new file mode 100644 index 000000000..64e16c06d --- /dev/null +++ b/tests/translator/output/aws-us-gov/function_with_logging_config.json @@ -0,0 +1,152 @@ +{ + "Resources": { + "KafkaSecret": { + "Properties": { + "Description": "Kafka SASL credentials", + "SecretString": { + "Fn::Sub": "{\n \"username\": \"kafka-user\",\n \"password\": \"kafka-password\"\n}" + } + }, + "Type": "AWS::SecretsManager::Secret" + }, + "LoggingConfigFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "loggingConfig.zip" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "LoggingConfigFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs16.x", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "LoggingConfigFunctionMSKEvent": { + "Properties": { + "EventSourceArn": { + "Fn::GetAtt": [ + "MSKCluster", + "Arn" + ] + }, + "FunctionName": { + "Ref": "LoggingConfigFunction" + }, + "LoggingConfig": { + "SystemLogLevel": "DEBUG" + }, + "StartingPosition": "LATEST", + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "LoggingConfigFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole" + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": { + "Ref": "KafkaSecret" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" + } + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + }, + "LoggingConfigFunctionSelfManagedKafkaEvent": { + "Properties": { + "FunctionName": { + "Ref": "LoggingConfigFunction" + }, + "LoggingConfig": { + "SystemLogLevel": "WARN" + }, + "SelfManagedEventSource": { + "Endpoints": { + "KafkaBootstrapServers": [ + "broker1:9092", + "broker2:9092" + ] + } + }, + "SourceAccessConfigurations": [ + { + "Type": "SASL_SCRAM_256_AUTH", + "URI": { + "Ref": "KafkaSecret" + } + } + ], + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "MSKCluster": { + "Properties": { + "BrokerNodeGroupInfo": { + "ClientSubnets": [ + "subnet-12345", + "subnet-67890" + ], + "InstanceType": "kafka.t3.small" + }, + "ClusterName": "test-cluster", + "KafkaVersion": "2.8.0", + "NumberOfBrokerNodes": 2 + }, + "Type": "AWS::MSK::Cluster" + } + } +} diff --git a/tests/translator/output/aws-us-gov/function_with_metrics_config.json b/tests/translator/output/aws-us-gov/function_with_metrics_config.json index 30b9b857e..fab29759f 100644 --- a/tests/translator/output/aws-us-gov/function_with_metrics_config.json +++ b/tests/translator/output/aws-us-gov/function_with_metrics_config.json @@ -92,6 +92,31 @@ }, "Type": "AWS::Lambda::EventSourceMapping" }, + "FilteredEventsFunctionMSKEvent": { + "Properties": { + "EventSourceArn": { + "Fn::GetAtt": [ + "MSKCluster", + "Arn" + ] + }, + "FunctionName": { + "Ref": "FilteredEventsFunction" + }, + "MetricsConfig": { + "Metrics": [ + "EventCount", + "ErrorCount", + "KafkaMetrics" + ] + }, + "StartingPosition": "LATEST", + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, "FilteredEventsFunctionMySqsQueue": { "Properties": { "EventSourceArn": { @@ -140,8 +165,28 @@ "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole", "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole", + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole", "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole" ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": { + "Ref": "KafkaSecret" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" + } + ], "Tags": [ { "Key": "lambda:createdBy", @@ -151,12 +196,69 @@ }, "Type": "AWS::IAM::Role" }, + "FilteredEventsFunctionSelfManagedKafkaEvent": { + "Properties": { + "FunctionName": { + "Ref": "FilteredEventsFunction" + }, + "MetricsConfig": { + "Metrics": [ + "ErrorCount", + "KafkaMetrics" + ] + }, + "SelfManagedEventSource": { + "Endpoints": { + "KafkaBootstrapServers": [ + "broker1:9092", + "broker2:9092" + ] + } + }, + "SourceAccessConfigurations": [ + { + "Type": "SASL_SCRAM_256_AUTH", + "URI": { + "Ref": "KafkaSecret" + } + } + ], + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "KafkaSecret": { + "Properties": { + "Description": "Kafka SASL credentials", + "SecretString": { + "Fn::Sub": "{\n \"username\": \"kafka-user\",\n \"password\": \"kafka-password\"\n}\n" + } + }, + "Type": "AWS::SecretsManager::Secret" + }, "KinesisStream": { "Properties": { "ShardCount": 1 }, "Type": "AWS::Kinesis::Stream" }, + "MSKCluster": { + "Properties": { + "BrokerNodeGroupInfo": { + "ClientSubnets": [ + "subnet-12345", + "subnet-67890" + ], + "InstanceType": "kafka.t3.small" + }, + "ClusterName": "test-cluster", + "KafkaVersion": "2.8.0", + "NumberOfBrokerNodes": 2 + }, + "Type": "AWS::MSK::Cluster" + }, "MySqsQueue": { "Type": "AWS::SQS::Queue" } diff --git a/tests/translator/output/function_with_logging_config.json b/tests/translator/output/function_with_logging_config.json new file mode 100644 index 000000000..b1c3ba430 --- /dev/null +++ b/tests/translator/output/function_with_logging_config.json @@ -0,0 +1,152 @@ +{ + "Resources": { + "KafkaSecret": { + "Properties": { + "Description": "Kafka SASL credentials", + "SecretString": { + "Fn::Sub": "{\n \"username\": \"kafka-user\",\n \"password\": \"kafka-password\"\n}" + } + }, + "Type": "AWS::SecretsManager::Secret" + }, + "LoggingConfigFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "loggingConfig.zip" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "LoggingConfigFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs16.x", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "LoggingConfigFunctionMSKEvent": { + "Properties": { + "EventSourceArn": { + "Fn::GetAtt": [ + "MSKCluster", + "Arn" + ] + }, + "FunctionName": { + "Ref": "LoggingConfigFunction" + }, + "LoggingConfig": { + "SystemLogLevel": "DEBUG" + }, + "StartingPosition": "LATEST", + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "LoggingConfigFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "arn:aws:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole" + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": { + "Ref": "KafkaSecret" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" + } + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + }, + "LoggingConfigFunctionSelfManagedKafkaEvent": { + "Properties": { + "FunctionName": { + "Ref": "LoggingConfigFunction" + }, + "LoggingConfig": { + "SystemLogLevel": "WARN" + }, + "SelfManagedEventSource": { + "Endpoints": { + "KafkaBootstrapServers": [ + "broker1:9092", + "broker2:9092" + ] + } + }, + "SourceAccessConfigurations": [ + { + "Type": "SASL_SCRAM_256_AUTH", + "URI": { + "Ref": "KafkaSecret" + } + } + ], + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "MSKCluster": { + "Properties": { + "BrokerNodeGroupInfo": { + "ClientSubnets": [ + "subnet-12345", + "subnet-67890" + ], + "InstanceType": "kafka.t3.small" + }, + "ClusterName": "test-cluster", + "KafkaVersion": "2.8.0", + "NumberOfBrokerNodes": 2 + }, + "Type": "AWS::MSK::Cluster" + } + } +} diff --git a/tests/translator/output/function_with_metrics_config.json b/tests/translator/output/function_with_metrics_config.json index ed6521020..b7f558d07 100644 --- a/tests/translator/output/function_with_metrics_config.json +++ b/tests/translator/output/function_with_metrics_config.json @@ -92,6 +92,31 @@ }, "Type": "AWS::Lambda::EventSourceMapping" }, + "FilteredEventsFunctionMSKEvent": { + "Properties": { + "EventSourceArn": { + "Fn::GetAtt": [ + "MSKCluster", + "Arn" + ] + }, + "FunctionName": { + "Ref": "FilteredEventsFunction" + }, + "MetricsConfig": { + "Metrics": [ + "EventCount", + "ErrorCount", + "KafkaMetrics" + ] + }, + "StartingPosition": "LATEST", + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, "FilteredEventsFunctionMySqsQueue": { "Properties": { "EventSourceArn": { @@ -140,8 +165,28 @@ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", "arn:aws:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole", "arn:aws:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole", + "arn:aws:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole", "arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole" ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": { + "Ref": "KafkaSecret" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" + } + ], "Tags": [ { "Key": "lambda:createdBy", @@ -151,12 +196,69 @@ }, "Type": "AWS::IAM::Role" }, + "FilteredEventsFunctionSelfManagedKafkaEvent": { + "Properties": { + "FunctionName": { + "Ref": "FilteredEventsFunction" + }, + "MetricsConfig": { + "Metrics": [ + "ErrorCount", + "KafkaMetrics" + ] + }, + "SelfManagedEventSource": { + "Endpoints": { + "KafkaBootstrapServers": [ + "broker1:9092", + "broker2:9092" + ] + } + }, + "SourceAccessConfigurations": [ + { + "Type": "SASL_SCRAM_256_AUTH", + "URI": { + "Ref": "KafkaSecret" + } + } + ], + "Topics": [ + "my-topic" + ] + }, + "Type": "AWS::Lambda::EventSourceMapping" + }, + "KafkaSecret": { + "Properties": { + "Description": "Kafka SASL credentials", + "SecretString": { + "Fn::Sub": "{\n \"username\": \"kafka-user\",\n \"password\": \"kafka-password\"\n}\n" + } + }, + "Type": "AWS::SecretsManager::Secret" + }, "KinesisStream": { "Properties": { "ShardCount": 1 }, "Type": "AWS::Kinesis::Stream" }, + "MSKCluster": { + "Properties": { + "BrokerNodeGroupInfo": { + "ClientSubnets": [ + "subnet-12345", + "subnet-67890" + ], + "InstanceType": "kafka.t3.small" + }, + "ClusterName": "test-cluster", + "KafkaVersion": "2.8.0", + "NumberOfBrokerNodes": 2 + }, + "Type": "AWS::MSK::Cluster" + }, "MySqsQueue": { "Type": "AWS::SQS::Queue" }