实现cdk自定义资源的结构

aws-cdk.custom-resources的Python项目详细描述


CDK自定义资源


Stability: Experimental

This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.

This API is still under active development and subject to non-backward compatible changes or removal in any future version. Use of the API is not recommended in production environments. Experimental APIs are not subject to the Semantic Versioning model.


这个模块是AWS Cloud Development Kit项目的一部分。

AWS自定义资源

有时候一个api调用就可以填补cloudformation覆盖率的空白。在 在这种情况下,您可以使用AwsCustomResource构造。这个构造创建 一个自定义资源,可以对其进行自定义以对 CREATEUPDATEDELETE事件。此外,api返回的数据 可以提取调用并在其他构造/资源中使用(创建 在hood下使用Fn::GetAtt的cloudformation依赖项)。

自定义资源的物理ID可以指定或从数据派生 由API调用返回。

AwsCustomResource将aws sdk用于javascript。服务、行动和 参数可以在API documentation中找到。

必须使用点表示法指定数据路径,例如,要获取字符串值 对于由dynamodb.query返回的第一个项的Title属性,它应该 是Items.0.Title.S

示例

使用ses验证域:

constverifyDomainIdentity=newAwsCustomResource(this,'VerifyDomainIdentity',{onCreate:{service:'SES',action:'verifyDomainIdentity',parameters:{Domain:'example.com'},physicalResourceIdPath:'VerificationToken'// Use the token returned by the call as physical id}});newroute53.TxtRecord(zone,'SESVerificationRecord',{recordName:`_amazonses.example.com`,recordValue: verifyDomainIdentity.getData('VerificationToken')});

获取最新版本的安全SSM参数:

constgetParameter=newAwsCustomResource(this,'GetParameter',{onUpdate:{// will also be called for a CREATE eventservice:'SSM',action:'getParameter',parameters:{Name:'my-parameter',WithDecryption: true},physicalResourceId: Date.now().toString()// Update physical id to always fetch the latest version}});// Use the value in another construct withgetParameter.getData('Parameter.Value')

进行api调用所需的iam策略语句是从调用派生的 默认情况下,允许对所有资源执行操作(*)。你可以 通过使用指定自己的语句列表来限制权限 policyStatements道具。

链式api调用可以通过创建依赖项来实现:

constawsCustom1=newAwsCustomResource(this,'API1',{onCreate:{service:'...',action:'...',physicalResourceId:'...'}});constawsCustom2=newAwsCustomResource(this,'API2',{onCreate:{service:'...',action:'...'parameters:{text: awsCustom1.getData('Items.0.text')},physicalResourceId:'...'}})

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
未检测到“空格”的java ASCII码   音频如何在Java中设置SourceDataLine的音量   java MyBatissSpringBoot无法使用作为bean注入的数据源   Java字谜递归列表<List<String>>仅存储空列表<Strings>   java显示30px高的JPanel,然后用minecraft填充剩余空间   java JOGL平滑度   Java:按完整与否对1d对象数组进行排序   arraylist仅当java结构不存在时才将对象添加到java结构中   无法初始化java渲染库在安卓 studio 4.1.1上出现错误   java SpringBoot ClassCastException   java解析文本文件,基于字数   java=运算符引发异常   java使点可拖动并存储新坐标JavaFx   JavaWebSphereApplicationServer:EJB模块和JMS路由器