How to Decrypt S3 content while serving through the Cloudfront.

0

I am aware of this post https://aws.amazon.com/blogs/networking-and-content-delivery/serving-sse-kms-encrypted-content-from-s3-using-cloudfront/. But it doesnt say anything about SSE-C type of encryption.

My implementation was, I am using AWS KMS to create DEK for each folder and save the wrapped DEK in DB / S3 for further use. Now if I want to decrypt this content while serving through cloudfront, what is the approach.

2개 답변
2
수락된 답변

To serve S3 content encrypted with SSE-C through CloudFront, you can use a Lambda@Edge function to handle the encryption keys. Here's a high-level approach to how you could set this up:

Create a Lambda@Edge Function:

Implement a Lambda@Edge function that will be triggered on viewer request events. This function should:

  • Retrieve the encrypted Data Encryption Keys (DEK) for the requested object from your DB or S3.
  • Decrypt the DEK using AWS KMS.
  • Add the decrypted DEK as the x-amz-server-side-encryption-customer-key header in the request forwarded to S3.

Deploy the Lambda@Edge Function:

Deploy your Lambda@Edge function to AWS Lambda, and associate the function with your CloudFront distribution, and ensure that the function has the necessary permissions to:

  • Access the DEKs from your DB/S3.
  • Decrypt keys using AWS KMS.
  • Write logs to CloudWatch for monitoring and debugging.

Configure CloudFront: Configure your CloudFront distribution to trigger the Lambda@Edge function on viewer request events. Ensure your S3 bucket policy allows access from CloudFront with the necessary SSE-C headers.

If this has answered your question or was helpful, accepting the answer would be greatly appreciated. Thank you!

profile picture
전문가
답변함 3달 전
profile picture
전문가
검토됨 2달 전
profile pictureAWS
전문가
검토됨 3달 전
0

Thank you for the quick response.

Continuing to that, I have couple of other questions, it would be a great help if you can answer.

  1. How do I encrypt the existing S3 objects by providing separate DEK for each folder, because AWS Batch doesn't seem to have that option.
  2. And replication, in case of disaster
Sateesh
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠