@aws-cdk/aws-servicecatalogappregistry-alpha

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

AWS 的 CDK 构建库: ServiiceCatalogApp Registry

中文使用文档
文档目录17 节
  1. 目录
  2. 应用
  3. 应用程序协理员
  4. 创建一个新应用程序来连接 cdk 中的所有堆栈 。 App 范围
  5. 导入已有的应用程序来连接 cdk 中的全部堆栈 。 App 范围
  6. 关联属性组 : ApplicationAssociator
  7. CDK管道部署的相干堆栈
  8. 关联交叉账户堆栈
  9. 关联跨区域堆栈
  10. 属性组
  11. 协会
  12. 将应用程序与新属性组连接
  13. 将属性组与应用程序结合
  14. 将应用程序与堆栈连接
  15. 共享
  16. 共享应用程序
  17. 共享属性组

AWS ServiceCatalogApp Registry 构造库


cdk-constructs: Experimental

本单元中更高层次的构件的API是实验性的并正在积极开发中. 在今后任何版本中,它们都须作非背向相容的修改或去除。 这些是 不适用 语义版本 模型和断开的更改 在发行笔记中宣布. 这意味着虽然你可能使用它们,但可能需要更新 当更新到此软件包的更新版本时,您的源代码.


AWS 服务目录应用程序注册 使各组织能够创建和管理应用程序和相关资源的储存库.

目录

这个 @aws-cdk/aws-servicecatalogappregistry-alpha 软件包包含使用户能够对其AWS资源进行大规模自动化治理和管理的资源.

import * as appreg from '@aws-cdk/aws-servicecatalogappregistry-alpha';

应用

一个 AppRegistry 应用程序允许您定义您的应用程序和相关资源. 申请名称必须在账户级别上独有,且不可改变.

const application = new appreg.Application(this, 'MyFirstApplication', {
  applicationName: 'MyFirstApplicationName',
  description: 'description for my application', // the description is optional
});

堆栈外已创建的应用程序可以导入到您的 CDK 应用程序中 . 应用程序可通过 ARN 导入 Application.fromApplicationArn() API : (英语)

const importedApplication = appreg.Application.fromApplicationArn(
  this,
  'MyImportedApplication',
  'arn:aws:servicecatalog:us-east-1:012345678910:/applications/0aqmvxvgmry0ecc4mjhwypun6i',
);

应用程序协理员

ApplicationAssociator 定义 AppRegistry 应用程序,以包含通过您的 cdk 软件包部署的所有堆栈。 这有助于管理所有 cdk 部署的资源.

创建一个新应用程序来连接 cdk 中的所有堆栈 。 App 范围

如果您想要创建名为应用程序 MyAssociatedApplication 账户 123456789012 区域 us-east-1 并想要将所有堆栈连接到 App 范围至 MyAssociatedApplication,然后使用如下示例所示:

const app = new App();
const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.createApplicationStack({
    applicationName: 'MyAssociatedApplication',
    // 'Application containing stacks deployed via CDK.' is the default
    applicationDescription: 'Associated Application description',
    stackName: 'MyAssociatedApplicationStack',
    // AWS Account and Region that are implied by the current CLI configuration is the default
    env: { account: '123456789012', region: 'us-east-1' },
  })],
});

这将创建一个堆栈 MyAssociatedApplicationStack 包含应用程序 MyAssociatedApplication 与 TagKey 作为 managedBy 财务报告和审定财务报表 TagValue 作为 CDK_Application_Associator。 。 。 .

默认情况下,堆栈将拥有系统管理应用程序管理器Control URL作为其创建应用程序的输出. 如果您想要删除输出, 请使用以下示例 :

const app = new App();
const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.createApplicationStack({
    applicationName: 'MyAssociatedApplication',
    // 'Application containing stacks deployed via CDK.' is the default
    applicationDescription: 'Associated Application description',
    stackName: 'MyAssociatedApplicationStack',
    // Disables emitting Application Manager url as output
    emitApplicationManagerUrlAsOutput: false,
    // AWS Account and Region that are implied by the current CLI configuration is the default
    env: { account: '123456789012', region: 'us-east-1' },
  })],
});

导入已有的应用程序来连接 cdk 中的全部堆栈 。 App 范围

如果您想要用 ARN 重用已有的应用程序 : arn:aws:servicecatalog:us-east-1:123456789012:/applications/applicationId 并想要将所有堆栈连接到 App 范围,然后使用如下示例所示:

const app = new App();
const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.existingApplicationFromArn({
    applicationArnValue: 'arn:aws:servicecatalog:us-east-1:123456789012:/applications/applicationId',
    stackName: 'MyAssociatedApplicationStack',
  })],
});

关联属性组 : ApplicationAssociator

如果您想要将属性组与创建于 ApplicationAssociator,然后使用如下示例所示:

import * as cdk from "aws-cdk-lib";

const app = new App();

const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.createApplicationStack({
    applicationName: 'MyAssociatedApplication',
    // 'Application containing stacks deployed via CDK.' is the default
    applicationDescription: 'Associated Application description',
    stackName: 'MyAssociatedApplicationStack',
    // AWS Account and Region that are implied by the current CLI configuration is the default
    env: { account: '123456789012', region: 'us-east-1' },
  })],
});

// Associate application to the attribute group.
associatedApp.appRegistryApplication.addAttributeGroup('MyAttributeGroup' , {
  attributeGroupName: 'MyAttributeGroupName',
  description: 'Test attribute group',
  attributes: {},
});

CDK管道部署的相干堆栈

如果您正在使用 CDK 管道来部署您的应用程序, 应用程序堆栈将位于阶段内,以及 应用 联系人无法找到他们。 打电话 associateStage 在添加到 管道,如下例所示:

import * as cdk from "aws-cdk-lib";
import * as codepipeline from "aws-cdk-lib/pipelines";
import * as codecommit from "aws-cdk-lib/aws-codecommit";
declare const repo: codecommit.Repository;
declare const pipeline: codepipeline.CodePipeline;
declare const beta: cdk.Stage;
class ApplicationPipelineStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props: ApplicationPipelineStackProps) {
    super(scope, id, props);

   //associate the stage to application associator.
   props.application.associateStage(beta);
   pipeline.addStage(beta);
  }
};

interface ApplicationPipelineStackProps extends cdk.StackProps {
  application: appreg.ApplicationAssociator;
};

const app = new App();
const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.createApplicationStack({
    applicationName: 'MyPipelineAssociatedApplication',
    stackName: 'MyPipelineAssociatedApplicationStack',
    env: { account: '123456789012', region: 'us-east-1' },
  })],
});

const cdkPipeline = new ApplicationPipelineStack(app, 'CDKApplicationPipelineStack', {
    application: associatedApp,
    env: {account: '123456789012', region: 'us-east-1'},
});

关联交叉账户堆栈

默认情况下,应用程序协会不会执行与目标应用程序的交叉账户堆栈关联, 避免未为交叉账户协会设立的账户出现部署失败. 为建立跨账户的堆栈协会,确保所有账户都与账户在同一个组织内 目标应用程序的账户以及资源分享在组织内得以实现. 如果您希望启动交叉账户共享和协会,请设定 associateCrossAccountStacks 字段改为 true, (中文(简体) ), 如下例所示:

const app = new App();
const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.createApplicationStack({
    associateCrossAccountStacks: true,
    applicationName: 'MyAssociatedApplication',
    env: { account: '123456789012', region: 'us-east-1' },
  })],
});

关联跨区域堆栈

目前,跨区域堆栈协会不支持.

属性组

AppRegistry属性组作为应用程序用户定义属性的容器. 元数据以机器可读格式附后,与自动化工作流程和工具相融合. 属性组名必须是账户级别上独有的,且不可改变.

const attributeGroup = new appreg.AttributeGroup(this, 'MyFirstAttributeGroup', {
  attributeGroupName: 'MyFirstAttributeGroupName',
  description: 'description for my attribute group', // the description is optional,
  attributes: {
    project: 'foo',
    team: ['member1', 'member2', 'member3'],
    public: false,
    stages: {
      alpha: 'complete',
      beta: 'incomplete',
      release: 'not started'
    }
  }
});

在堆栈外已创建的属性组可导入您的 CDK 应用程序 . 属性组可以通过 ARN 通过 AttributeGroup.fromAttributeGroupArn() API : (英语)

const importedAttributeGroup = appreg.AttributeGroup.fromAttributeGroupArn(
  this,
  'MyImportedAttrGroup',
  'arn:aws:servicecatalog:us-east-1:012345678910:/attribute-groups/0aqmvxvgmry0ecc4mjhwypun6i',
);

协会

您可以将您的应用程序与属性组和资源关联 . 资源是 CloudFormation 堆栈, 您可以与应用程序关联到组相关 堆叠起来,使元数据能够对您的应用程序和资源有丰富的见解. 一个 Cloudform 堆栈只能与一个应用程序相联. 如果一个堆栈与您的应用程序中的多个应用程序相关联或已经与一个应用程序相关联, CDK在部署时会失败 .

将应用程序与新属性组连接

您可以创建属性组并将其关联到应用程序 addAttributeGroup() API : (英语)

declare const application: appreg.Application;
declare const attributeGroup: appreg.AttributeGroup;
application.addAttributeGroup('MyAttributeGroupId' , {
    attributeGroupName: 'MyAttributeGroupName',
    description: 'Test attribute group',
    attributes: {},
});

将属性组与应用程序结合

您可以将应用程序与属性组关联到 associateWith数字 :

declare const application: appreg.Application;
declare const attributeGroup: appreg.AttributeGroup;
attributeGroup.associateWith(application);

将应用程序与堆栈连接

您可以将一个堆栈与应用程序连接到 associateApplicationWithStack() API : (英语)

const app = new App();
const myStack = new Stack(app, 'MyStack');

declare const application: appreg.Application;
application.associateApplicationWithStack(myStack);

共享

您可以与 AWS 组织,组织单位(OUs), AWS 组织内部的账户, 以及 IAM 角色和用户共享您的 AppRegistry 应用程序和属性组 。 AppRegistry 要求 AWS 组织在部署应用程序或属性组的共享之前在账户中启用.

共享应用程序

import * as iam from 'aws-cdk-lib/aws-iam';
declare const application: appreg.Application;
declare const myRole: iam.IRole;
declare const myUser: iam.IUser;
application.shareApplication('MyShareId', {
  name:'MyShare',
  accounts: ['123456789012'],
  organizationArns: ['arn:aws:organizations::123456789012:organization/o-my-org-id'],
  roles: [myRole],
  users: [myUser],
});

例如,与多个账户共享应用程序,并允许账户与应用程序关联资源.

import * as iam from 'aws-cdk-lib/aws-iam';
declare const application: appreg.Application;
application.shareApplication('MyShareId', {
  name: 'MyShare',
  accounts: ['123456789012', '234567890123'],
  sharePermission: appreg.SharePermission.ALLOW_ACCESS,
});

共享属性组

import * as iam from 'aws-cdk-lib/aws-iam';
declare const attributeGroup: appreg.AttributeGroup;
declare const myRole: iam.IRole;
declare const myUser: iam.IUser;
attributeGroup.shareAttributeGroup('MyShareId', {
  name: 'MyShare',
  accounts: ['123456789012'],
  organizationArns: ['arn:aws:organizations::123456789012:organization/o-my-org-id'],
  roles: [myRole],
  users: [myUser],
});

例如,与多个账户共享一个应用程序,并允许账户将应用程序关联到属性组.

import * as iam from 'aws-cdk-lib/aws-iam';
declare const attributeGroup: appreg.AttributeGroup;
attributeGroup.shareAttributeGroup('MyShareId', {
  name: 'MyShare',
  accounts: ['123456789012', '234567890123'],
  sharePermission: appreg.SharePermission.ALLOW_ACCESS,
});

版本与发布记录

@aws-cdk/aws-servicecatalogappregistry-alpha 共发布 380 个版本,首次发布于 2021/10/14;过去 12 个月发布了 64 个版本。

版本发布日期距今
2.275.0-alpha.0latest2026/10/2712 天前
2.274.0-alpha.02026/10/2018 天前
2.273.0-alpha.02026/10/0929 天前
2.272.0-alpha.02026/09/301 个月前
2.271.0-alpha.02026/09/261 个月前
2.270.0-alpha.02026/09/181 个月前

关于 @aws-cdk/aws-servicecatalogappregistry-alpha 的常见问题

@aws-cdk/aws-servicecatalogappregistry-alpha 是什么?

AWS 的 CDK 构建库: ServiiceCatalogApp Registry

如何安装 @aws-cdk/aws-servicecatalogappregistry-alpha?

在项目目录运行 npm install @aws-cdk/aws-servicecatalogappregistry-alpha,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:constructs(^10.5.0)、aws-cdk-lib(^2.275.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aws-cdk/aws-servicecatalogappregistry-alpha 支持 TypeScript 吗?

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

@aws-cdk/aws-servicecatalogappregistry-alpha 支持 ESM 还是 CommonJS?

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

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

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

@aws-cdk/aws-servicecatalogappregistry-alpha 可以商用吗?

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

@aws-cdk/aws-servicecatalogappregistry-alpha 的下载量有多少?

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

@aws-cdk/aws-servicecatalogappregistry-alpha 还在维护吗?

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