Class: AWSCDK::LambdaEventSources::ManagedKafkaEventSource

Inherits:
StreamEventSource
  • Object
show all
Defined in:
lambda_event_sources/managed_kafka_event_source.rb

Overview

Use a MSK cluster as a streaming source for AWS Lambda.

Examples:

require 'aws-cdk-lib'

# With provisioned pollers and poller group for cost optimization
my_function = nil # AWSCDK::Lambda::Function

my_function.add_event_source(AWSCDK::LambdaEventSources::ManagedKafkaEventSource.new({
    cluster_arn: "arn:aws:kafka:us-east-1:123456789012:cluster/my-cluster/abcd1234-abcd-cafe-abab-9876543210ab-4",
    topic: "orders-topic",
    starting_position: AWSCDK::Lambda::StartingPosition::LATEST,
    provisioned_poller_config: {
        minimum_pollers: 2,
        maximum_pollers: 10,
        poller_group_name: "shared-kafka-pollers",
    },
}))

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props) ⇒ ManagedKafkaEventSource

Returns a new instance of ManagedKafkaEventSource.



26
27
28
29
30
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 26

def initialize(props)
  props = props.is_a?(Hash) ? ::AWSCDK::LambdaEventSources::ManagedKafkaEventSourceProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhX2V2ZW50X3NvdXJjZXMuTWFuYWdlZEthZmthRXZlbnRTb3VyY2VQcm9wcyJ9")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(props)
end

Class Method Details

.jsii_overridable_methodsObject



32
33
34
35
36
37
38
39
40
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 32

def self.jsii_overridable_methods
  {
    :props => { kind: :property, name: "props", is_optional: false },
    :event_source_mapping_arn => { kind: :property, name: "eventSourceMappingArn", is_optional: false },
    :event_source_mapping_id => { kind: :property, name: "eventSourceMappingId", is_optional: false },
    :bind => { kind: :method, name: "bind", is_optional: false },
    :enrich_mapping_options => { kind: :method, name: "enrichMappingOptions", is_optional: false },
  }
end

Instance Method Details

#bind(target) ⇒ void

This method returns an undefined value.

Called by lambda.addEventSource to allow the event source to bind to this function.

Parameters:



65
66
67
68
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 65

def bind(target)
  Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "target")
  jsii_call_method("bind", [target])
end

#enrich_mapping_options(options) ⇒ AWSCDK::Lambda::EventSourceMappingOptions



72
73
74
75
76
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 72

def enrich_mapping_options(options)
  options = options.is_a?(Hash) ? ::AWSCDK::Lambda::EventSourceMappingOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLkV2ZW50U291cmNlTWFwcGluZ09wdGlvbnMifQ==")), "options")
  jsii_call_method("enrichMappingOptions", [options])
end

#event_source_mapping_arnString

The ARN for this EventSourceMapping.

Returns:

  • (String)


50
51
52
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 50

def event_source_mapping_arn()
  jsii_get_property("eventSourceMappingArn")
end

#event_source_mapping_idString

The identifier for this EventSourceMapping.

Returns:

  • (String)


57
58
59
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 57

def event_source_mapping_id()
  jsii_get_property("eventSourceMappingId")
end

#propsAWSCDK::LambdaEventSources::StreamEventSourceProps



43
44
45
# File 'lambda_event_sources/managed_kafka_event_source.rb', line 43

def props()
  jsii_get_property("props")
end