awslambdadestinations

package
v2.21.1 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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventBridgeDestination_Override

func NewEventBridgeDestination_Override(e EventBridgeDestination, eventBus awsevents.IEventBus)

func NewLambdaDestination_Override

func NewLambdaDestination_Override(l LambdaDestination, fn awslambda.IFunction, options *LambdaDestinationOptions)

func NewSnsDestination_Override

func NewSnsDestination_Override(s SnsDestination, topic awssns.ITopic)

func NewSqsDestination_Override

func NewSqsDestination_Override(s SqsDestination, queue awssqs.IQueue)

Types

type EventBridgeDestination

type EventBridgeDestination interface {
	awslambda.IDestination
	// Returns a destination configuration.
	Bind(_scope constructs.Construct, fn awslambda.IFunction, _options *awslambda.DestinationOptions) *awslambda.DestinationConfig
}

Use an Event Bridge event bus as a Lambda destination.

If no event bus is specified, the default event bus is used.

Example:

import awscdk "github.com/aws/aws-cdk-go/awscdk"import events "github.com/aws/aws-cdk-go/awscdk/aws_events"import awscdk "github.com/aws/aws-cdk-go/awscdk"import lambda_destinations "github.com/aws/aws-cdk-go/awscdk/aws_lambda_destinations"

var eventBus eventBus
eventBridgeDestination := lambda_destinations.NewEventBridgeDestination(eventBus)

func NewEventBridgeDestination

func NewEventBridgeDestination(eventBus awsevents.IEventBus) EventBridgeDestination

type LambdaDestination

type LambdaDestination interface {
	awslambda.IDestination
	// Returns a destination configuration.
	Bind(scope constructs.Construct, fn awslambda.IFunction, options *awslambda.DestinationOptions) *awslambda.DestinationConfig
}

Use a Lambda function as a Lambda destination.

Example:

// Auto-extract response payload with a lambda destination
var destinationFn function

sourceFn := lambda.NewFunction(this, jsii.String("Source"), &functionProps{
	runtime: lambda.runtime_NODEJS_12_X(),
	handler: jsii.String("index.handler"),
	code: lambda.code.fromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
	// auto-extract on success
	onSuccess: destinations.NewLambdaDestination(destinationFn, &lambdaDestinationOptions{
		responseOnly: jsii.Boolean(true),
	}),
})

type LambdaDestinationOptions

type LambdaDestinationOptions struct {
	// Whether the destination function receives only the `responsePayload` of the source function.
	//
	// When set to `true` and used as `onSuccess` destination, the destination
	// function will be invoked with the payload returned by the source function.
	//
	// When set to `true` and used as `onFailure` destination, the destination
	// function will be invoked with the error object returned by source function.
	//
	// See the README of this module to see a full explanation of this option.
	ResponseOnly *bool `json:"responseOnly" yaml:"responseOnly"`
}

Options for a Lambda destination.

Example:

// Auto-extract response payload with a lambda destination
var destinationFn function

sourceFn := lambda.NewFunction(this, jsii.String("Source"), &functionProps{
	runtime: lambda.runtime_NODEJS_12_X(),
	handler: jsii.String("index.handler"),
	code: lambda.code.fromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
	// auto-extract on success
	onSuccess: destinations.NewLambdaDestination(destinationFn, &lambdaDestinationOptions{
		responseOnly: jsii.Boolean(true),
	}),
})

type SnsDestination

type SnsDestination interface {
	awslambda.IDestination
	// Returns a destination configuration.
	Bind(_scope constructs.Construct, fn awslambda.IFunction, _options *awslambda.DestinationOptions) *awslambda.DestinationConfig
}

Use a SNS topic as a Lambda destination.

Example:

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

myTopic := sns.NewTopic(this, jsii.String("Topic"))

myFn := lambda.NewFunction(this, jsii.String("Fn"), &functionProps{
	runtime: lambda.runtime_NODEJS_12_X(),
	handler: jsii.String("index.handler"),
	code: lambda.code.fromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
	// sns topic for successful invocations
	onSuccess: destinations.NewSnsDestination(myTopic),
})

func NewSnsDestination

func NewSnsDestination(topic awssns.ITopic) SnsDestination

type SqsDestination

type SqsDestination interface {
	awslambda.IDestination
	// Returns a destination configuration.
	Bind(_scope constructs.Construct, fn awslambda.IFunction, _options *awslambda.DestinationOptions) *awslambda.DestinationConfig
}

Use a SQS queue as a Lambda destination.

Example:

import sqs "github.com/aws/aws-cdk-go/awscdk"

deadLetterQueue := sqs.NewQueue(this, jsii.String("DeadLetterQueue"))

myFn := lambda.NewFunction(this, jsii.String("Fn"), &functionProps{
	runtime: lambda.runtime_NODEJS_12_X(),
	handler: jsii.String("index.handler"),
	code: lambda.code.fromInline(jsii.String("// your code")),
	// sqs queue for unsuccessful invocations
	onFailure: destinations.NewSqsDestination(deadLetterQueue),
})

func NewSqsDestination

func NewSqsDestination(queue awssqs.IQueue) SqsDestination

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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