{"id":5571,"library":"aws-cdk-aws-glue-alpha","title":"AWS CDK AWS Glue Alpha Construct Library","description":"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.","status":"active","version":"2.248.0a0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","glue","infrastructure-as-code","etl","serverless","alpha"],"install":[{"cmd":"pip install aws-cdk-aws-glue-alpha","lang":"bash","label":"Install latest alpha version"}],"dependencies":[{"reason":"Core AWS CDK library for defining cloud infrastructure.","package":"aws-cdk-lib","optional":false},{"reason":"Base constructs library for all CDK applications.","package":"constructs","optional":false}],"imports":[{"note":"Standard alias for the alpha Glue module.","symbol":"glue_alpha","correct":"import aws_cdk.aws_glue_alpha as glue_alpha"}],"quickstart":{"code":"import os\nfrom pathlib import Path\nimport aws_cdk as cdk\nimport aws_cdk.aws_s3 as s3\nimport aws_cdk.aws_iam as iam\nimport aws_cdk.aws_glue_alpha as glue_alpha\n\n# Create a dummy script file for the example Glue Job\nscript_content = \"\"\"\nimport sys\nfrom awsglue.utils import getResolvedOptions\n\nprint(\"Hello from Glue Job!\")\nargs = getResolvedOptions(sys.argv, ['JOB_NAME'])\nprint(f\"Job Name: {args['JOB_NAME']}\")\n\"\"\"\nscript_dir = Path.cwd() / \"glue_assets\"\nscript_dir.mkdir(exist_ok=True)\nscript_path = script_dir / \"my_glue_script.py\"\nscript_path.write_text(script_content)\n\napp = cdk.App()\nstack = cdk.Stack(app, \"MyGlueJobStack\",\n    env=cdk.Environment(\n        account=os.environ.get('CDK_DEFAULT_ACCOUNT', 'YOUR_AWS_ACCOUNT_ID'),\n        region=os.environ.get('CDK_DEFAULT_REGION', 'YOUR_AWS_REGION')\n    )\n)\n\n# S3 bucket to store the Glue script\nbucket = s3.Bucket(stack, \"GlueScriptsBucket\",\n    removal_policy=cdk.RemovalPolicy.DESTROY,\n    auto_delete_objects=True\n)\n\n# IAM role for the Glue Job\nglue_role = iam.Role(stack, \"GlueJobRole\",\n    assumed_by=iam.ServicePrincipal(\"glue.amazonaws.com\"),\n    managed_policies=[\n        iam.ManagedPolicy.from_aws_managed_policy_name(\"service-role/AWSGlueServiceRole\"),\n        iam.ManagedPolicy.from_aws_managed_policy_name(\"AmazonS3FullAccess\"), # For simplicity, grant S3 access\n    ]\n)\n\n# Define a Python Shell Glue Job\nglue_job = glue_alpha.Job(stack, \"MyPythonShellJob\",\n    executable=glue_alpha.JobExecutable.python_shell(\n        glue_version=glue_alpha.GlueVersion.V3_0, # Specify a Glue version\n        python_version=glue_alpha.PythonVersion.THREE_NINE, # Specify Python 3.9\n        script=glue_alpha.Code.from_asset(str(script_path)) # Upload script from local path\n    ),\n    role=glue_role,\n    job_name=\"MyPythonShellCDKJob\",\n    description=\"A simple Python Shell Glue Job created with CDK alpha construct.\",\n    tags={\n        \"Project\": \"CDKGlueAlphaDemo\"\n    }\n)\n\ncdk.CfnOutput(stack, \"GlueJobName\", value=glue_job.job_name)\ncdk.CfnOutput(stack, \"GlueScriptBucketName\", value=bucket.bucket_name)\n\napp.synth()\n\n# Clean up the dummy script file and directory\nscript_path.unlink()\nscript_dir.rmdir()\n","lang":"python","description":"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."},"warnings":[{"fix":"Review release notes and migration guides for each new alpha version. Test updates thoroughly.","message":"As 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.","severity":"breaking","affected_versions":"All alpha versions (e.g., 2.x.x-alpha.0)"},{"fix":"Adopt the `JobExecutable.TYPE_LANGUAGE()` pattern, such as `JobExecutable.python_shell(...)` or `JobExecutable.python_etl(...)`, and specify `glue_version` and `python_version` explicitly.","message":"Recent 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.","severity":"breaking","affected_versions":"Specific alpha versions (e.g., 2.173.2-alpha.0 onwards saw changes)"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All alpha versions"},{"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.","message":"The `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.","severity":"deprecated","affected_versions":"All alpha versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}