AWS ServiceCatalogApp Registry 构造库
AWS CDK v1在2023-06-01上达到了支持结束. 此软件包不再更新,用户应该迁移到 AWS CDK v2.
关于如何移徙的更多信息,请参见: 移动到 AWS CDK v2 指南。 。 。 .
AWS 服务目录应用程序注册 使各组织能够创建和管理应用程序和相关资源的存储器.
目录
这个 @aws-cdk/aws-servicecatalogappregistry 软件包包含使用户能够对其AWS资源进行大规模自动化治理和管理的资源.
import * as appreg from '@aws-cdk/aws-servicecatalogappregistry';
应用
一个 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',
);
属性组
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在部署时会失败 .
将应用程序与属性组关联
您可以将属性组与应用程序关联到 associateAttributeGroup() API : (英语)
declare const application: appreg.Application;
declare const attributeGroup: appreg.AttributeGroup;
application.associateAttributeGroup(attributeGroup);
将应用程序与堆栈连接
您可以将一个堆栈与应用程序连接到 associateStack() API : (英语)
const app = new App();
const myStack = new Stack(app, 'MyStack');
declare const application: appreg.Application;
application.associateStack(myStack);