Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create CloudFront distribution that accepts only signed URL’s with serverless

I want to create a web cloudFront distribution that can be accessed only using signed URL's.

On creating the distribution manually, there is an option Restrict Viewer Access under the Default Cache Behavior Settings.

enter image description here

I want to create the distribution using the serverless framework but I can't find the CloudFormation attribute for the Restrict Viewer Access property.

enter image description here

like image 303
Abhishek Pandey Avatar asked May 16 '19 13:05

Abhishek Pandey


People also ask

What is the difference between CloudFront signed URL and S3 signed URL?

In CloudFront, a signed URL allow access to a path. Therefore, if the user has a valid signature, he can access it, no matter the origin. In S3, a signed URL issue a request as the signer user.

Which types of origin does Amazon CloudFront support?

You can use several different kinds of origins with CloudFront. For example, you can use an Amazon S3 bucket, a MediaStore container, a MediaPackage channel, an Application Load Balancer, or an AWS Lambda function URL.


1 Answers

The documentation is totally not clear on this one. If the signing keys are in the same account you are deploying the CloudFront Distribution to you just need:

    TrustedSigners:
      - self

Note sometime in late 2020 CloudFront provided a way to create signing keys that does not involve using the AWS account root user. See these docs for more information. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html#choosing-key-groups-or-AWS-accounts

like image 167
cementblocks Avatar answered Sep 29 '22 10:09

cementblocks