A SysOps Administrator is setting up an organization-wide AWS CloudTrail trail in Account A (). The trail is configured to deliver log files to an Amazon S3 bucket located in Account B (). The administrator wants to encrypt these log files using a customer managed KMS key that is also located in Account B. The S3 bucket policy in Account B has already been configured to allow the `cloudtrail.amazonaws.com` service principal to write logs. However, when the administrator enables KMS encryption on the trail using the KMS key from Account B, CloudTrail log delivery fails.
Which configuration change must the administrator make to resolve this delivery issue?
- Modify the KMS key policy in Account B to allow the `cloudtrail.amazonaws.com` service principal to perform `kms:GenerateDataKey*` and `kms:DescribeKey` actions, with a condition matching the trail ARN from Account A in the `kms:EncryptionContext:aws:cloudtrail:arn` key.Cevap
- BConfigure an IAM role in Account A with permissions to use the KMS key in Account B, and modify the CloudTrail configuration to assume this role when delivering logs.
- CAttach a customer managed IAM policy to the CloudTrail service-linked role in Account A that allows `kms:GenerateDataKey*` and `kms:DescribeKey` actions on the Account B KMS key resource.
- DModify the S3 bucket policy in Account B to include `kms:GenerateDataKey*` permissions within the statement that allows CloudTrail to write to the bucket.
Cevap
Modify the KMS key policy in Account B to allow the `cloudtrail.amazonaws.com` service principal to perform `kms:GenerateDataKey*` and `kms:DescribeKey` actions, with a condition matching the trail ARN from Account A in the `kms:EncryptionContext:aws:cloudtrail:arn` key.
To allow AWS CloudTrail (a service running on behalf of Account A) to encrypt log files using a KMS key in Account B, the KMS key policy in Account B must explicitly permit the `cloudtrail.amazonaws.com` service principal to use the key. Specifically, CloudTrail requires the `kms:GenerateDataKey*` action to generate data keys for encrypting the log objects, and `kms:DescribeKey` to check key properties. Additionally, using the `kms:EncryptionContext:aws:cloudtrail:arn` condition key restricts key usage to the specific trail in Account A, ensuring proper security boundaries.
Adım Adım Çözüm
Anahtar Kavram
Cross-account AWS Service access to KMS CMKs requires explicit configuration of the KMS key policy to permit the service principal, constrained by specific encryption contexts.