awslambdaeventsources

package
v1.153.1-devpreview Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApiEventSource_Override

func NewApiEventSource_Override(a ApiEventSource, method *string, path *string, options *awsapigateway.MethodOptions)

Experimental.

func NewDynamoEventSource_Override

func NewDynamoEventSource_Override(d DynamoEventSource, table awsdynamodb.ITable, props *DynamoEventSourceProps)

Experimental.

func NewKinesisEventSource_Override

func NewKinesisEventSource_Override(k KinesisEventSource, stream awskinesis.IStream, props *KinesisEventSourceProps)

Experimental.

func NewManagedKafkaEventSource_Override

func NewManagedKafkaEventSource_Override(m ManagedKafkaEventSource, props *ManagedKafkaEventSourceProps)

Experimental.

func NewS3EventSource_Override

func NewS3EventSource_Override(s S3EventSource, bucket awss3.Bucket, props *S3EventSourceProps)

Experimental.

func NewSelfManagedKafkaEventSource_Override

func NewSelfManagedKafkaEventSource_Override(s SelfManagedKafkaEventSource, props *SelfManagedKafkaEventSourceProps)

Experimental.

func NewSnsDlq_Override

func NewSnsDlq_Override(s SnsDlq, topic awssns.ITopic)

Experimental.

func NewSnsEventSource_Override

func NewSnsEventSource_Override(s SnsEventSource, topic awssns.ITopic, props *SnsEventSourceProps)

Experimental.

func NewSqsDlq_Override

func NewSqsDlq_Override(s SqsDlq, queue awssqs.IQueue)

Experimental.

func NewSqsEventSource_Override

func NewSqsEventSource_Override(s SqsEventSource, queue awssqs.IQueue, props *SqsEventSourceProps)

Experimental.

func NewStreamEventSource_Override

func NewStreamEventSource_Override(s StreamEventSource, props *StreamEventSourceProps)

Experimental.

Types

type ApiEventSource

type ApiEventSource interface {
	awslambda.IEventSource
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
}

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"import apigateway "github.com/aws/aws-cdk-go/awscdk/aws_apigateway"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda_event_sources "github.com/aws/aws-cdk-go/awscdk/aws_lambda_event_sources"

var authorizer authorizer
var model model
var requestValidator requestValidator
apiEventSource := lambda_event_sources.NewApiEventSource(jsii.String("method"), jsii.String("path"), &methodOptions{
	apiKeyRequired: jsii.Boolean(false),
	authorizationScopes: []*string{
		jsii.String("authorizationScopes"),
	},
	authorizationType: apigateway.authorizationType_NONE,
	authorizer: authorizer,
	methodResponses: []methodResponse{
		&methodResponse{
			statusCode: jsii.String("statusCode"),

			// the properties below are optional
			responseModels: map[string]iModel{
				"responseModelsKey": model,
			},
			responseParameters: map[string]*bool{
				"responseParametersKey": jsii.Boolean(false),
			},
		},
	},
	operationName: jsii.String("operationName"),
	requestModels: map[string]*iModel{
		"requestModelsKey": model,
	},
	requestParameters: map[string]*bool{
		"requestParametersKey": jsii.Boolean(false),
	},
	requestValidator: requestValidator,
	requestValidatorOptions: &requestValidatorOptions{
		requestValidatorName: jsii.String("requestValidatorName"),
		validateRequestBody: jsii.Boolean(false),
		validateRequestParameters: jsii.Boolean(false),
	},
})

Experimental.

func NewApiEventSource

func NewApiEventSource(method *string, path *string, options *awsapigateway.MethodOptions) ApiEventSource

Experimental.

type AuthenticationMethod

type AuthenticationMethod string

The authentication method to use with SelfManagedKafkaEventSource. Experimental.

const (
	// SASL_SCRAM_512_AUTH authentication method for your Kafka cluster.
	// Experimental.
	AuthenticationMethod_SASL_SCRAM_512_AUTH AuthenticationMethod = "SASL_SCRAM_512_AUTH"
	// SASL_SCRAM_256_AUTH authentication method for your Kafka cluster.
	// Experimental.
	AuthenticationMethod_SASL_SCRAM_256_AUTH AuthenticationMethod = "SASL_SCRAM_256_AUTH"
	// BASIC_AUTH (SASL/PLAIN) authentication method for your Kafka cluster.
	// Experimental.
	AuthenticationMethod_BASIC_AUTH AuthenticationMethod = "BASIC_AUTH"
	// CLIENT_CERTIFICATE_TLS_AUTH (mTLS) authentication method for your Kafka cluster.
	// Experimental.
	AuthenticationMethod_CLIENT_CERTIFICATE_TLS_AUTH AuthenticationMethod = "CLIENT_CERTIFICATE_TLS_AUTH"
)

type BaseStreamEventSourceProps

type BaseStreamEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
}

The set of properties for streaming event sources shared by Dynamo, Kinesis and Kafka.

Example:

import monocdk "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda "github.com/aws/aws-cdk-go/awscdk/aws_lambda"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda_event_sources "github.com/aws/aws-cdk-go/awscdk/aws_lambda_event_sources"

var duration duration
baseStreamEventSourceProps := &baseStreamEventSourceProps{
	startingPosition: lambda.startingPosition_TRIM_HORIZON,

	// the properties below are optional
	batchSize: jsii.Number(123),
	enabled: jsii.Boolean(false),
	maxBatchingWindow: duration,
}

Experimental.

type DynamoEventSource

type DynamoEventSource interface {
	StreamEventSource
	// The identifier for this EventSourceMapping.
	// Experimental.
	EventSourceMappingId() *string
	// Experimental.
	Props() *StreamEventSourceProps
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
	// Experimental.
	EnrichMappingOptions(options *awslambda.EventSourceMappingOptions) *awslambda.EventSourceMappingOptions
}

Use an Amazon DynamoDB stream as an event source for AWS Lambda.

Example:

import dynamodb "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type DynamoEventSource awscdk.DynamoEventSource
type SqsDlq awscdk.SqsDlq

var table table

var fn function

deadLetterQueue := sqs.NewQueue(this, jsii.String("deadLetterQueue"))
fn.addEventSource(NewDynamoEventSource(table, &dynamoEventSourceProps{
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
	batchSize: jsii.Number(5),
	bisectBatchOnError: jsii.Boolean(true),
	onFailure: NewSqsDlq(deadLetterQueue),
	retryAttempts: jsii.Number(10),
}))

Experimental.

func NewDynamoEventSource

func NewDynamoEventSource(table awsdynamodb.ITable, props *DynamoEventSourceProps) DynamoEventSource

Experimental.

type DynamoEventSourceProps

type DynamoEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// If the function returns an error, split the batch in two and retry.
	// Experimental.
	BisectBatchOnError *bool `json:"bisectBatchOnError" yaml:"bisectBatchOnError"`
	// The maximum age of a record that Lambda sends to a function for processing.
	//
	// Valid Range:
	// * Minimum value of 60 seconds
	// * Maximum value of 7 days.
	// Experimental.
	MaxRecordAge awscdk.Duration `json:"maxRecordAge" yaml:"maxRecordAge"`
	// An Amazon SQS queue or Amazon SNS topic destination for discarded records.
	// Experimental.
	OnFailure awslambda.IEventSourceDlq `json:"onFailure" yaml:"onFailure"`
	// The number of batches to process from each shard concurrently.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of 10.
	// Experimental.
	ParallelizationFactor *float64 `json:"parallelizationFactor" yaml:"parallelizationFactor"`
	// Allow functions to return partially successful responses for a batch of records.
	// See: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting
	//
	// Experimental.
	ReportBatchItemFailures *bool `json:"reportBatchItemFailures" yaml:"reportBatchItemFailures"`
	// Maximum number of retry attempts Valid Range: * Minimum value of 0 * Maximum value of 10000.
	// Experimental.
	RetryAttempts *float64 `json:"retryAttempts" yaml:"retryAttempts"`
	// The size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.
	// Experimental.
	TumblingWindow awscdk.Duration `json:"tumblingWindow" yaml:"tumblingWindow"`
}

Example:

import dynamodb "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type DynamoEventSource awscdk.DynamoEventSource
type SqsDlq awscdk.SqsDlq

var table table

var fn function

deadLetterQueue := sqs.NewQueue(this, jsii.String("deadLetterQueue"))
fn.addEventSource(NewDynamoEventSource(table, &dynamoEventSourceProps{
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
	batchSize: jsii.Number(5),
	bisectBatchOnError: jsii.Boolean(true),
	onFailure: NewSqsDlq(deadLetterQueue),
	retryAttempts: jsii.Number(10),
}))

Experimental.

type KafkaEventSourceProps

type KafkaEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// The Kafka topic to subscribe to.
	// Experimental.
	Topic *string `json:"topic" yaml:"topic"`
	// The secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet.
	// Experimental.
	Secret awssecretsmanager.ISecret `json:"secret" yaml:"secret"`
}

Properties for a Kafka event source.

Example:

import monocdk "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda "github.com/aws/aws-cdk-go/awscdk/aws_lambda"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda_event_sources "github.com/aws/aws-cdk-go/awscdk/aws_lambda_event_sources"import awscdk "github.com/aws/aws-cdk-go/awscdk"import secretsmanager "github.com/aws/aws-cdk-go/awscdk/aws_secretsmanager"

var duration duration
var secret secret
kafkaEventSourceProps := &kafkaEventSourceProps{
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
	topic: jsii.String("topic"),

	// the properties below are optional
	batchSize: jsii.Number(123),
	enabled: jsii.Boolean(false),
	maxBatchingWindow: duration,
	secret: secret,
}

Experimental.

type KinesisEventSource

type KinesisEventSource interface {
	StreamEventSource
	// The identifier for this EventSourceMapping.
	// Experimental.
	EventSourceMappingId() *string
	// Experimental.
	Props() *StreamEventSourceProps
	// Experimental.
	Stream() awskinesis.IStream
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
	// Experimental.
	EnrichMappingOptions(options *awslambda.EventSourceMappingOptions) *awslambda.EventSourceMappingOptions
}

Use an Amazon Kinesis stream as an event source for AWS Lambda.

Example:

import kinesis "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type KinesisEventSource awscdk.KinesisEventSource

var myFunction function

stream := kinesis.NewStream(this, jsii.String("MyStream"))
myFunction.addEventSource(NewKinesisEventSource(stream, &kinesisEventSourceProps{
	batchSize: jsii.Number(100),
	 // default
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
}))

Experimental.

func NewKinesisEventSource

func NewKinesisEventSource(stream awskinesis.IStream, props *KinesisEventSourceProps) KinesisEventSource

Experimental.

type KinesisEventSourceProps

type KinesisEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// If the function returns an error, split the batch in two and retry.
	// Experimental.
	BisectBatchOnError *bool `json:"bisectBatchOnError" yaml:"bisectBatchOnError"`
	// The maximum age of a record that Lambda sends to a function for processing.
	//
	// Valid Range:
	// * Minimum value of 60 seconds
	// * Maximum value of 7 days.
	// Experimental.
	MaxRecordAge awscdk.Duration `json:"maxRecordAge" yaml:"maxRecordAge"`
	// An Amazon SQS queue or Amazon SNS topic destination for discarded records.
	// Experimental.
	OnFailure awslambda.IEventSourceDlq `json:"onFailure" yaml:"onFailure"`
	// The number of batches to process from each shard concurrently.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of 10.
	// Experimental.
	ParallelizationFactor *float64 `json:"parallelizationFactor" yaml:"parallelizationFactor"`
	// Allow functions to return partially successful responses for a batch of records.
	// See: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting
	//
	// Experimental.
	ReportBatchItemFailures *bool `json:"reportBatchItemFailures" yaml:"reportBatchItemFailures"`
	// Maximum number of retry attempts Valid Range: * Minimum value of 0 * Maximum value of 10000.
	// Experimental.
	RetryAttempts *float64 `json:"retryAttempts" yaml:"retryAttempts"`
	// The size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.
	// Experimental.
	TumblingWindow awscdk.Duration `json:"tumblingWindow" yaml:"tumblingWindow"`
}

Example:

import kinesis "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type KinesisEventSource awscdk.KinesisEventSource

var myFunction function

stream := kinesis.NewStream(this, jsii.String("MyStream"))
myFunction.addEventSource(NewKinesisEventSource(stream, &kinesisEventSourceProps{
	batchSize: jsii.Number(100),
	 // default
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
}))

Experimental.

type ManagedKafkaEventSource

type ManagedKafkaEventSource interface {
	StreamEventSource
	// The identifier for this EventSourceMapping.
	// Experimental.
	EventSourceMappingId() *string
	// Experimental.
	Props() *StreamEventSourceProps
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
	// Experimental.
	EnrichMappingOptions(options *awslambda.EventSourceMappingOptions) *awslambda.EventSourceMappingOptions
}

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

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"type Secret awscdk.Secretimport awscdk "github.com/aws/aws-cdk-go/awscdk"type ManagedKafkaEventSource awscdk.ManagedKafkaEventSource

var myFunction function

// Your MSK cluster arn
clusterArn := "arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4"

// The Kafka topic you want to subscribe to
topic := "some-cool-topic"

// The secret that allows access to your MSK cluster
// You still have to make sure that it is associated with your cluster as described in the documentation
secret := NewSecret(this, jsii.String("Secret"), &secretProps{
	secretName: jsii.String("AmazonMSK_KafkaSecret"),
})
myFunction.addEventSource(NewManagedKafkaEventSource(&managedKafkaEventSourceProps{
	clusterArn: jsii.String(clusterArn),
	topic: topic,
	secret: secret,
	batchSize: jsii.Number(100),
	 // default
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
}))

Experimental.

func NewManagedKafkaEventSource

func NewManagedKafkaEventSource(props *ManagedKafkaEventSourceProps) ManagedKafkaEventSource

Experimental.

type ManagedKafkaEventSourceProps

type ManagedKafkaEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// The Kafka topic to subscribe to.
	// Experimental.
	Topic *string `json:"topic" yaml:"topic"`
	// The secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet.
	// Experimental.
	Secret awssecretsmanager.ISecret `json:"secret" yaml:"secret"`
	// An MSK cluster construct.
	// Experimental.
	ClusterArn *string `json:"clusterArn" yaml:"clusterArn"`
}

Properties for a MSK event source.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"type Secret awscdk.Secretimport awscdk "github.com/aws/aws-cdk-go/awscdk"type ManagedKafkaEventSource awscdk.ManagedKafkaEventSource

var myFunction function

// Your MSK cluster arn
clusterArn := "arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4"

// The Kafka topic you want to subscribe to
topic := "some-cool-topic"

// The secret that allows access to your MSK cluster
// You still have to make sure that it is associated with your cluster as described in the documentation
secret := NewSecret(this, jsii.String("Secret"), &secretProps{
	secretName: jsii.String("AmazonMSK_KafkaSecret"),
})
myFunction.addEventSource(NewManagedKafkaEventSource(&managedKafkaEventSourceProps{
	clusterArn: jsii.String(clusterArn),
	topic: topic,
	secret: secret,
	batchSize: jsii.Number(100),
	 // default
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
}))

Experimental.

type S3EventSource

type S3EventSource interface {
	awslambda.IEventSource
	// Experimental.
	Bucket() awss3.Bucket
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
}

Use S3 bucket notifications as an event source for AWS Lambda.

Example:

import eventsources "github.com/aws/aws-cdk-go/awscdk"import s3 "github.com/aws/aws-cdk-go/awscdk"

var fn function
bucket := s3.NewBucket(this, jsii.String("Bucket"))
fn.addEventSource(eventsources.NewS3EventSource(bucket, &s3EventSourceProps{
	events: []eventType{
		s3.*eventType_OBJECT_CREATED,
		s3.*eventType_OBJECT_REMOVED,
	},
	filters: []notificationKeyFilter{
		&notificationKeyFilter{
			prefix: jsii.String("subdir/"),
		},
	},
}))

Experimental.

func NewS3EventSource

func NewS3EventSource(bucket awss3.Bucket, props *S3EventSourceProps) S3EventSource

Experimental.

type S3EventSourceProps

type S3EventSourceProps struct {
	// The s3 event types that will trigger the notification.
	// Experimental.
	Events *[]awss3.EventType `json:"events" yaml:"events"`
	// S3 object key filter rules to determine which objects trigger this event.
	//
	// Each filter must include a `prefix` and/or `suffix` that will be matched
	// against the s3 object key. Refer to the S3 Developer Guide for details
	// about allowed filter rules.
	// Experimental.
	Filters *[]*awss3.NotificationKeyFilter `json:"filters" yaml:"filters"`
}

Example:

import eventsources "github.com/aws/aws-cdk-go/awscdk"import s3 "github.com/aws/aws-cdk-go/awscdk"

var fn function
bucket := s3.NewBucket(this, jsii.String("Bucket"))
fn.addEventSource(eventsources.NewS3EventSource(bucket, &s3EventSourceProps{
	events: []eventType{
		s3.*eventType_OBJECT_CREATED,
		s3.*eventType_OBJECT_REMOVED,
	},
	filters: []notificationKeyFilter{
		&notificationKeyFilter{
			prefix: jsii.String("subdir/"),
		},
	},
}))

Experimental.

type SelfManagedKafkaEventSource

type SelfManagedKafkaEventSource interface {
	StreamEventSource
	// Experimental.
	Props() *StreamEventSourceProps
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
	// Experimental.
	EnrichMappingOptions(options *awslambda.EventSourceMappingOptions) *awslambda.EventSourceMappingOptions
}

Use a self hosted Kafka installation as a streaming source for AWS Lambda.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"type Secret awscdk.Secretimport awscdk "github.com/aws/aws-cdk-go/awscdk"type SelfManagedKafkaEventSource awscdk.SelfManagedKafkaEventSource

// The secret that allows access to your self hosted Kafka cluster
var secret secret

var myFunction function

// The list of Kafka brokers
bootstrapServers := []*string{
	"kafka-broker:9092",
}

// The Kafka topic you want to subscribe to
topic := "some-cool-topic"
myFunction.addEventSource(NewSelfManagedKafkaEventSource(&selfManagedKafkaEventSourceProps{
	bootstrapServers: bootstrapServers,
	topic: topic,
	secret: secret,
	batchSize: jsii.Number(100),
	 // default
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
}))

Experimental.

func NewSelfManagedKafkaEventSource

func NewSelfManagedKafkaEventSource(props *SelfManagedKafkaEventSourceProps) SelfManagedKafkaEventSource

Experimental.

type SelfManagedKafkaEventSourceProps

type SelfManagedKafkaEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// The Kafka topic to subscribe to.
	// Experimental.
	Topic *string `json:"topic" yaml:"topic"`
	// The secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet.
	// Experimental.
	Secret awssecretsmanager.ISecret `json:"secret" yaml:"secret"`
	// The list of host and port pairs that are the addresses of the Kafka brokers in a "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.
	//
	// They are in the format `abc.xyz.com:xxxx`.
	// Experimental.
	BootstrapServers *[]*string `json:"bootstrapServers" yaml:"bootstrapServers"`
	// The authentication method for your Kafka cluster.
	// Experimental.
	AuthenticationMethod AuthenticationMethod `json:"authenticationMethod" yaml:"authenticationMethod"`
	// If your Kafka brokers are only reachable via VPC, provide the security group here.
	// Experimental.
	SecurityGroup awsec2.ISecurityGroup `json:"securityGroup" yaml:"securityGroup"`
	// If your Kafka brokers are only reachable via VPC provide the VPC here.
	// Experimental.
	Vpc awsec2.IVpc `json:"vpc" yaml:"vpc"`
	// If your Kafka brokers are only reachable via VPC, provide the subnets selection here.
	// Experimental.
	VpcSubnets *awsec2.SubnetSelection `json:"vpcSubnets" yaml:"vpcSubnets"`
}

Properties for a self managed Kafka cluster event source.

If your Kafka cluster is only reachable via VPC make sure to configure it.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"type Secret awscdk.Secretimport awscdk "github.com/aws/aws-cdk-go/awscdk"type SelfManagedKafkaEventSource awscdk.SelfManagedKafkaEventSource

// The secret that allows access to your self hosted Kafka cluster
var secret secret

var myFunction function

// The list of Kafka brokers
bootstrapServers := []*string{
	"kafka-broker:9092",
}

// The Kafka topic you want to subscribe to
topic := "some-cool-topic"
myFunction.addEventSource(NewSelfManagedKafkaEventSource(&selfManagedKafkaEventSourceProps{
	bootstrapServers: bootstrapServers,
	topic: topic,
	secret: secret,
	batchSize: jsii.Number(100),
	 // default
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
}))

Experimental.

type SnsDlq

type SnsDlq interface {
	awslambda.IEventSourceDlq
	// Returns a destination configuration for the DLQ.
	// Experimental.
	Bind(_target awslambda.IEventSourceMapping, targetHandler awslambda.IFunction) *awslambda.DlqDestinationConfig
}

An SNS dead letter queue destination configuration for a Lambda event source.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda_event_sources "github.com/aws/aws-cdk-go/awscdk/aws_lambda_event_sources"import awscdk "github.com/aws/aws-cdk-go/awscdk"import sns "github.com/aws/aws-cdk-go/awscdk/aws_sns"

var topic topic
snsDlq := lambda_event_sources.NewSnsDlq(topic)

Experimental.

func NewSnsDlq

func NewSnsDlq(topic awssns.ITopic) SnsDlq

Experimental.

type SnsEventSource

type SnsEventSource interface {
	awslambda.IEventSource
	// Experimental.
	Topic() awssns.ITopic
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
}

Use an Amazon SNS topic as an event source for AWS Lambda.

Example:

import sns "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type SnsEventSource awscdk.SnsEventSource

var topic topic

var fn function
deadLetterQueue := sqs.NewQueue(this, jsii.String("deadLetterQueue"))
fn.addEventSource(NewSnsEventSource(topic, &snsEventSourceProps{
	filterPolicy: map[string]interface{}{
	},
	deadLetterQueue: deadLetterQueue,
}))

Experimental.

func NewSnsEventSource

func NewSnsEventSource(topic awssns.ITopic, props *SnsEventSourceProps) SnsEventSource

Experimental.

type SnsEventSourceProps

type SnsEventSourceProps struct {
	// Queue to be used as dead letter queue.
	//
	// If not passed no dead letter queue is enabled.
	// Experimental.
	DeadLetterQueue awssqs.IQueue `json:"deadLetterQueue" yaml:"deadLetterQueue"`
	// The filter policy.
	// Experimental.
	FilterPolicy *map[string]awssns.SubscriptionFilter `json:"filterPolicy" yaml:"filterPolicy"`
}

Properties forwarded to the Lambda Subscription.

Example:

import sns "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type SnsEventSource awscdk.SnsEventSource

var topic topic

var fn function
deadLetterQueue := sqs.NewQueue(this, jsii.String("deadLetterQueue"))
fn.addEventSource(NewSnsEventSource(topic, &snsEventSourceProps{
	filterPolicy: map[string]interface{}{
	},
	deadLetterQueue: deadLetterQueue,
}))

Experimental.

type SqsDlq

type SqsDlq interface {
	awslambda.IEventSourceDlq
	// Returns a destination configuration for the DLQ.
	// Experimental.
	Bind(_target awslambda.IEventSourceMapping, targetHandler awslambda.IFunction) *awslambda.DlqDestinationConfig
}

An SQS dead letter queue destination configuration for a Lambda event source.

Example:

import dynamodb "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"type DynamoEventSource awscdk.DynamoEventSource
type SqsDlq awscdk.SqsDlq

var table table

var fn function

deadLetterQueue := sqs.NewQueue(this, jsii.String("deadLetterQueue"))
fn.addEventSource(NewDynamoEventSource(table, &dynamoEventSourceProps{
	startingPosition: lambda.startingPosition_TRIM_HORIZON,
	batchSize: jsii.Number(5),
	bisectBatchOnError: jsii.Boolean(true),
	onFailure: NewSqsDlq(deadLetterQueue),
	retryAttempts: jsii.Number(10),
}))

Experimental.

func NewSqsDlq

func NewSqsDlq(queue awssqs.IQueue) SqsDlq

Experimental.

type SqsEventSource

type SqsEventSource interface {
	awslambda.IEventSource
	// The identifier for this EventSourceMapping.
	// Experimental.
	EventSourceMappingId() *string
	// Experimental.
	Queue() awssqs.IQueue
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(target awslambda.IFunction)
}

Use an Amazon SQS queue as an event source for AWS Lambda.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"type SqsEventSource awscdk.SqsEventSource

var fn function
queue := sqs.NewQueue(this, jsii.String("MyQueue"))
eventSource := NewSqsEventSource(queue)
fn.addEventSource(eventSource)

eventSourceId := eventSource.eventSourceMappingId

Experimental.

func NewSqsEventSource

func NewSqsEventSource(queue awssqs.IQueue, props *SqsEventSourceProps) SqsEventSource

Experimental.

type SqsEventSourceProps

type SqsEventSourceProps struct {
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range: Minimum value of 1. Maximum value of 10.
	// If `maxBatchingWindow` is configured, this value can go up to 10,000.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the SQS event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Valid Range: Minimum value of 0 minutes. Maximum value of 5 minutes.
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// Allow functions to return partially successful responses for a batch of records.
	// See: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting
	//
	// Experimental.
	ReportBatchItemFailures *bool `json:"reportBatchItemFailures" yaml:"reportBatchItemFailures"`
}

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"type SqsEventSource awscdk.SqsEventSource
var fn function

queue := sqs.NewQueue(this, jsii.String("MyQueue"), &queueProps{
	visibilityTimeout: duration.seconds(jsii.Number(30)),
	 // default,
	receiveMessageWaitTime: *duration.seconds(jsii.Number(20)),
})

fn.addEventSource(NewSqsEventSource(queue, &sqsEventSourceProps{
	batchSize: jsii.Number(10),
	 // default
	maxBatchingWindow: *duration.minutes(jsii.Number(5)),
	reportBatchItemFailures: jsii.Boolean(true),
}))

Experimental.

type StreamEventSource

type StreamEventSource interface {
	awslambda.IEventSource
	// Experimental.
	Props() *StreamEventSourceProps
	// Called by `lambda.addEventSource` to allow the event source to bind to this function.
	// Experimental.
	Bind(_target awslambda.IFunction)
	// Experimental.
	EnrichMappingOptions(options *awslambda.EventSourceMappingOptions) *awslambda.EventSourceMappingOptions
}

Use an stream as an event source for AWS Lambda. Experimental.

type StreamEventSourceProps

type StreamEventSourceProps struct {
	// Where to begin consuming the stream.
	// Experimental.
	StartingPosition awslambda.StartingPosition `json:"startingPosition" yaml:"startingPosition"`
	// The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
	//
	// Your function receives an
	// event with all the retrieved records.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of:
	//    * 1000 for {@link DynamoEventSource}
	// * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource}.
	// Experimental.
	BatchSize *float64 `json:"batchSize" yaml:"batchSize"`
	// If the stream event source mapping should be enabled.
	// Experimental.
	Enabled *bool `json:"enabled" yaml:"enabled"`
	// The maximum amount of time to gather records before invoking the function.
	//
	// Maximum of Duration.minutes(5)
	// Experimental.
	MaxBatchingWindow awscdk.Duration `json:"maxBatchingWindow" yaml:"maxBatchingWindow"`
	// If the function returns an error, split the batch in two and retry.
	// Experimental.
	BisectBatchOnError *bool `json:"bisectBatchOnError" yaml:"bisectBatchOnError"`
	// The maximum age of a record that Lambda sends to a function for processing.
	//
	// Valid Range:
	// * Minimum value of 60 seconds
	// * Maximum value of 7 days.
	// Experimental.
	MaxRecordAge awscdk.Duration `json:"maxRecordAge" yaml:"maxRecordAge"`
	// An Amazon SQS queue or Amazon SNS topic destination for discarded records.
	// Experimental.
	OnFailure awslambda.IEventSourceDlq `json:"onFailure" yaml:"onFailure"`
	// The number of batches to process from each shard concurrently.
	//
	// Valid Range:
	// * Minimum value of 1
	// * Maximum value of 10.
	// Experimental.
	ParallelizationFactor *float64 `json:"parallelizationFactor" yaml:"parallelizationFactor"`
	// Allow functions to return partially successful responses for a batch of records.
	// See: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting
	//
	// Experimental.
	ReportBatchItemFailures *bool `json:"reportBatchItemFailures" yaml:"reportBatchItemFailures"`
	// Maximum number of retry attempts Valid Range: * Minimum value of 0 * Maximum value of 10000.
	// Experimental.
	RetryAttempts *float64 `json:"retryAttempts" yaml:"retryAttempts"`
	// The size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.
	// Experimental.
	TumblingWindow awscdk.Duration `json:"tumblingWindow" yaml:"tumblingWindow"`
}

The set of properties for streaming event sources shared by Dynamo and Kinesis.

Example:

import monocdk "github.com/aws/aws-cdk-go/awscdk"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda "github.com/aws/aws-cdk-go/awscdk/aws_lambda"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda_event_sources "github.com/aws/aws-cdk-go/awscdk/aws_lambda_event_sources"

var duration duration
var eventSourceDlq iEventSourceDlq
streamEventSourceProps := &streamEventSourceProps{
	startingPosition: lambda.startingPosition_TRIM_HORIZON,

	// the properties below are optional
	batchSize: jsii.Number(123),
	bisectBatchOnError: jsii.Boolean(false),
	enabled: jsii.Boolean(false),
	maxBatchingWindow: duration,
	maxRecordAge: duration,
	onFailure: eventSourceDlq,
	parallelizationFactor: jsii.Number(123),
	reportBatchItemFailures: jsii.Boolean(false),
	retryAttempts: jsii.Number(123),
	tumblingWindow: duration,
}

Experimental.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL