需要审计证明书
probator-auditor-required-tags的Python项目详细描述
认证人审计员要求的标签
请在Probator存储库中打开问题
说明
该审核员对发现不符合标记要求的aws对象进行审查、警告并可能采取行动。
配置选项
Option name | Default Value | Type | Description |
---|---|---|---|
alert_settings | See notes below | JSON | Alert and enforcement settings for supported resources |
always_send_email | True | bool | Send emails even in collect mode |
audit_ignore_tag | probator:ignore | string | Probator will ignore alerting/enforcement if resources are tagged with this |
audit_scope | aws_ec2_instance | string | Select resources (aws_ec2_instance, aws_s3_bucket) |
collect_only | True | bool | Do not shutdown resources, only update caches |
confirm_shutdown | True | bool | Require manual confirmation before shutting down instances |
email_subject | Resources missing required tags | string | Subject of the new issues email notifications |
enabled | False | bool | Enable the Required Tags auditor |
interval | 30 | int | How often the auditor executes, in minutes |
partial_owner_match | False | bool | Allow partial matches of the Owner tag |
permanent_recipient | [] | array | List of email addresses to receive all alerts |
required_tags | ['owner', 'accounting', 'name'] | array | List of required tags |
示例alert_settings
:
{"global":{"actions":[{"name":"alert:1","age":"now","action":"alert","order":0},{"name":"alert:2","age":"3 weeks","action":"alert","order":1},{"name":"alert:3","age":"3 weeks, 6 days","action":"alert","order":2},{"name":"stop","age":"4 weeks","action":"stop","order":3},{"name":"remove","age":"12 weeks","action":"remove","order":4}],"requiredTags":{"Name":null,"owner":"([a-zA-Z0-9._%+-]+[^+]@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,})"},"extraConfig":{}},"aws_ec2_instance":{"requiredTags":{"ssmEnabled":"^(true|false)$"}}}
global
部分应用于所有资源,我们将在下面的详细部分中讨论一些限制。除了
global
部分,您还可以为某些资源类型定义附加标记,或者重写actions
以使用不同的调度
特定资源类型
actions
actions
块定义要采取的操作集。通过上面的例子,我们可以看到总共有5个操作
将占用所有资源。
- 一旦检测到,立即发送警报(
age
=now
) - 3周后,再次发送警报
- 再过6天,发送第三个警报
- 4周后,停止实例(同时发送通知)
- 最后在12周后,删除资源(同时发送通知)
可以重写特定资源的操作,但是如果提供新的操作计划,则将忽略 资源类型。
有效操作类型
目前只支持三种类型的操作:alert
、stop
和remove
。
警报
向资源帐户的每个注册所有者发送通知
stop
停止资源(如果适用)。例如,如果EC2实例正在运行,则它将停止运行资源的状态将是 对审计员的每次执行进行评估,因此如果资源再次启动,则停止操作将再次应用
删除
完全删除资源,例如,如果资源是EC2实例,它将被终止。
required_tags
required_tags
是一个类似字典的对象,其中键是标记的名称,值是一个正则表达式模式
将用于验证资源的标记值。如果标记与提供的正则表达式不匹配,则将标记资源
由于不兼容,需要注意标记未能匹配正则表达式。
如果任何值是有效的,则可以提供null
值而不是正则表达式,以避免发生任何匹配,而不是
使用空/全局表达式,如.*
extra_config
此部分可用于提供验证标记所需的额外信息。此时,它不被 基本审计员功能,但在实现自定义操作方法的情况下可能会有所帮助
执行操作方法
action方法是一种简单的方法,它接受一个参数作为需要对其执行操作的Resource
对象。见
probator_auditor_required_tags/actions.py例如实现。
使用命名空间中setup.py中定义的入口点动态加载操作方法
probator_auditor_required_tags.actions
。入口点的名称必须是<resource_type>_<action>
例如要删除的操作
一个s3存储桶应该是aws_s3_bucket_remove
。