aws::config的cdk构造库

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


aws配置构造库


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管理的规则

要设置托管规则,请定义一个ManagedRule,并指定其标识符:

newManagedRule(this,'AccessKeysRotated',{identifier:'ACCESS_KEYS_ROTATED'});

可用的标识符和参数列在List of AWS Config Managed Rules中。

托管规则的高级结构可用,请参见Managed Rules。如果可用,更愿意使用这些结构(欢迎prs添加更多的结构)。

自定义规则

要设置自定义规则,请定义一个CustomRule,并指定要运行的lambda函数和触发器类型:

newCustomRule(this,'CustomRule',{lambdaFunction: myFn,configurationChanges: true,periodic: true});

限制范围

默认情况下,规则由对所有resources的更改触发。使用scopeToResource()scopeToResources()scopeToTag()方法来限制托管规则和自定义规则的范围:

constsshRule=newManagedRule(this,'SSH',{identifier:'INCOMING_SSH_DISABLED'});// Restrict to a specific security grouprule.scopeToResource('AWS::EC2::SecurityGroup','sg-1234567890abcdefgh');constcustomRule=newCustomRule(this,'CustomRule',{lambdaFunction: myFn,configurationChanges: true});// Restrict to a specific tagcustomRule.scopeToTag('Cost Center','MyApp');

一个规则只能添加一种类型的作用域限制(对scopeToXxx()的最后一次调用设置作用域)。

事件

要定义amazon cloudwatch事件规则,请使用onComplianceChange()onReEvaluationStatus()方法:

construle=newCloudFormationStackDriftDetectionCheck(this,'Drift');rule.onComplianceChange('TopicEvent',{target: newtargets.SnsTopic(topic))});

示例

创建具有范围限制和事件的自定义和托管规则:

// A custom rule that runs on configuration changes of EC2 instancesconstfn=newlambda.Function(this,'CustomFunction',{code: lambda.AssetCode.fromInline('exports.handler = (event) => console.log(event);'),handler:'index.handler',runtime: lambda.Runtime.NODEJS_8_10});constcustomRule=newconfig.CustomRule(this,'Custom',{configurationChanges: true,lambdaFunction: fn});customRule.scopeToResource('AWS::EC2::Instance');// A rule to detect stacks driftsconstdriftRule=newconfig.CloudFormationStackDriftDetectionCheck(this,'Drift');// Topic for compliance eventsconstcomplianceTopic=newsns.Topic(this,'ComplianceTopic');// Send notification on compliance changedriftRule.onComplianceChange('ComplianceChange',{target: newtargets.SnsTopic(complianceTopic)});

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

推荐PyPI第三方库


热门话题
java正则表达式查找但不包含在组中   java在for循环内的主线程中调用AsyncTask   java解析SOAP服务的响应时遇到问题。XML有什么问题?   java Servlet ClassNotFoundException出现在包中时。。。为什么?   Facebook SDK中的安卓 R.Java与应用程序R.Java冲突   java为什么我得到SSLProtocolexception:尝试发送http请求时握手失败?   java Base64编码字符串搜索   在htmlunit中选择java下拉菜单   java列表添加到HashMap   java设置断点的最短NOOP语句是什么?   java如何检索windows中所有应用程序最近使用的文件   java正则表达式,包含正向向后看和向前看   如何在java中通过API从url获取图像?   如何将for-each循环转换为Java流和lambda函数?   java如何使用jackson流式api解析给定的json?   java暂停调用方法jdbcTemplate。getDataSource()   java如何在使用getJdbcTemplate时使用union运算符设置sql查询的参数。查询(sql、新对象[]、行映射器)?   java我可以为HQL查询指定结果对象类型吗?   java Spring未满足的依赖项错误   maven试图重新定位poi jar,但未找到java类异常