实现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 Hibernate@ManyToMany mapping只在一个方向上在数据库中添加记录   java将文件上载到tomcat服务器外部的文件夹   java将摄像头捕获的图像上传到服务器   java如何创建Rest API并为进程添加时间延迟?   springmodulesvalidation0中缺少java注释包。8a源文件   如何在java中打印SOAP头   Spring security中的java自定义消息,包括UserDetailsService实现和异常   java如何使用Htmlunit中的表单数据登录站点   web如何在WildFly上自动运行java文件   java如何从已经使用另一个方法传递的参数的方法中获取返回值?   java我在JFrame上有一个索引越界。setContentPane   java中的循环序列/系列打印   java maven 3 webapp没有要运行的测试吗?   java CORS不允许POST请求   java再次在派生类中的Jackson中添加字段,该字段在基类中被忽略   爪哇坑测试显示仆从由于超时而异常退出   java寻找第10001个素数   java jboss是否更改web应用程序上下文根?