我正在尝试为CloudWatch设置自定义事件模式规则。到目前为止我提出的是
EventPattern:
source:
- aws.codebuild
detail-type:
- "CodeBuild Build State Change"
detail:
additional-information:
environment:
environment-variables:
name:
- "ENVIRONMENT"
value:
- !Sub "${Environment}"
这很好用,但我想过滤另一个环境变量。我已经尝试过以下示例,但这不起作用。
示例1 :(我可以保存,但不做任何事情)
EventPattern:
source:
- aws.codebuild
detail-type:
- "CodeBuild Build State Change"
detail:
additional-information:
environment:
environment-variables:
name:
- "ENVIRONMENT"
- "MY_ENV"
value:
- !Sub "${Environment}"
- "true"
示例2 :(错误:事件模式包含空元素或无效元素(只能是非空字符串,布尔值或数字))
EventPattern:
source:
- aws.codebuild
detail-type:
- "CodeBuild Build State Change"
detail:
additional-information:
environment:
environment-variables:
- name: "ENVIRONMENT"
value: !Sub "${Environment}"
- name: "MY_ENV"
value: "true"
我从CodeBuild获得的模式如下:
{
"detail":{
"additional-information":{
"environment":{
"environment-variables":[
{
"name":"MY_ENV",
"type":"PLAINTEXT",
"value":"true"
},
{
"name":"ENVIRONMENT",
"type":"PLAINTEXT",
"value":"production"
}
]
}
}
}
}
还有其他想法吗?