CloudFront Flashcards

1
Q

What is CloudFront (from a high level)?

A

CDN - Content Delivery Network, with 216 global points of access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some benefits of using CloudFront?

A
  • Improves read performances as content is cached at the edge (i.e., edge locations)
  • DDoS protection, integration with Shield, AWS Web Application Firewall
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What origins does CloudFront offer?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between CloudFront and S3 Cross Region Replication?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a strategy for maximizing cache hits?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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?

A
  • Create an invalidation on the object path
    This will invalidate the cache and force CloudFront to fetch the latest version again.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What would prevent CloudFront from fetching information from an EC2 instance?

A

The instance is private, and so CloudFront cannot fetch data from it (as it is a public CDN).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you allow CloudFront to interact with EC2 instances?

A
  • Allow public IP of edge locations within the instance
  • Use a public ALB with a security group, and allow the security group of the ALB to the EC2 instance.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is CloudFront Geo Restriction, and what is the use case?

A
  • Restrict access based on location with a blocklist/allowlist
  • Country is determined using a 3rd party Geo-IP database
    Use case: Copyright Laws to control access to content.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between Signed URL for CloudFront vs S3

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you sign CloudFront URLs?

A
  • Use a trusted key group
  • Use an AWS account that contains a CloudFront Key Pair
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why is one method of signing URLs preferred over the other

A
  • Trusted key group creates and rotates keys (and IAM for API security)
  • Using a Key Pair requires managing the keys using the root account and the AWS console (should not be using root account for this)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you allow EC2 instances to create signed URLs?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How is CloudFront priced?

A
  • Cost is of data out per edge location
  • This cost varies based on location
  • Price classes can offer cost reduction by restricting number of regions available:
    -> Price Class All - all regions, best performance, most expensive
    -> Price Class 200 - most regions but excludes most expensive regions
    -> Price Class 100 - only the least expensive regions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does CloudFront Multiple Origin work?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the function and purpose of CloudFront Origin Groups?

A

Increase high-availability and do failover
- One primary and one secondary origin (failover to secondary)

16
Q

How can you achieve Region Level High Availability/Disaster Recovery?

A

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

17
Q

What is Field Level Encryption?

A

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.

18
Q

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?

A

Configure your CloudFront Distribution and create an Origin Access Control, then update your S3 Bucket Policy to only accept requests from your CloudFront Distribution.

19
Q

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?

A

CloudFront Signed Cookies