{"id":7958,"library":"aws-cdk-region-info","title":"AWS CDK Region Info","description":"The `aws-cdk-region-info` library provides a comprehensive directory of AWS region-specific information, such as service principal names for IAM policies, S3 static website endpoints, and other essential regional facts. As a core component of the AWS Cloud Development Kit (CDK) v2, it enables CDK applications to dynamically adapt to regional differences. The library is actively maintained and receives frequent updates, typically alongside new AWS CDK releases, with the current version being 2.250.0.","status":"active","version":"2.250.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","region","cloud","infrastructure-as-code","iam","s3"],"install":[{"cmd":"pip install aws-cdk-region-info","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.9 or higher for AWS CDK v2 compatibility.","package":"python","optional":false}],"imports":[{"note":"The standard Python CDK import convention is to import the module and access classes via the module alias.","wrong":"from aws_cdk.region_info import RegionInfo # Not the standard import pattern in Python CDK","symbol":"RegionInfo","correct":"from aws_cdk import region_info\n# ...\ninfo = region_info.RegionInfo.get(\"us-east-1\")"},{"note":"Accessing Fact and FactName directly via the main region_info module is the idiomatic way.","wrong":"from aws_cdk.region_info.Fact import find # Incorrect submodule access","symbol":"Fact","correct":"from aws_cdk import region_info\n# ...\nendpoint = region_info.Fact.find(\"ap-northeast-1\", region_info.FactName.S3_STATIC_WEBSITE_ENDPOINT)"}],"quickstart":{"code":"import os\nfrom aws_cdk import region_info\n\n# Get information for a specific region\nus_east_1_info = region_info.RegionInfo.get(\"us-east-1\")\nprint(f\"S3 Static Website Endpoint for us-east-1: {us_east_1_info.s3_static_website_endpoint}\")\n\n# Get a service principal for a region\ns3_service_principal = us_east_1_info.service_principal(\"s3.amazonaws.com\")\nprint(f\"S3 Service Principal for us-east-1: {s3_service_principal}\")\n\n# Find a specific fact for a region using Fact.find()\n# Example: Get the domain suffix for a China region\ncn_north_1_domain_suffix = region_info.Fact.find(\"cn-north-1\", region_info.FactName.DOMAIN_SUFFIX)\nprint(f\"Domain Suffix for cn-north-1: {cn_north_1_domain_suffix}\")\n\n# Override or add a custom fact (e.g., for a new or hypothetical region)\n# This is for demonstration; normally you'd implement IFact\nclass MyCustomFact:\n    def __init__(self, region, name, value):\n        self.region = region\n        self.name = name\n        self.value = value\n\n@region_info.jsii.implements(region_info.IFact)\nclass CustomEndpointFact(MyCustomFact):\n    pass\n\ncustom_region = \"bermuda-triangle-1\"\ncustom_endpoint_fact = CustomEndpointFact(\n    region=custom_region,\n    name=region_info.FactName.S3_STATIC_WEBSITE_ENDPOINT,\n    value=\"s3-website.bermuda-triangle-1.nowhere.com\"\n)\nregion_info.Fact.register(custom_endpoint_fact)\n\n# Retrieve the custom fact\nretrieved_custom_endpoint = region_info.RegionInfo.get(custom_region).s3_static_website_endpoint\nprint(f\"Custom S3 Static Website Endpoint for {custom_region}: {retrieved_custom_endpoint}\")\n","lang":"python","description":"This quickstart demonstrates how to retrieve standard region information using `RegionInfo.get()` and its attributes, as well as how to use `Fact.find()` for specific facts. It also includes an example of how to register custom region facts for new or overridden data."},"warnings":[{"fix":"Downgrade `aws-cdk-region-info` to a known working version (e.g., 2.199.0) or upgrade to a patched version that resolves the internal module resolution issue. Always test upgrades in a controlled environment.","message":"Specific versions of `aws-cdk-region-info` (e.g., 2.200.1 up to 2.232.2) have experienced a regression causing a `Cannot find module 'aws-cdk-lib/core/lib/errors'` error at runtime due to internal dependency issues within the CDK ecosystem. This can completely block CDK application execution.","severity":"breaking","affected_versions":"2.200.1 - 2.232.2 (and potentially others within this range)"},{"fix":"Instead of `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION`, define your own custom environment variables (e.g., `MY_DEPLOY_ACCOUNT`, `MY_DEPLOY_REGION`) and use them programmatically within your CDK application for stack `env` properties. For region-specific resource lookups or imports, explicitly specify the `env` property in your CDK stacks.","message":"The AWS CDK CLI (e.g., `cdk synth`, `cdk deploy`) overrides any user-set `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` environment variables. If you rely on these for specific deployments, the CLI's behavior might lead to unintended targets.","severity":"gotcha","affected_versions":"All AWS CDK v2 versions"},{"fix":"If you encounter missing or incorrect data, you can temporarily override or supply new facts using `region_info.Fact.register()`. It's also recommended to report such findings as a GitHub issue to the AWS CDK team so it can be fixed in future releases.","message":"While `aws-cdk-region-info` aims to be comprehensive, new AWS regions or very specific service endpoints might initially be missing or have outdated facts. Relying solely on the built-in data might lead to `None` values or incorrect behavior for bleeding-edge features or newly launched regions.","severity":"gotcha","affected_versions":"All versions, particularly for newly launched AWS regions or services."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Check your `aws-cdk-region-info` version. If it's within the affected range (e.g., 2.200.1 - 2.232.2), try downgrading to a stable preceding version (e.g., 2.199.0) or upgrading to a version released after the fix was applied.","cause":"An internal dependency resolution issue within specific versions of `aws-cdk-region-info` prevents it from finding a required module from `aws-cdk-lib/core`.","error":"Error: Cannot find module 'aws-cdk-lib/core/lib/errors'"},{"fix":"Avoid using `CDK_DEFAULT_ACCOUNT` or `CDK_DEFAULT_REGION` directly. Instead, explicitly define the `env` property (account and region) for your CDK `Stack` instances in your code. For custom overrides, define and use your own environment variables (e.g., `MY_ACCOUNT`, `MY_REGION`) within your application code.","cause":"The AWS CDK CLI overwrites `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` if set as shell environment variables. Additionally, 'environment-agnostic' stacks might default to your AWS CLI's configured profile.","error":"cdk synth / cdk deploy uses the wrong AWS account or region for deployment."},{"fix":"Verify the fact's existence and correctness in the official AWS documentation. If missing or incorrect, use `region_info.Fact.register()` to programmatically inject or override the specific fact for your application. Consider contributing the correction to the AWS CDK project via a GitHub issue.","cause":"The built-in database of regional facts might not yet include information for very new AWS regions or specific, recently launched service features, or might contain outdated information.","error":"region_info.RegionInfo.get('some-new-region').some_fact returns None or incorrect value."}]}