Search code examples
node.jsamazon-s3amazon-cloudfront

S3 with Cloudfront SignedURL


I am new to Node.js and currently using aws-cloudfront-sign package. It is working on public buckets. But when I am using private folders, it said Access Denied.

var cf = require('aws-cloudfront-sign');
var options = {
  keypairId: KEY,
  privateKeyPath: PATHTOPEMFILE
};

cf.getSignedUrl(CLOUDFRONTURL + directory + file, options);

It return a signedURL but showing Access Denied. What am I doing wrong? Or, is there any other way for S3 with Cloudfront SignedURL. Thanks.


Solution

  • It sounds like you maybe confusing signed URLs with origin access identities. Based on your description, it sounds like S3 is returning access denied to CloudFront because the folder/bucket is private. I would recommend taking a look at the documentation on configuring origin access identities, OAI.

    • Create OAI
    • Associate OAI with distribution
    • Update S3 bucket policy to grant GetObject to OAI