A SysOps Administrator is configuring a new multi-region trail in AWS CloudTrail for Account A (). The trail is configured to deliver logs to a centralized Amazon S3 bucket located in Account B (). The bucket is configured to encrypt all new objects using a Customer Managed Key (CMK) in AWS KMS located in Account B. The S3 bucket policy in Account B has been updated to allow log delivery from Account A, but CloudTrail displays a log delivery error and no log files are generated. Which configuration change will resolve this log delivery failure?
- Add a statement to the KMS key policy in Account B that grants the CloudTrail service principal (cloudtrail.amazonaws.com) the permissions to perform kms:GenerateDataKey* and kms:DescribeKey, using a condition to verify the source trail ARN:
{
"Sid": "Allow CloudTrail to encrypt logs",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": [
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*",
"Condition": {
"StringLike": {
"kms:EncryptionContext:aws:cloudtrail:arn": "arn:aws:cloudtrail:*:111111111111:trail/*"
}
}
}
Cevap - BAdd a statement to the S3 bucket policy in Account B that grants the CloudTrail service principal the permissions to perform kms:GenerateDataKey* and kms:DescribeKey on the encryption key:
{
"Sid": "Allow CloudTrail KMS encryption",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": [
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:us-east-1:222222222222:key/my-kms-key"
} - CAttach an IAM policy to the IAM execution role used by CloudTrail in Account A to allow key usage across accounts:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Allow KMS usage for CloudTrail",
"Effect": "Allow",
"Action": [
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:us-east-1:222222222222:key/my-kms-key"
}
]
} - DAttach an IAM policy to the CloudTrail administrator in Account A to allow passing the delivery role to CloudTrail across accounts:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Allow PassRole to CloudTrail",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::111111111111:role/CloudTrailDeliveryRole",
"Condition": {
"StringEquals": {
"iam:PassedToService": "cloudtrail.amazonaws.com"
}
}
}
]
}
Cevap
Add a statement to the KMS key policy in Account B that grants the CloudTrail service principal (cloudtrail.amazonaws.com) the permissions to perform kms:GenerateDataKey* and kms:DescribeKey, using a condition to verify the source trail ARN.
When a CloudTrail trail delivers logs to an Amazon S3 bucket encrypted with a Customer Managed Key (CMK), the CloudTrail service principal (cloudtrail.amazonaws.com) must have permissions to use the key. Because the key is in Account B and the trail is in Account A, the KMS key policy in Account B must explicitly permit the service principal to perform kms:GenerateDataKey* and kms:DescribeKey. Using the kms:EncryptionContext condition ensures that only the trail from Account A can use the key for log encryption.
Adım Adım Çözüm
Anahtar Kavram
Cross-account AWS CloudTrail log delivery with KMS encryption requires explicit KMS key policy permissions for the CloudTrail service principal.