我刚刚出现了这个问题,似乎我已经解决了。
CloudWatch 警报的服务相关 IAM 角色是 AWSServiceRoleForCloudWatchEvents。我发现它的受信任实体是 events.amazonaws.com。及其在信任关系标签 中的政策文件,
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
以及信任关系标签 中我的 ec2 实例的角色策略文档
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
然后将 Trusted entity,events.amazonaws.com 内容添加到 ec2 实例的角色策略文档中,如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
它将events.amazonaws.com的可信实体添加到角色。
那么,CloudWatch 报警停止实例功能就OK了!