@aws-cdk/region-info

中文文档
2.275.0发布于 2026/10/27Apache-2.0TypeScriptCommonJS零依赖近 30 天下载 131.9万

AWS region information, such as service principal names

原始使用文档
文档目录5 节
  1. Usage
  2. The RegionInfo class
  3. Low-Level API
  4. Supplying new or missing information
  5. Overriding incorrect information

AWS Region-Specific Information Directory

Usage

Some information used in CDK Applications differs from one AWS region to another, such as service principals used in IAM policies, S3 static website endpoints, ...

The RegionInfo class

The library offers a simple interface to obtain region specific information in the form of the RegionInfo class. This is the preferred way to interact with the regional information database:

// Get the information for "eu-west-1":
const region = regionInfo.RegionInfo.get('eu-west-1');

// Access attributes:
region.s3StaticWebsiteEndpoint; // s3-website-eu-west-1.amazonaws.com

The RegionInfo layer is built on top of the Low-Level API, which is described below and can be used to register additional data, including user-defined facts that are not available through the RegionInfo interface.

Low-Level API

This library offers a primitive database of such information so that CDK constructs can easily access regional information. The FactName class provides a list of known fact names, which can then be used with the RegionInfo to retrieve a particular value:

const staticWebsite = regionInfo.Fact.find(
  'ap-northeast-1',
  regionInfo.FactName.S3_STATIC_WEBSITE_ENDPOINT
);
// => s3-website-ap-northeast-1.amazonaws.com

Supplying new or missing information

As new regions are released, it might happen that a particular fact you need is missing from the library. In such cases, the Fact.register method can be used to inject FactName into the database:

class MyFact implements regionInfo.IFact {
  public readonly region = 'bermuda-triangle-1';
  public readonly name = regionInfo.FactName.S3_STATIC_WEBSITE_ENDPOINT;
  public readonly value = 's3-website.bermuda-triangle-1.nowhere.com';
}

regionInfo.Fact.register(new MyFact());

Overriding incorrect information

In the event information provided by the library is incorrect, it can be overridden using the same Fact.register method demonstrated above, simply adding an extra boolean argument:

class MyFact implements regionInfo.IFact {
  public readonly region = 'us-east-1';
  public readonly name = regionInfo.FactName.S3_STATIC_WEBSITE_ENDPOINT;
  public readonly value = 'the-correct-endpoint.amazonaws.com';
}

regionInfo.Fact.register(new MyFact(), true /* Allow overriding information */);

If you happen to have stumbled upon incorrect data built into this library, it is always a good idea to report your findings in a GitHub issue, so we can fix it for everyone else!


This module is part of the AWS Cloud Development Kit project.

版本与发布记录

@aws-cdk/region-info 共发布 671 个版本,首次发布于 2019/03/13;过去 12 个月发布了 64 个版本。

版本发布日期距今
2.275.0latest2026/10/2712 天前
2.274.02026/10/2018 天前
2.273.02026/10/0930 天前
2.272.02026/09/301 个月前
2.271.02026/09/261 个月前
2.270.02026/09/181 个月前

其他发布通道:next → 2.0.0-rc.33,latest-1 → 1.204.0。

关于 @aws-cdk/region-info 的常见问题

@aws-cdk/region-info 是什么?

AWS region information, such as service principal names

如何安装 @aws-cdk/region-info?

在项目目录运行 npm install @aws-cdk/region-info,或使用 pnpm add / yarn add / bun add。

@aws-cdk/region-info 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aws-cdk/region-info 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aws-cdk/region-info 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@aws-cdk/region-info 可以商用吗?

@aws-cdk/region-info 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aws-cdk/region-info 的下载量有多少?

根据 npm 官方下载统计,@aws-cdk/region-info 在 2026/10/08 – 2026/11/06 这 30 天内被下载 1,319,495 次,日均约 43,983 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aws-cdk/region-info 还在维护吗?

最新版本 2.275.0 发布于 2026/10/27(12 天前);至今共发布 671 个版本,其中过去 12 个月发布了 64 个;首次发布于 2019/03/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。