我目前正在致力于实施 AWS 组织 SCP。我的目标是满足以下条件:
谢谢!
我尝试了以下政策,
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyEC2CreationSCP1",
"Effect": "Deny",
"Action": [
"ec2:RunInstances"
],
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
"Null": {
"aws:RequestTag/Department": "true",
"aws:RequestTag/Name": "true"
}
}
}
]
}
但是这个政策只适用于提到的条件1。如果缺少任何一个标签,我们仍然能够创建实例。我还了解到我们不能在组织 SCP 中使用“允许”操作。
尝试为每个标签指定一个语句,通过在相同条件下指定多个标签,如果存在任何标签,则允许执行该操作。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyEC2CreationSCP1",
"Effect": "Deny",
"Action": [
"ec2:RunInstances"
],
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
"Null": {
"aws:RequestTag/Department": "true"
}
}
},
{
"Sid": "DenyEC2CreationSCP2",
"Effect": "Deny",
"Action": [
"ec2:RunInstances"
],
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
"Null": {
"aws:RequestTag/Name": "true"
}
}
}
]
}