我试图要求使用特定KMS密钥加密放入存储桶的所有对象。我设法要求KMS加密,但密钥规范不起作用。这是我现有的政策(没有真正的桶名和ID):
{
"Version": "2012-10-17",
"Id": "PutObjPolicy",
"Statement": [
{
"Sid": "DenyInsecureCommunications",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::bucket1,
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
},
{
"Sid": "DenyIncorrectEncryptionHeader",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::bucket1/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "aws:kms",
"s3:x-amz-server-side-encryption-aws-kms-key-id": "arn:aws:kms:eu-central-1:123456789:key/12345-123-notmy-keyid-1234566"
}
}
},
{
"Sid": "DenyUnEncryptedObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::bucket1/*",
"Condition": {
"Null": {
"s3:x-amz-server-side-encryption": "true"
}
}
}
]
}
这正确地拒绝上传而没有指定任何服务器端加密,但它仍然允许使用默认的s3密钥。
答案 0 :(得分:4)
如果有多个条件运算符,或者单个条件运算符附加了多个键,则使用逻辑AND计算条件。
http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Condition
这表明双条件策略只会拒绝两个字符串不相等(即,如果未使用加密和,则密钥ID为错)。
分开测试
s3:x-amz-server-side-encryption
和
s3:x-amz-server-side-encryption-aws-kms-key-id
分为两个单独的Deny
政策声明应该是修复。