AWS Security ChangesHomeSearch

AWS cdk documentation change

Service: cdk · 2026-03-07 · Documentation low

File: cdk/v2/guide/work-with-cdk-python.md

Summary

Updated Python version requirement from 3.6 to 3.9 and added detailed documentation on preventing type errors using type checkers (MyPy, Pyright) and IDE integrations (Pylance, PyCharm)

Security assessment

The changes promote code quality and early error detection, which indirectly enhances security by reducing deployment risks caused by type-related misconfigurations. However, there is no explicit mention of addressing a specific security vulnerability.

Diff

diff --git a/cdk/v2/guide/work-with-cdk-python.md b/cdk/v2/guide/work-with-cdk-python.md
index 2fabc7dde..3ec117a31 100644
--- a//cdk/v2/guide/work-with-cdk-python.md
+++ b//cdk/v2/guide/work-with-cdk-python.md
@@ -5 +5 @@
-Get started with PythonCreating a projectManaging AWS Construct Library modulesManaging dependencies in PythonAWS CDK idioms in Python
+Get started with PythonCreating a projectManaging AWS Construct Library modulesManaging dependencies in PythonAWS CDK idioms in PythonPreventing type errors
@@ -19 +19 @@ To work with the AWS CDK, you must have an AWS account and credentials and have
-Python AWS CDK applications require Python 3.6 or later. If you don’t already have it installed, [download a compatible version](https://www.python.org/downloads/) for your operating system at [python.org](https://www.python.org/). If you run Linux, your system may have come with a compatible version, or you may install it using your distro’s package manager (`yum`, `apt`, etc.). Mac users may be interested in [Homebrew](https://brew.sh/), a Linux-style package manager for macOS.
+Python AWS CDK applications require Python 3.9 or later. If you don’t already have it installed, [download a compatible version](https://www.python.org/downloads/) for your operating system at [python.org](https://www.python.org/). If you run Linux, your system may have come with a compatible version, or you may install it using your distro’s package manager (`yum`, `apt`, etc.). Mac users may be interested in [Homebrew](https://brew.sh/), a Linux-style package manager for macOS.
@@ -257 +257,50 @@ In our experience, the type errors Python programmers make tend to fall into the
-The AWS CDK Python modules do include type annotations, so you can use tools that support them to help with types. If you are not using an IDE that supports these, such as [PyCharm](https://www.jetbrains.com/pycharm/), you might want to call the [MyPy](http://mypy-lang.org/) type validator as a step in your build process. There are also runtime type checkers that can improve error messages for type-related errors.
+## Preventing type errors
+
+The AWS CDK Python modules include type annotations, so you can use tools that support them to catch type errors before deployment.
+
+### IDE integration (recommended)
+
+Visual Studio Code with Pylance provides real-time type checking as you write code:
+
+  1. Install the [Pylance extension](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance)
+
+  2. Configure strict type checking in `.vscode/settings.json`:
+    
+        {
+      "python.languageServer": "Pylance",
+      "python.analysis.typeCheckingMode": "strict"
+    }
+
+  3. Type errors now appear immediately with red squiggles and detailed error messages
+
+
+
+
+[PyCharm](https://www.jetbrains.com/pycharm/) also provides built-in type checking with similar capabilities.
+
+### Command-line type checking
+
+For CI/CD pipelines or pre-commit validation, use one of these type checkers:
+
+**MyPy (Python-based):**
+    
+    
+    pip install mypy
+    mypy app.py
+
+**Pyright (faster, JavaScript-based, same engine as Pylance):**
+    
+    
+    npm install -g pyright
+    pyright app.py
+
+### Recommended workflow
+
+  1. During development: Use Pyright or Pylance for instant feedback
+
+  2. Before commit: Run `mypy app.py` or `pyright app.py`
+
+  3. In CI/CD: Make type checking a required step before deployment
+
+
+