A SysOps Administrator is configuring VPC Flow Logs to capture traffic for a production VPC and deliver the logs to an Amazon S3 bucket. The S3 bucket is encrypted using an AWS Key Management Service (AWS KMS) customer managed key. After creating the flow log, the administrator notes that no log files are being written to the S3 bucket, and the flow log status shows delivery errors. Which two configurations must the administrator apply to resolve this issue?
- Update the Amazon S3 bucket policy to allow the delivery.logs.amazonaws.com service principal to perform the s3:PutObject and s3:GetBucketAcl actions.Answer
- Update the AWS KMS key policy to allow the delivery.logs.amazonaws.com service principal to perform the kms:GenerateDataKey action.Answer
- CAssociate an IAM service role with the flow log that has a trust policy for vpc-flow-logs.amazonaws.com and ensure the administrator has iam:PassRole permission.
- DModify the Amazon S3 bucket lifecycle configuration to adjust log retention settings to prevent premature deletion of flow log files.
- ECreate an Amazon EventBridge rule that detects flow log status changes and triggers an AWS Systems Manager Automation runbook to repair the log group stream.
Answer
Update the Amazon S3 bucket policy to allow the delivery.logs.amazonaws.com service principal to perform the s3:PutObject and s3:GetBucketAcl actions, and update the AWS KMS key policy to allow the delivery.logs.amazonaws.com service principal to perform the kms:GenerateDataKey action.
When VPC Flow Logs are delivered to an Amazon S3 bucket, they use the AWS Log Delivery service principal (delivery.logs.amazonaws.com). The target S3 bucket policy must allow this principal to perform s3:PutObject and s3:GetBucketAcl. Additionally, if the bucket is encrypted with a customer managed AWS KMS key, the KMS key policy must allow the delivery.logs.amazonaws.com principal to use the key via kms:GenerateDataKey to encrypt the uploaded log files.
Step-by-Step Solution
Key Concept
VPC Flow Logs S3 delivery with KMS encryption requires both bucket policy write permissions and KMS key policy generate data key permissions for the Log Delivery service principal.