cdkeventbridgepartnerprocessors

package module
v0.0.522 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Eventbridge SaaS Partner fURLs

View on Construct Hub

npm version PyPI version Go project version

This CDK Construct library provides CDK constructs for the 1st-party (i.e. developed by AWS) lambda fURL webhook receivers for:

  • GitHub
  • Stripe
  • Twilio

Usage Examples (Simplified)

These examples are consistent for all 3 primary exported constructs of this library:

  • GitHubEventProcessor
  • TwilioEventProcessor
  • StripeEventProcessor

Note: Click on the above View on Construct Hub button to view auto-generated examples in Python/Go

Typescript
import { GitHubEventProcessor } from 'cdk-eventbridge-partner-processors';
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { EventBus } from 'aws-cdk-lib/aws-events';
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';

export class MyStackWithABetterName extends Stack {
    constructor(scope: Construct, id: string, props: StackProps) {
        super(scope, id, props);

        // This library has no opinion on how you reference your EventBus,
        // It just needs to fulfill the IEventBus protocol
        const myEventBus = new EventBus(this, 'TheBestBusEver', {
            eventBusName: 'TheGreatestBus'
        });

        // This library has no opinion on how you reference your secret,
        // It just needs to fulfill the ISecret protocol
        const mySecret = Secret.fromSecretNameV2(this, 'MyNuclearCodeSecret', '/home/recipes/icbm')

        // Function will automatically receive permission to:
        // 1. Post events to the given bus
        // 2. Read the given secret
        const githubEventProcessor = new GitHubEventProcessor(this, 'GitHubProcessor', {
            eventBus: myEventBus,
            webhookSecret: mySecret,
            lambdaInvocationAlarmThreshold: 2000,
        })

    }
}
Golang
package main

import (
	partner "github.com/a-bigelow/cdk-eventbridge-partner-processors-go"
	"github.com/aws/aws-cdk-go/awscdk/v2"
	"github.com/aws/aws-cdk-go/awscdk/v2/awsevents"
	"github.com/aws/constructs-go/constructs/v10"
	"github.com/aws/jsii-runtime-go"
)

type ClusterStackProps struct {
	awscdk.StackProps
}

func NewClusterStack(scope constructs.Construct, id string, props *ClusterStackProps) awscdk.Stack {
	var sprops awscdk.StackProps
	if props != nil {
		sprops = props.StackProps
	}
	stack := awscdk.NewStack(scope, &id, &sprops)

	// The code that defines your stack goes here
	eventProps := awsevents.EventBusProps{EventBusName: jsii.String("name")}

	eventBus := awsevents.NewEventBus(stack, jsii.String("id"), &eventProps)

	secret := secretsmanager.secret.fromSecretNameV2(scope, jsii.String("secret"), jsii.String("secretName"))
	partnerProcessor := partner.GithubEventProcessor{
		EventBus:                       eventBus,
		WebhookSecret:                  secret,
		LambdaInvocationAlarmThreshold: 2000,
	}

	_ = partner.NewGitHubEventProcessor(stack, jsii.String("id"), partnerProcessor)

	return stack
}
Disclaimer

⚠ The Lambda Functions that handle the actual event processing in this Library are owned and maintained by Amazon Web Services. This CDK Construct library provides a thin deployment wrapper for these functions. Changes made to the S3 location of the functions will break this library. Until I have a way to deterministically track where these things are, please raise an issue if you have reason to believe that the functions have moved.

AWS Documentation

See here for additional information.

Documentation

Overview

cdk-eventbridge-partner-processors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitHubEventProcessor_IsConstruct

func GitHubEventProcessor_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func InvocationAlarm_IsConstruct

func InvocationAlarm_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NewGitHubEventProcessor_Override

func NewGitHubEventProcessor_Override(g GitHubEventProcessor, scope constructs.Construct, id *string, props *GitHubProps)

func NewInvocationAlarm_Override

func NewInvocationAlarm_Override(i InvocationAlarm, scope constructs.Construct, id *string, props *InvocationAlarmProps)

func NewPartnerProcessor_Override

func NewPartnerProcessor_Override(p PartnerProcessor, scope constructs.Construct, id *string, props *PartnerFunctionProps)

func NewStripeEventProcessor_Override

func NewStripeEventProcessor_Override(s StripeEventProcessor, scope constructs.Construct, id *string, props *StripeProps)

func NewTwilioEventProcessor_Override

func NewTwilioEventProcessor_Override(t TwilioEventProcessor, scope constructs.Construct, id *string, props *TwilioProps)

func PartnerProcessor_IsConstruct

func PartnerProcessor_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func StripeEventProcessor_IsConstruct

func StripeEventProcessor_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func TwilioEventProcessor_IsConstruct

func TwilioEventProcessor_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

Types

type GitHubEventProcessor

type GitHubEventProcessor interface {
	PartnerProcessor
	InvocationAlarm() InvocationAlarm
	SetInvocationAlarm(val InvocationAlarm)
	// The tree node.
	Node() constructs.Node
	PartnerEventsFunction() awslambda.Function
	SetPartnerEventsFunction(val awslambda.Function)
	// Returns a string representation of this construct.
	ToString() *string
}

CDK wrapper for the GitHub Eventbridge processor. See: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas-furls.html#furls-connection-github

func NewGitHubEventProcessor

func NewGitHubEventProcessor(scope constructs.Construct, id *string, props *GitHubProps) GitHubEventProcessor

type GitHubProps

type GitHubProps struct {
	// Eventbus to send GitHub events to.
	EventBus awsevents.IEventBus `field:"required" json:"eventBus" yaml:"eventBus"`
	// Maximum number of concurrent invocations on the fURL function before triggering the alarm.
	LambdaInvocationAlarmThreshold *float64 `field:"required" json:"lambdaInvocationAlarmThreshold" yaml:"lambdaInvocationAlarmThreshold"`
	// SM Secret containing the secret string used to validate webhook events.
	WebhookSecret awssecretsmanager.ISecret `field:"required" json:"webhookSecret" yaml:"webhookSecret"`
}

type InvocationAlarm

type InvocationAlarm interface {
	constructs.Construct
	// The tree node.
	Node() constructs.Node
	// Returns a string representation of this construct.
	ToString() *string
}

Cloudwatch Alarm used across this construct library.

func NewInvocationAlarm

func NewInvocationAlarm(scope constructs.Construct, id *string, props *InvocationAlarmProps) InvocationAlarm

type InvocationAlarmProps

type InvocationAlarmProps struct {
	// The function to monitor.
	EventFunction awslambda.IFunction `field:"required" json:"eventFunction" yaml:"eventFunction"`
	// Lambda Invocation threshold.
	Threshold *float64 `field:"required" json:"threshold" yaml:"threshold"`
}

type Partner

type Partner string

Supported partners with fURL integrations.

const (
	Partner_GITHUB Partner = "GITHUB"
	Partner_STRIPE Partner = "STRIPE"
	Partner_TWILIO Partner = "TWILIO"
)

type PartnerFunctionProps

type PartnerFunctionProps struct {
	// The partner to create an events processor for.
	EventbridgePartner Partner `field:"required" json:"eventbridgePartner" yaml:"eventbridgePartner"`
	// Eventbus to send Partner events to.
	EventBus awsevents.IEventBus `field:"required" json:"eventBus" yaml:"eventBus"`
	// Maximum number of concurrent invocations on the fURL function before triggering the alarm.
	LambdaInvocationAlarmThreshold *float64 `field:"required" json:"lambdaInvocationAlarmThreshold" yaml:"lambdaInvocationAlarmThreshold"`
	// SM Secret containing the secret string used to validate webhook events.
	WebhookSecret awssecretsmanager.ISecret `field:"required" json:"webhookSecret" yaml:"webhookSecret"`
}

type PartnerProcessor

type PartnerProcessor interface {
	constructs.Construct
	InvocationAlarm() InvocationAlarm
	SetInvocationAlarm(val InvocationAlarm)
	// The tree node.
	Node() constructs.Node
	PartnerEventsFunction() awslambda.Function
	SetPartnerEventsFunction(val awslambda.Function)
	// Returns a string representation of this construct.
	ToString() *string
}

Abstract class for Lambda-driven Eventbridge integrations.

This only works because the pattern for the S3 Keys lines up to: lambda-templates/<partner>-lambdasrc.zip See: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas-furls.html

type StripeEventProcessor

type StripeEventProcessor interface {
	PartnerProcessor
	InvocationAlarm() InvocationAlarm
	SetInvocationAlarm(val InvocationAlarm)
	// The tree node.
	Node() constructs.Node
	PartnerEventsFunction() awslambda.Function
	SetPartnerEventsFunction(val awslambda.Function)
	// Returns a string representation of this construct.
	ToString() *string
}

CDK wrapper for the Stripe Eventbridge processor. See: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas-furls.html#furls-connection-github

func NewStripeEventProcessor

func NewStripeEventProcessor(scope constructs.Construct, id *string, props *StripeProps) StripeEventProcessor

type StripeProps

type StripeProps struct {
	// Eventbus to send GitHub events to.
	EventBus awsevents.IEventBus `field:"required" json:"eventBus" yaml:"eventBus"`
	// Maximum number of concurrent invocations on the fURL function before triggering the alarm.
	LambdaInvocationAlarmThreshold *float64 `field:"required" json:"lambdaInvocationAlarmThreshold" yaml:"lambdaInvocationAlarmThreshold"`
	// SM Secret containing the secret string used to validate webhook events.
	WebhookSecret awssecretsmanager.ISecret `field:"required" json:"webhookSecret" yaml:"webhookSecret"`
}

type TwilioEventProcessor

type TwilioEventProcessor interface {
	PartnerProcessor
	InvocationAlarm() InvocationAlarm
	SetInvocationAlarm(val InvocationAlarm)
	// The tree node.
	Node() constructs.Node
	PartnerEventsFunction() awslambda.Function
	SetPartnerEventsFunction(val awslambda.Function)
	// Returns a string representation of this construct.
	ToString() *string
}

CDK wrapper for the Twilio Eventbridge processor. See: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas-furls.html#furls-connection-github

func NewTwilioEventProcessor

func NewTwilioEventProcessor(scope constructs.Construct, id *string, props *TwilioProps) TwilioEventProcessor

type TwilioProps

type TwilioProps struct {
	// Eventbus to send GitHub events to.
	EventBus awsevents.IEventBus `field:"required" json:"eventBus" yaml:"eventBus"`
	// Maximum number of concurrent invocations on the fURL function before triggering the alarm.
	LambdaInvocationAlarmThreshold *float64 `field:"required" json:"lambdaInvocationAlarmThreshold" yaml:"lambdaInvocationAlarmThreshold"`
	// SM Secret containing the secret string used to validate webhook events.
	WebhookSecret awssecretsmanager.ISecret `field:"required" json:"webhookSecret" yaml:"webhookSecret"`
}

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

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