{"id":9523,"library":"aws-cdk-aws-location-alpha","title":"AWS CDK Location Service (Alpha)","description":"The AWS CDK Location Service Alpha module provides L2 (Level 2) constructs for interacting with AWS Location Service. This allows developers to define Location Service resources like Trackers, Geofence Collections, Maps, and Place Indexes using Python. As an 'alpha' module, its APIs are subject to change and it's generally not recommended for production use. It is released in lockstep with the main `aws-cdk-lib` package.","status":"active","version":"2.250.0a0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws-cdk","aws-location","cloud-development-kit","serverless","alpha-module"],"install":[{"cmd":"pip install aws-cdk-aws-location-alpha","lang":"bash","label":"Install library"},{"cmd":"npm install -g aws-cdk","lang":"bash","label":"Install AWS CDK CLI (globally)"}],"dependencies":[{"reason":"Core AWS CDK library, required for any CDK project. Version must match.","package":"aws-cdk-lib","optional":false},{"reason":"Dependency for all CDK constructs.","package":"constructs","optional":false}],"imports":[{"note":"L2 constructs (e.g., `Tracker`) for Location Service are typically found in the `_alpha` module. The non-alpha `aws_cdk.aws_location` module usually contains only L1 (Cfn) constructs.","wrong":"import aws_cdk.aws_location as location","symbol":"aws_location_alpha","correct":"import aws_cdk.aws_location_alpha as location"},{"note":"Standard import for defining a CDK Stack.","symbol":"Stack","correct":"from aws_cdk import Stack"}],"quickstart":{"code":"import os\nfrom aws_cdk import (\n    Stack,\n    App,\n    Environment,\n)\nimport aws_cdk.aws_location_alpha as location\nfrom constructs import Construct\n\nclass MyLocationStack(Stack):\n    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        # Create an AWS Location Tracker\n        tracker = location.Tracker(\n            self, \"MySimpleTracker\",\n            tracker_name=\"MyExampleTracker\",\n            description=\"A simple tracker for demonstration\"\n        )\n\n        # Optional: Create a Geofence Collection\n        geofence_collection = location.GeofenceCollection(\n            self, \"MySimpleGeofenceCollection\",\n            geofence_collection_name=\"MyExampleGeofenceCollection\",\n            description=\"A simple geofence collection\"\n        )\n\napp = App()\nMyLocationStack(app, \"MyLocationServiceStack\",\n    env=Environment(\n        account=os.environ.get(\"CDK_DEFAULT_ACCOUNT\"),\n        region=os.environ.get(\"CDK_DEFAULT_REGION\"),\n    )\n)\napp.synth()\n","lang":"python","description":"This example demonstrates how to define a basic AWS CDK Stack that provisions an AWS Location Service Tracker and a Geofence Collection using the `aws-cdk-aws-location-alpha` module. Ensure `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` environment variables are set or explicitly provided for deployment."},"warnings":[{"fix":"Review release notes for `aws-cdk-lib` and `aws-cdk-aws-location-alpha` with each update. For production, consider using L1 (Cfn) constructs from `aws_cdk.aws_location` if L2 constructs are not available in a stable module.","message":"As an 'alpha' module (`a0` suffix in version, `_alpha` in module name), APIs are subject to breaking changes without major version bumps. This module is not recommended for production workloads.","severity":"breaking","affected_versions":"All alpha versions (e.g., 2.x.x.a0)"},{"fix":"Always install `aws-cdk-aws-location-alpha` with the same major.minor.patch version prefix as your `aws-cdk-lib`. For example, if `aws-cdk-lib==2.250.0`, install `aws-cdk-aws-location-alpha==2.250.0a0`.","message":"Alpha modules (`aws-cdk-aws-location-alpha`) must be strictly version-locked with the core `aws-cdk-lib` package. Mismatched versions can lead to `ModuleNotFoundError`, `AttributeError`, or `TypeError` due to underlying JSII compatibility issues.","severity":"gotcha","affected_versions":"All versions where `aws-cdk-lib` and `aws-cdk-aws-location-alpha` versions do not match (e.g., `aws-cdk-lib==2.200.0` and `aws-cdk-aws-location-alpha==2.250.0a0`)."},{"fix":"Install the CLI via `npm install -g aws-cdk`. Configure your AWS credentials (e.g., `aws configure` or environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`). Ensure `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` are set or specified in your `App`.","message":"Deploying AWS CDK applications requires the AWS CDK CLI (`aws-cdk`) to be installed globally and configured with valid AWS credentials and a default region/account.","severity":"gotcha","affected_versions":"All versions of AWS CDK."}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install aws-cdk-aws-location-alpha`. Ensure `aws-cdk-aws-location-alpha` and `aws-cdk-lib` share the same major.minor.patch version prefix.","cause":"The `aws-cdk-aws-location-alpha` Python package is not installed, or there's a version mismatch with `aws-cdk-lib`.","error":"ModuleNotFoundError: No module named 'aws_cdk.aws_location_alpha'"},{"fix":"Change your import statement to `import aws_cdk.aws_location_alpha as location` and then use `location.Tracker(...)`.","cause":"Attempting to import L2 constructs (like `Tracker`) from the non-alpha `aws_cdk.aws_location` module, while they only exist in the `_alpha` module.","error":"AttributeError: module 'aws_cdk.aws_location' has no attribute 'Tracker'"},{"fix":"Ensure `aws-cdk-lib` and `aws-cdk-aws-location-alpha` are installed with matching major.minor.patch versions. You may need to update `jsii` or reinstall your `node_modules` if you are working in a JSII-enabled environment.","cause":"This often indicates a deep incompatibility issue, frequently caused by a mismatch between the `aws-cdk-lib` and `aws-cdk-aws-location-alpha` package versions, or an outdated `jsii` runtime.","error":"jsii.errors.JavaScriptError: TypeError: Class constructor Location cannot be invoked without 'new'"},{"fix":"Pass an `env` object to your Stack, e.g., `env=Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT'), region=os.environ.get('CDK_DEFAULT_REGION'))`. Ensure `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` are set in your shell environment.","cause":"CDK expects an AWS environment (account and region) to synthesize or deploy the stack, but it was not provided in the `App` or via environment variables.","error":"Error: There are no 'context' values defined for this stack."}]}