Signed Urls for CloudFront <-> S3 with API

We create here the Api Gateway with Cognito Authentication to create secure time limited links (signed urls) for CloudFront resources. The API gateway send requests to a Lambda function. The Lambda uses the CloudFront private key to create the signed urls.

  • https://:::APIGATEWAY::::.execute-api.eu-central-1.amazonaws.com/Prod/signed_link?urn=your_video.mp4&lt=180 urn is required lt is optional (10 minutes is set by default configured as maximumLifeTime defaultLifeTime, maximum is 600 minutes, configured as maximumLifeTime in your function)

Creating a CloudFormation key pair

  1. Create a CloudFront key pair using the root account (described in this doc): https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html#private-content-creating-cloudfront-key-pairs You will need the keypairId and the private key to create the secured links.

Set up your CloudFront and S3 Bucket

Lambda

  • It is completely parameterized using environment variables.
  • You can change the parameters any time directly in the lambda function.

Links