Registry / aws / cdk-events-notify

cdk-events-notify

JSON →
library2.3.53pypypi✓ verified 87d ago

cdk-events-notify is an AWS CDK Construct Library (currently v2.2.767) that provides a mechanism to trigger Lambda functions for push notifications to Line Notify or Slack. It primarily focuses on detecting AWS Console Login or switch role events via CloudTrail. The library is actively maintained with frequent updates, as indicated by its versioning and recent activity on PyPI and GitHub.

pip install cdk-events-notify
INSTALL
IMPORT
SIG · CDK-EVENTS-NOTIFY
C
cdk-events-notify
awspythonv2.3.53
Install
17.6s avg
Import
Disk
397MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.53 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 359.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 17.6s · import 0.000s · 360MB
397MB installed
● package 397MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EventNotify
from cdk_events_notify import EventNotify
import cdk_events_notify
The primary construct `EventNotify` is typically imported directly from the `cdk_events_notify` package, not as a submodule.
Stack
from aws_cdk import Stack, Environment
from aws_cdk.core import Stack
AWS CDK v2 consolidates core modules into `aws_cdk` directly, removing the `core` submodule path used in v1.

This quickstart demonstrates how to set up `cdk-events-notify` to send notifications to Line Notify for AWS console login events. It requires setting the `LINE_NOTIFY_TOKEN` environment variable and deploying the CDK stack. Ensure you have CloudTrail management events enabled for your account.

import os import aws_cdk as cdk from constructs import Construct from cdk_events_notify import EventNotify class MyEventNotifyStack(cdk.Stack): def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: super().__init__(scope, construct_id, **kwargs) # Retrieve Line Notify Token from environment variable for security line_notify_token = os.environ.get('LINE_NOTIFY_TOKEN', '') if not line_notify_token: raise ValueError("LINE_NOTIFY_TOKEN environment variable is not set.") # Create an EventNotify construct for Line notifications EventNotify(self, 'LineEventNotify', line_notify_token=line_notify_token) app = cdk.App() MyEventNotifyStack(app, 'MyEventNotifyStack', env=cdk.Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT'), region=os.environ.get('CDK_DEFAULT_REGION')) ) app.synth()
Debug
Known issues
breakingThis library is designed for AWS CDK v2. While previous versions might have supported CDK v1, AWS CDK v1 has reached End-of-Support. Using `cdk-events-notify` with CDK v1 is not recommended and may lead to compatibility issues or missing features.
fix
Migrate your AWS CDK application to v2 and ensure `cdk-events-notify` is installed for v2. Refer to the official AWS CDK migration guide.
affects: <2.x.x
gotchaAWS EventBridge, which `cdk-events-notify` relies on for event detection, is a regional service. If a console sign-in or role switch event occurs in a different AWS region than where your `cdk-events-notify` stack is deployed, the event will not be captured and notifications will not be sent.
fix
Deploy `cdk-events-notify` stacks in each region where you expect to receive console login/switch role events, or ensure your CloudTrail configuration aggregates events to a central region where the stack is deployed.
affects: All
gotchaA `LINE_NOTIFY_TOKEN` or Slack webhook URL is required for notifications to function. The quickstart example demonstrates passing this as an environment variable, which is a common pattern for sensitive information.
fix
Ensure `LINE_NOTIFY_TOKEN` or relevant Slack webhook configuration is provided to the `EventNotify` construct. Use AWS Secrets Manager or environment variables, avoiding hardcoding sensitive values.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cdk_events_notify'
The `cdk-events-notify` package is not installed in your Python environment or the virtual environment activated for your CDK project.
fix
Run `pip install cdk-events-notify` in your project's Python virtual environment. If using a `requirements.txt`, ensure it's listed and run `pip install -r requirements.txt`.
ValueError: LINE_NOTIFY_TOKEN environment variable is not set.
The provided quickstart code explicitly checks for the `LINE_NOTIFY_TOKEN` environment variable and raises an error if it's missing.
fix
Set the `LINE_NOTIFY_TOKEN` environment variable before running `cdk deploy` or `cdk synth`. For example: `export LINE_NOTIFY_TOKEN='your-token-here'`.
Error: 'MyStack' depends on 'AnotherStack' (Depends on Lambda resources., Depends on resources.). Adding this dependency (AnotherStack -> MyStack/MyConstruct/Resource.Arn) would create a cyclic reference.
While not directly related to `cdk-events-notify` specifically, this is a common AWS CDK error when creating event notification patterns (like those implicitly handled by `cdk-events-notify` or explicitly with `aws-events`) between different stacks in a way that creates a circular dependency in CloudFormation.
fix
Refactor your CDK application to avoid circular dependencies. This might involve combining resources into a single stack, using existing resources via `from_lookup` methods, or leveraging custom resources for advanced scenarios where native CDK constructs create circular references.
Upgrade
Version history
2.3.53latest on PyPI · released Jun 13, 2026
Audit
Dependencies
aws-cdk-librequiredCore AWS CDK v2 library for defining cloud infrastructure.
constructsrequiredBase constructs library for AWS CDK.
Agent activity
32 hits · last 30 days
node
30
OpenAI (training)
1
Resources