Amazon CloudFront
This guide puts CloudFront in front of your bucket and connects it to Media Cloud Sync. CloudFront works with any bucket that has a public URL, and works best with Amazon S3.
AWS changes its console from time to time. If a screen looks different, follow the linked AWS guide for that step.
Step 1: Create the distribution
- In the CloudFront console, click Create distribution.
- Set the origin to your bucket’s address, such as
my-bucket.s3.us-east-1.amazonaws.com. - Choose how CloudFront reads the bucket:
- Public bucket: add the public-read policy from the S3 guide.
- Private bucket (recommended on S3): use Origin Access Control (OAC), and add the bucket policy AWS gives you. See AWS’s Restrict access to an Amazon S3 origin.
- Create the distribution and copy its domain name, such as
d1234abcd.cloudfront.net.
If your media needs CORS (fonts, SVGs, or video), use the managed CORS-S3Origin origin request policy on the behavior, so the Origin header reaches the bucket. See AWS’s managed origin request policies, and turn on Bucket CORS PRO.
Step 2: Add your own domain (optional)
To serve from media.example.com instead of the cloudfront.net address:
- Add the domain to the distribution as an alternate domain name.
- Attach an SSL certificate for it. CloudFront needs the certificate to be in AWS Certificate Manager in the
us-east-1region. - Create a CNAME DNS record pointing the domain to the distribution’s domain name.
Step 3: Connect it to Media Cloud Sync
- Go to Media Cloud Sync → Settings and click Change on the Delivery card.
- Choose Amazon CloudFront.
- Enter your domain under Use Custom Domain Name (CNAME), and click Save.
- Click Recheck on the Delivery card. It should say Objects are accessible to Read.
Step 4: Clear stale files (optional) PRO
Connect CDN Cache Purge with your Distribution ID, so files uploaded again under the same name are cleared. On Amazon S3 storage, it can use your S3 storage keys if they’re allowed to create invalidations. Otherwise enter separate keys.
Private Media PRO
With Amazon S3 storage, private files can be served through CloudFront signed URLs. You need a key group, a behavior for the private path restricted to it, and an OAC on the S3 origin. See Private Media behind a CDN.