Event targets for Amazon EventBridge
Project description
Event Targets for Amazon EventBridge
---This library contains integration classes to send Amazon EventBridge to any
number of supported AWS Services. Instances of these classes should be passed
to the rule.addTarget()
method.
Currently supported are:
- Start a CodeBuild build
- Start a CodePipeline pipeline
- Run an ECS task
- Invoke a Lambda function
- Publish a message to an SNS topic
- Send a message to an SQS queue
- Start a StepFunctions state machine
- Queue a Batch job
- Make an AWS API call
- Put a record to a Kinesis stream
- Log an event into a LogGroup
- Put a record to a Kinesis Data Firehose stream
- Put an event on an EventBridge bus
See the README of the @aws-cdk/aws-events
library for more information on
EventBridge.
Invoke a Lambda function
Use the LambdaFunction
target to invoke a lambda function.
The code snippet below creates an event rule with a Lambda function as a target
triggered for every events from aws.ec2
source. You can optionally attach a
dead letter queue.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_events as events
import aws_cdk.aws_sqs as sqs
import aws_cdk.aws_events_targets as targets
fn = lambda_.Function(self, "MyFunc",
runtime=lambda_.Runtime.NODEJS_12_X,
handler="index.handler",
code=lambda_.Code.from_inline(f"exports.handler = {handler.toString()}")
)
rule = events.Rule(self, "rule",
event_pattern=EventPattern(
source=["aws.ec2"]
)
)
queue = sqs.Queue(self, "Queue")
rule.add_target(targets.LambdaFunction(fn,
dead_letter_queue=queue
))
Log an event into a LogGroup
Use the LogGroup
target to log your events in a CloudWatch LogGroup.
For example, the following code snippet creates an event rule with a CloudWatch LogGroup as a target.
Every events sent from the aws.ec2
source will be sent to the CloudWatch LogGroup.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_logs as logs
import aws_cdk.aws_events as events
import aws_cdk.aws_events_targets as targets
log_group = logs.LogGroup(self, "MyLogGroup",
log_group_name="MyLogGroup"
)
rule = events.Rule(self, "rule",
event_pattern=EventPattern(
source=["aws.ec2"]
)
)
rule.add_target(targets.CloudWatchLogGroup(log_group))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-events-targets-1.92.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd17b79e0c7173da23cfa80a81f64e8351184d7e9e83a655ea4f8ced4c9f991f |
|
MD5 | 676d059cfe0f3fc1da35fd9207113fb9 |
|
BLAKE2b-256 | 37801a0d08290225f9cc6526bb38c2c68fb8e13f180641b49e5519176b99d720 |
Hashes for aws_cdk.aws_events_targets-1.92.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0783c4e3142955756d34a99b9c6a3f0b556648565e1ae9de3013ff126baec354 |
|
MD5 | 1bcd1383bbd1f35ddf9b673c49d38307 |
|
BLAKE2b-256 | 3c19edb279857b0a134bc2d77b2aa966f26cbf0b9101c320016cb13adf25b42e |