Registry / aws / aws-cdk-aws-glue-alpha

aws-cdk-aws-glue-alpha

JSON →
library2.267.0a0pypypi✓ verified 22d ago

The AWS CDK Construct Library for AWS Glue is an experimental module providing higher-level (L2) constructs for defining AWS Glue resources in your CDK applications. It simplifies the creation of Glue Jobs, Databases, and other components with opinionated defaults, aiming for best practices. Being an 'alpha' module, its APIs are subject to non-backward compatible changes, and it's currently at version 2.248.0a0. The AWS CDK typically has a frequent release cadence, with alpha modules updating regularly.

pip install aws-cdk-aws-glue-alpha
INSTALL
IMPORT
SIG · AWS-CDK-AWS-GLUE-A
A
aws-cdk-aws-glue-alpha
awspythonv2.267.0a0
Install
18.5s avg
Import
Disk
401MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.267.0a0 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 379.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 18.5s · import 0.000s · 380MB
401MB installed
● package 401MB
Code
Verified usage

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

glue_alpha
import aws_cdk.aws_glue_alpha as glue_alpha
Standard alias for the alpha Glue module.

This quickstart defines a basic AWS CDK stack that creates an S3 bucket for Glue scripts, an IAM role for the Glue job, and a Python Shell Glue Job using the `aws-cdk-aws-glue-alpha` construct library. It uploads a local Python script as an S3 asset for the Glue Job. Remember to replace 'YOUR_AWS_ACCOUNT_ID' and 'YOUR_AWS_REGION' or set `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` environment variables.

import os from pathlib import Path import aws_cdk as cdk import aws_cdk.aws_s3 as s3 import aws_cdk.aws_iam as iam import aws_cdk.aws_glue_alpha as glue_alpha # Create a dummy script file for the example Glue Job script_content = """ import sys from awsglue.utils import getResolvedOptions print("Hello from Glue Job!") args = getResolvedOptions(sys.argv, ['JOB_NAME']) print(f"Job Name: {args['JOB_NAME']}") """ script_dir = Path.cwd() / "glue_assets" script_dir.mkdir(exist_ok=True) script_path = script_dir / "my_glue_script.py" script_path.write_text(script_content) app = cdk.App() stack = cdk.Stack(app, "MyGlueJobStack", env=cdk.Environment( account=os.environ.get('CDK_DEFAULT_ACCOUNT', 'YOUR_AWS_ACCOUNT_ID'), region=os.environ.get('CDK_DEFAULT_REGION', 'YOUR_AWS_REGION') ) ) # S3 bucket to store the Glue script bucket = s3.Bucket(stack, "GlueScriptsBucket", removal_policy=cdk.RemovalPolicy.DESTROY, auto_delete_objects=True ) # IAM role for the Glue Job glue_role = iam.Role(stack, "GlueJobRole", assumed_by=iam.ServicePrincipal("glue.amazonaws.com"), managed_policies=[ iam.ManagedPolicy.from_aws_managed_policy_name("service-role/AWSGlueServiceRole"), iam.ManagedPolicy.from_aws_managed_policy_name("AmazonS3FullAccess"), # For simplicity, grant S3 access ] ) # Define a Python Shell Glue Job glue_job = glue_alpha.Job(stack, "MyPythonShellJob", executable=glue_alpha.JobExecutable.python_shell( glue_version=glue_alpha.GlueVersion.V3_0, # Specify a Glue version python_version=glue_alpha.PythonVersion.THREE_NINE, # Specify Python 3.9 script=glue_alpha.Code.from_asset(str(script_path)) # Upload script from local path ), role=glue_role, job_name="MyPythonShellCDKJob", description="A simple Python Shell Glue Job created with CDK alpha construct.", tags={ "Project": "CDKGlueAlphaDemo" } ) cdk.CfnOutput(stack, "GlueJobName", value=glue_job.job_name) cdk.CfnOutput(stack, "GlueScriptBucketName", value=bucket.bucket_name) app.synth() # Clean up the dummy script file and directory script_path.unlink() script_dir.rmdir()
cdk --version
Debug
Known issues
breakingAs an 'alpha' module, APIs in `aws-cdk-aws-glue-alpha` are experimental and subject to non-backward compatible changes or removal in any future version without adhering to semantic versioning. Developers should expect to update their source code when upgrading versions.
fix
Review release notes and migration guides for each new alpha version. Test updates thoroughly.
affects: All alpha versions (e.g., 2.x.x-alpha.0)
breakingRecent iterations of the Glue L2 construct have introduced breaking changes, particularly in how Glue Jobs are instantiated. Users must refactor existing job definitions to explicitly choose the job type (e.g., `python_shell`, `spark_etl`) and language.
fix
Adopt the `JobExecutable.TYPE_LANGUAGE()` pattern, such as `JobExecutable.python_shell(...)` or `JobExecutable.python_etl(...)`, and specify `glue_version` and `python_version` explicitly.
affects: Specific alpha versions (e.g., 2.173.2-alpha.0 onwards saw changes)
gotchaThe `Code.fromAsset()` method for specifying job scripts requires a path to a single *file*, not a directory. Providing a directory will result in a validation error.
fix
Ensure the `path` argument for `Code.fromAsset()` points directly to the script file (e.g., `path/to/my_script.py`), not its containing directory.
affects: All versions
gotchaThe Glue L2 constructs are 'opinionated,' meaning they enforce best practices and may not allow creating resources with non-current Glue versions or deprecated language dependencies (e.g., older Python versions). For maximum flexibility, L1 (CloudFormation) constructs might be necessary.
fix
Adhere to recommended Glue versions and language runtimes. If specific legacy configurations are required, consider using the `aws-cdk-lib.aws_glue` module for L1 (CloudFormation) constructs.
affects: All alpha versions
deprecatedThe `aws-cdk-aws-glue-alpha` module is expected to migrate from its alpha state into the core `aws-cdk-lib` after a stabilization phase (typically around 3 months from its announcement). This will eventually change the import path and package name.
fix
Monitor AWS CDK release announcements. Be prepared to migrate imports from `aws_cdk.aws_glue_alpha` to `aws_cdk.aws_glue` when the module stabilizes and is rolled into the core library.
affects: All alpha versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_cdk.aws_glue_alpha'
The 'aws-cdk.aws-glue-alpha' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install aws-cdk.aws-glue-alpha'.
TypeError: __init__() missing 1 required positional argument: 'scope'
The constructor for a Glue construct is missing the 'scope' argument.
fix
Ensure that the 'scope' argument is provided when initializing the construct, e.g., 'glue.Database(self, 'MyDatabase', ...)'
AttributeError: module 'aws_cdk.aws_glue_alpha' has no attribute 'PySparkEtlJob'
The 'PySparkEtlJob' class is not available in the installed version of 'aws-cdk.aws-glue-alpha'.
fix
Update the 'aws-cdk.aws-glue-alpha' module to the latest version using pip: 'pip install --upgrade aws-cdk.aws-glue-alpha'.
ValueError: Invalid GlueVersion: 'V5_1'
The specified GlueVersion 'V5_1' is not recognized or supported.
fix
Use a valid GlueVersion, such as 'glue.GlueVersion.V4_0'.
ImportError: cannot import name 'Database' from 'aws_cdk.aws_glue_alpha'
The 'Database' class is not available in the installed version of 'aws-cdk.aws-glue_alpha'.
fix
Ensure that the module is up to date by running 'pip install --upgrade aws-cdk.aws-glue-alpha'.
Upgrade
Version history
2.267.0a0latest on PyPI · released Aug 27, 2026
Audit
Dependencies
aws-cdk-librequiredCore AWS CDK library for defining cloud infrastructure.
constructsrequiredBase constructs library for all CDK applications.
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
2
Resources
aws-cdk-aws-glue-alpha — pip install aws-cdk-aws-glue-alpha · libregistry