Created
October 25, 2018 19:07
-
-
Save eMahtab/5c6fe4a983fac976240c6c0a95943295 to your computer and use it in GitHub Desktop.
Generating CloudFront Signed URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cfsign = require('aws-cloudfront-sign'); | |
var currentTime = new Date() | |
var currentTimeinMillis = currentTime.getTime(); | |
console.log("---------------------------------------------------------------------------") | |
console.log('Current Time is '+currentTime) | |
var expiryTime = currentTimeinMillis + 1*60*1000; | |
console.log("---------------------------------------------------------------------------") | |
console.log('Signed URL wiil expire on '+new Date(expiryTime)); | |
var signingParams = { | |
keypairId: process.env.KEY_PAIR_ACCESS_KEY_ID, | |
privateKeyPath: '/Users/mahtab.alam/Downloads/cloudfront-key-pair-private-key.pem', | |
expireTime: expiryTime | |
} | |
// Generating a signed URL | |
var signedUrl = cfsign.getSignedUrl( | |
'http://aaaaaaaaaaaaaa.cloudfront.net/cat1.jpeg', | |
signingParams | |
); | |
console.log("---------------------------------------------------------------------------") | |
console.log('Signed URL ') | |
console.log("---------------------------------------------------------------------------") | |
console.log(signedUrl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment