What is CloudFront (from a high level)?
CDN - Content Delivery Network, with 216 global points of access.
What are some benefits of using CloudFront?
What origins does CloudFront offer?
S3 bucket
-> For distributing files and caching them at the edge
-> Enhanced security with CloudFront Origin Access Control (OAC)
-> CloudFront can be used as an ingress (to upload files to S3)
Custom Origin (HTTP)
-> ALB
-> EC2 instance
-> S3 website
(-> Any HTTP backend you want)
What is the difference between CloudFront and S3 Cross Region Replication?
CloudFront
- Global Edge network
- Files are cached for a TTL
- Great for static content that must be available everywhere
S3 Cross Region Replication
- Must be setup for each region you want replication to happen
- Files are update in near real-time
- Read only
- Great for dynamic content that needs to be available at low latency in few regions
What is a strategy for maximizing cache hits?
Separate out static and dynamic distributions
e.g.,
Static requests
- Simple request with no headers/session caching rules is forwarded to S3
Dynamic requests
- Cache based on correct headers and cookie, forwarded to ALB and EC2
What do you have to do when uploading a new version of a file to S3 in order to get the new version through CloudFront, and why?
What would prevent CloudFront from fetching information from an EC2 instance?
The instance is private, and so CloudFront cannot fetch data from it (as it is a public CDN).
How can you allow CloudFront to interact with EC2 instances?
What is CloudFront Geo Restriction, and what is the use case?
What is the difference between Signed URL for CloudFront vs S3
CloudFront:
- Allow access to a path, no matter the origin
- Account wide key-pair; only the root can manage it
- Can filter by IP, path, date, expiration
- Can leverage caching features
S3:
- Issue a request as the person who pre-signed the URL
- Uses the IAM key of the signing IAM principal
- Limited lifetime
How can you sign CloudFront URLs?
Why is one method of signing URLs preferred over the other
How can you allow EC2 instances to create signed URLs?
Use a trusted key group
- Generate a public/private key
- The private key is used by your applications to sign URLs
- The public key (uploaded) is used by CloudFront to verify URLs
How is CloudFront priced?
How does CloudFront Multiple Origin work?
Route to different kinds of origins based on content type
- Based on path pattern
e.g.,
/images/* - set the cache behaviour to access content through an ALB
/* - set the cache behaviour to access content through S3 bucket
What is the function and purpose of CloudFront Origin Groups?
Increase high-availability and do failover
- One primary and one secondary origin (failover to secondary)
How can you achieve Region Level High Availability/Disaster Recovery?
Use S3 + CloudFront Origin Groups
- 2 buckets, A and B, in different regions, with replication from A to B
- A is primary origin, B is failover
What is Field Level Encryption?
Encryption of data at Edge Location using the public key.
- Specify up to 10 fields on a POST request that you would like to be encrypted
- Specify the public key to be used
- Data is decrypted at web server using the private key.
You have a static website hosted on an S3 bucket. You have created a CloudFront Distribution that points to your S3 bucket to better serve your requests and improve performance. After a while, you noticed that users can still access your website directly from the S3 bucket. You want to enforce users to access the website only through CloudFront. How would you achieve that?
Configure your CloudFront Distribution and create an Origin Access Control, then update your S3 Bucket Policy to only accept requests from your CloudFront Distribution.
A website is hosted on a set of EC2 instances fronted by an Application Load Balancer. You have created a CloudFront Distribution and set up its origin to point to your ALB. What should you use to provide access to hundreds of private files served by your CloudFront distribution?
CloudFront Signed Cookies