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 Respuestas
2
Respuesta aceptada

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
EXPERTO
respondido hace 3 meses
profile picture
EXPERTO
revisado hace 2 meses
profile pictureAWS
EXPERTO
revisado hace 3 meses
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
respondido hace 3 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas