{"id":7950,"library":"aws-cdk-aws-events","title":"AWS CDK Events (v1)","description":"The `aws-cdk-aws-events` library provides constructs for defining Amazon EventBridge resources in AWS CDK v1. It allows developers to programmatically create event buses, rules, targets, and schema registry resources using Python. This library is part of the AWS CDK v1 ecosystem, with the current version being 1.204.0, and receives updates aligned with AWS service releases and CDK v1 maintenance.","status":"active","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","events","eventbridge","infrastructure-as-code","cloud-infrastructure"],"install":[{"cmd":"pip install aws-cdk-aws-events aws-cdk","lang":"bash","label":"Install library and core CDK"}],"dependencies":[],"imports":[{"note":"CDK v1 construct libraries are imported as submodules of `aws_cdk`, not directly using their PyPI package name.","wrong":"import aws_cdk_aws_events","symbol":"aws_events","correct":"from aws_cdk import aws_events"}],"quickstart":{"code":"import aws_cdk as cdk\nfrom aws_cdk import aws_events\nfrom aws_cdk import aws_events_targets as targets\nfrom aws_cdk import aws_lambda as lambda_\n\nclass MyEventStack(cdk.Stack):\n    def __init__(self, scope: cdk.App, id: str, **kwargs) -> None:\n        super().__init__(scope, id, **kwargs)\n\n        # Define a simple Lambda function to be a target\n        my_lambda = lambda_.Function(\n            self, \"MyEventHandler\",\n            runtime=lambda_.Runtime.PYTHON_3_9,\n            handler=\"index.handler\",\n            code=lambda_.Code.from_inline(\"import json; def handler(event, context): print(json.dumps(event)); return 'OK'\")\n        )\n\n        # Create an EventBridge rule that triggers every 5 minutes\n        rule = aws_events.Rule(\n            self, \"MyScheduleRule\",\n            schedule=aws_events.Schedule.rate(cdk.Duration.minutes(5)),\n            description=\"Rule that triggers every 5 minutes\"\n        )\n\n        # Add the Lambda function as a target for the rule\n        rule.add_target(targets.LambdaFunction(my_lambda))\n\napp = cdk.App()\nMyEventStack(app, \"MyEventBridgeStack\")\napp.synth()","lang":"python","description":"This quickstart demonstrates how to create an EventBridge rule that triggers a Lambda function every 5 minutes using `aws-cdk-aws-events` within an AWS CDK v1 application. Run `cdk deploy` after `app.synth()` to deploy."},"warnings":[{"fix":"For new projects, install `aws-cdk-lib` and use v2 constructs. For existing v1 projects, consult the AWS CDK v2 migration guide before upgrading. Key changes include unified package imports (e.g., `from aws_cdk import aws_events` becomes `from aws_cdk_lib import aws_events`), removal of some L1 constructs, and updated construct signatures.","message":"AWS CDK v1 is in maintenance mode; new projects should use AWS CDK v2. Migrating from v1 to v2 involves significant breaking changes to package imports and construct APIs.","severity":"breaking","affected_versions":"All v1.x.x versions, when migrating to v2.x.x"},{"fix":"Ensure `app.synth()` is called at the end of your CDK application entry point. After synthesis, use the AWS CDK CLI command `cdk deploy` (and `cdk bootstrap` if this is your first deployment to an environment) to provision resources in your AWS account.","message":"Forgetting to call `app.synth()` or run `cdk deploy` will result in no CloudFormation template generation or AWS resource deployment.","severity":"gotcha","affected_versions":"All v1.x.x"},{"fix":"Review EventBridge documentation for best practices on event patterns and permissions. Use `aws_events.EventBus.from_event_bus_arn()` for existing buses and ensure `PolicyStatement` is correctly attached to allow `events:PutEvents` from source accounts/regions.","message":"When defining EventBridge rules for cross-account or cross-region events, ensure proper permissions are granted and event bus policies are correctly configured. A common mistake is restricting the `Detail` field too broadly, preventing events from matching.","severity":"gotcha","affected_versions":"All v1.x.x"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change `import aws_cdk_aws_events` to `from aws_cdk import aws_events`.","cause":"Incorrect import path. CDK v1 constructs are submodules of `aws_cdk`.","error":"ModuleNotFoundError: No module named 'aws_cdk_aws_events'"},{"fix":"Ensure `app.synth()` is called at the end of your CDK application entry point before attempting `cdk deploy`. Run `rm -rf cdk.out` if you suspect a stale output directory.","cause":"The `cdk.App` object's `synth()` method was not called, or the `cdk.out` directory is missing/stale.","error":"jsii.errors.JavaScriptError: The CDK app must be synthesized before it can be deployed."},{"fix":"Upgrade all `aws-cdk-*` packages to the same major and minor version. Use `pip install -U aws-cdk aws-cdk-aws-events aws-cdk-aws-lambda` (or other relevant packages) to ensure they are consistent.","cause":"Mismatched versions of core CDK library (`aws-cdk`) and construct libraries (e.g., `aws-cdk-aws-events`). All CDK v1 packages must be at the same major.minor version.","error":"You must use the same minor version of @aws-cdk/core and the construct libraries (e.g. aws-cdk-lib) - found @aws-cdk/core@1.100.0 and @aws-cdk/aws-events@1.204.0"}]}