Socket
Socket
Sign inDemoInstall

@aws-cdk/aws-events

Package Overview
Dependencies
Maintainers
5
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-events

AWS CloudWatch Events Construct Library


Version published
Weekly downloads
70K
decreased by-53.75%
Maintainers
5
Weekly downloads
 
Created

What is @aws-cdk/aws-events?

@aws-cdk/aws-events is an AWS Cloud Development Kit (CDK) library that allows you to define and manage Amazon EventBridge resources using code. EventBridge is a serverless event bus that makes it easier to build event-driven applications by connecting application data from your own applications, integrated Software-as-a-Service (SaaS) applications, and AWS services.

What are @aws-cdk/aws-events's main functionalities?

Creating an Event Bus

This code sample demonstrates how to create a new EventBridge event bus using the AWS CDK. The event bus can be used to receive and route events.

const events = require('@aws-cdk/aws-events');
const cdk = require('@aws-cdk/core');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'EventBusStack');

const eventBus = new events.EventBus(stack, 'MyEventBus', {
  eventBusName: 'my-event-bus'
});

app.synth();

Creating a Rule

This code sample demonstrates how to create an EventBridge rule that triggers when an EC2 instance changes state to 'running'. The rule targets a Lambda function.

const events = require('@aws-cdk/aws-events');
const targets = require('@aws-cdk/aws-events-targets');
const cdk = require('@aws-cdk/core');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'EventRuleStack');

const rule = new events.Rule(stack, 'MyRule', {
  eventPattern: {
    source: ['aws.ec2'],
    detailType: ['EC2 Instance State-change Notification'],
    detail: {
      state: ['running']
    }
  }
});

rule.addTarget(new targets.LambdaFunction(myLambdaFunction));

app.synth();

Scheduling Events

This code sample demonstrates how to create a scheduled EventBridge rule that triggers every 5 minutes. The rule targets a Lambda function.

const events = require('@aws-cdk/aws-events');
const targets = require('@aws-cdk/aws-events-targets');
const cdk = require('@aws-cdk/core');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'ScheduledEventStack');

const rule = new events.Rule(stack, 'MyScheduledRule', {
  schedule: events.Schedule.rate(cdk.Duration.minutes(5))
});

rule.addTarget(new targets.LambdaFunction(myLambdaFunction));

app.synth();

Other packages similar to @aws-cdk/aws-events

Keywords

FAQs

Package last updated on 19 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc