{"id":8890,"library":"cdk-events-notify","title":"Events Notify AWS Construct for AWS CDK","description":"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.","status":"active","version":"2.2.767","language":"en","source_language":"en","source_url":"https://github.com/neilkuan/cdk-events-notify.git","tags":["aws-cdk","event-driven","notifications","slack","line-notify","cloudtrail","security"],"install":[{"cmd":"pip install cdk-events-notify","lang":"bash","label":"Install for AWS CDK v2"}],"dependencies":[{"reason":"Core AWS CDK v2 library for defining cloud infrastructure.","package":"aws-cdk-lib","optional":false},{"reason":"Base constructs library for AWS CDK.","package":"constructs","optional":false}],"imports":[{"note":"The primary construct `EventNotify` is typically imported directly from the `cdk_events_notify` package, not as a submodule.","wrong":"import cdk_events_notify","symbol":"EventNotify","correct":"from cdk_events_notify import EventNotify"},{"note":"AWS CDK v2 consolidates core modules into `aws_cdk` directly, removing the `core` submodule path used in v1.","wrong":"from aws_cdk.core import Stack","symbol":"Stack","correct":"from aws_cdk import Stack, Environment"}],"quickstart":{"code":"import os\nimport aws_cdk as cdk\nfrom constructs import Construct\nfrom cdk_events_notify import EventNotify\n\nclass MyEventNotifyStack(cdk.Stack):\n    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        # Retrieve Line Notify Token from environment variable for security\n        line_notify_token = os.environ.get('LINE_NOTIFY_TOKEN', '')\n        if not line_notify_token:\n            raise ValueError(\"LINE_NOTIFY_TOKEN environment variable is not set.\")\n\n        # Create an EventNotify construct for Line notifications\n        EventNotify(self, 'LineEventNotify', \n                    line_notify_token=line_notify_token)\n\napp = cdk.App()\nMyEventNotifyStack(app, 'MyEventNotifyStack',\n                     env=cdk.Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT'),\n                                         region=os.environ.get('CDK_DEFAULT_REGION'))\n                    )\napp.synth()","lang":"python","description":"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."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":"<2.x.x"},{"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.","message":"AWS 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"A `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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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`.","cause":"The `cdk-events-notify` package is not installed in your Python environment or the virtual environment activated for your CDK project.","error":"ModuleNotFoundError: No module named 'cdk_events_notify'"},{"fix":"Set the `LINE_NOTIFY_TOKEN` environment variable before running `cdk deploy` or `cdk synth`. For example: `export LINE_NOTIFY_TOKEN='your-token-here'`.","cause":"The provided quickstart code explicitly checks for the `LINE_NOTIFY_TOKEN` environment variable and raises an error if it's missing.","error":"ValueError: LINE_NOTIFY_TOKEN environment variable is not set."},{"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.","cause":"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.","error":"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."}]}