Search code examples
amazon-web-servicesamazon-s3amazon-cloudfront

Access protected S3 bucket using CloudFront


I have a S3 bucket that can be accessed only using signed urls. Until now i generated signed urls using GeneratePresignedUrlRequest (Java). Now i want to access my bucket through CloudFront. The question is how i generate a signed url in this case?


Solution

  • It's all in the docs.

    http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls-overview.html

    You also have to properly configure the interaction between Cloudfront and S3.

    http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html

    If you are a programmer, you will also find it interesting and important that Cloudfront uses a different set of base64 rules than S3. Instead of percent-encoding the unsafe characters + = / in a signed url, Cloudfront expects them to be transliterated into -_~ respectively.