{"id":7947,"library":"aws-cdk-aws-cloudwatch","title":"AWS CDK CloudWatch (v1)","description":"The `aws-cdk-aws-cloudwatch` library is part of the AWS Cloud Development Kit (CDK) v1, providing Python constructs for provisioning and managing AWS CloudWatch resources, including metrics, alarms, and dashboards. This specific package, version 1.204.0, was released on June 19, 2023. AWS CDK v1 officially reached End-of-Support on June 1, 2023, meaning it no longer receives maintenance, updates, patches, or technical support. Users are strongly recommended to migrate to AWS CDK v2.","status":"deprecated","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws-cdk","cloudwatch","iac","monitoring","deprecated"],"install":[{"cmd":"pip install aws-cdk.aws-cloudwatch aws-cdk.core","lang":"bash","label":"Install for CDK v1"},{"cmd":"pip install aws-cdk-lib","lang":"bash","label":"Install for CDK v2 (Recommended)"}],"dependencies":[{"reason":"Required core library for AWS CDK v1 applications.","package":"aws-cdk.core","optional":false},{"reason":"Core library for defining constructs in CDK.","package":"constructs","optional":false},{"reason":"Required for inter-language operability in CDK.","package":"jsii","optional":true},{"reason":"Required for runtime type checking in CDK's Python bindings.","package":"typeguard","optional":true}],"imports":[{"note":"For CDK v1, `aws_cdk` is the top-level namespace. `aws_cdk_lib` is part of CDK v2's consolidated package.","wrong":"from aws_cdk_lib import aws_cloudwatch","symbol":"aws_cloudwatch","correct":"from aws_cdk import aws_cloudwatch"},{"symbol":"Alarm","correct":"from aws_cdk.aws_cloudwatch import Alarm"},{"symbol":"Metric","correct":"from aws_cdk.aws_cloudwatch import Metric"}],"quickstart":{"code":"import os\nfrom aws_cdk import (\n    aws_cloudwatch as cw,\n    aws_sqs as sqs,\n    core as cdk\n)\n\nclass MyCloudWatchStack(cdk.Stack):\n    def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        queue = sqs.Queue(self, \"MyQueue\")\n\n        # Create a metric for the number of visible messages in the SQS queue\n        # Using a default SQS queue for demonstration purposes.\n        queue_metric = queue.metric_approximate_number_of_messages_visible(\n            period=cdk.Duration.minutes(5)\n        )\n\n        # Create an alarm if the number of visible messages exceeds 100\n        cw.Alarm(self, \"QueueHighMessagesAlarm\",\n            metric=queue_metric,\n            threshold=100,\n            evaluation_periods=1,\n            comparison_operator=cw.ComparisonOperator.GREATER_THAN_THRESHOLD,\n            alarm_description=\"Alarm when queue visible messages are too high\"\n        )\n\napp = cdk.App()\n# Specify account and region for deployment (optional, but good practice)\n# env = cdk.Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT'), region=os.environ.get('CDK_DEFAULT_REGION'))\nMyCloudWatchStack(app, \"CloudWatchV1Stack\")\napp.synth()\n","lang":"python","description":"This quickstart demonstrates how to create a basic AWS CloudWatch alarm using AWS CDK v1. It defines an SQS queue and sets up an alarm that triggers if the number of visible messages in the queue exceeds a specified threshold."},"warnings":[{"fix":"Migrate your CDK applications to AWS CDK v2 immediately. Refer to the official 'Migrating to AWS CDK v2' guide.","message":"AWS CDK v1 reached End-of-Support on June 1, 2023. It is no longer maintained, receives no updates, security patches, or technical support. Continuing to use v1 can expose your applications to security vulnerabilities and unaddressed bugs.","severity":"breaking","affected_versions":"<=1.204.0"},{"fix":"After installing `aws-cdk-lib`, update your import statements from `from aws_cdk import aws_service` (v1) to `from aws_cdk import aws_service` (v2), ensuring `aws_service` is imported from `aws_cdk-lib`. The `constructs` package is now a separate dependency.","message":"The AWS CDK v1 architecture uses separate PyPI packages for each AWS service (e.g., `aws-cdk.aws-cloudwatch`, `aws-cdk.aws-sqs`). AWS CDK v2 consolidates all stable constructs into a single package, `aws-cdk-lib`, simplifying dependency management but requiring import path changes.","severity":"breaking","affected_versions":"<=1.204.0"},{"fix":"Run `cdk bootstrap` with the AWS CDK v2 CLI installed (globally or locally via `npx aws-cdk bootstrap`). Ensure your CLI version is up-to-date with your `aws-cdk-lib` version.","message":"AWS CDK v2 requires a new 'modern' bootstrapping process for your AWS accounts. If you attempt to deploy v2 applications with an old v1 bootstrap, deployments will likely fail.","severity":"gotcha","affected_versions":"<=1.204.0"},{"fix":"Utilize CDK's context system, environment variables, or AWS SSM Parameter Store/Secrets Manager to dynamically reference values. Specify `env` property in your stacks for clarity.","message":"Hardcoding resource names, ARNs, and environment-specific details makes CDK applications non-portable and difficult to maintain across different environments (dev, staging, prod).","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update your global AWS CDK Toolkit to the latest v2 version: `npm update -g aws-cdk`. If you need multiple CLI versions, install a specific version locally with `npm install aws-cdk@2.x` and use `npx aws-cdk`.","cause":"The AWS CDK Toolkit (CLI) version is incompatible with the version of the CDK Construct Library used in your project.","error":"Error: The installed CDK Toolkit version (1.x.x) is older than the CDK library version (2.x.x) used in this app."},{"fix":"Bootstrap your AWS environment with the AWS CDK CLI: `cdk bootstrap aws://ACCOUNT-NUMBER/REGION`. Ensure you use a v2-compatible bootstrap if migrating.","cause":"Your AWS environment has not been bootstrapped, or the bootstrap stack is outdated, preventing the CDK from staging assets in an S3 bucket for deployment.","error":"CloudFormation Create Stack Failed: [AWS::S3::Bucket] No such bucket: cdk-xxxxxx-assets-xxxxxxxxx-us-east-1"},{"fix":"Consult the AWS CDK v2 migration guide and the specific construct's documentation. For `removal_policy`, ensure you are importing `RemovalPolicy` from `aws_cdk` (v2) or `aws_cdk.core` (v1) and that the argument name is correct for your CDK version. The v2 arguments are usually more consistent.","cause":"A common breaking change between CDK v1 and v2 is the change of keyword arguments for certain construct properties, such as `removal_policy` on resources like S3 Buckets or DynamoDB Tables. The argument might have moved or been renamed.","error":"TypeError: __init__ got an unexpected keyword argument 'removal_policy'"}]}