Section 15: CloudFront Flashcards
T/F
* A) CloudFront is a Contend Delivery Network (CDN)
* B) improves read/write performance/user experience by caching content at the endge
* C) 216 point of presence globally (edge locaitons)
* D) DDOS protection (because worldword), integration with Shield, AWS Web App FIrewall
B is false. It’s just read performance/user experience
T/F
CloudFront origins
* A) S3 bucket: distributing files and caching them at the edge; enchanced security with CloudFront Origin Access Control; OAC is replacing Origin Access Identity (OAI); CloudFront can be used as an ingress (to upload files to S3)
* B) Custom Origin (HTTP): App Load balancer; ec2 instance; s3 website (must first enable bucket as static s3 website); any http backend you want
T
hey, random, but I just realized that I think you can host dynamic sites on static s3 sites. idk. check this out https://aws.amazon.com/blogs/architecture/create-dynamic-contact-forms-for-s3-static-websites-using-aws-lambda-amazon-api-gateway-and-amazon-ses/.
T/F
* when client does an http request into your edge location, then edge location will see if it has your results in the cache. If it doesn’t, it’ll store results in the cache.
T
T/F
CloudFront - S3 as an origin
- so if I have one s3 bucket and it uses an Origin Access Control + S3 bucket policy to handle what accesses are and aren’t allowed then people from all over the world will first go through their nearest edge location and if the info is cached then the edge location won’t bother the s3 bucket at all. If the requested info isn’t already cached, your edge location will get the info rom your s3 bucket and then send it off to users with public internet access and then cache that info.
T
Which describes CloudFront and which describes Cross Region Replication? (add any important things to remember when answering)
- A) files cached for TTL (maybe a day); great for static content that must be available everywhere
- B) files updated near real-time; read only; great for dynamic content that needs to be available at low-latency in certain places
- A) Cloudfront: Global edge network; files cached for TTL (maybe a day); great for static content that must be available everywhere
- B) s3 cross region replication: must be set up for each region you want replication to happen; files updated near real-time; read only; great for dynamic content that needs to be available at low-latency in a few regionsT
you created a cloudfront distribution for your s3 bucket s3”//somebucketsnacks, but when you go to the index.html (not the public one, the one you see when you click the ‘Open’ button you forget about all the time), you still don’t see the beach.jpg that the code says should be there. What’s up?
Probably you forgot to update the bucket policy. Here’s the note you see when you selected somebucketsnacks on the cloudfront distribution form:
You must update the S3 bucket policy
CloudFront will provide you with the policy statement after creating the distribution.
hey what’s a good default root object for your cloudfront distrubution (idk why they call it a distribution, basically it just looks like a configuration form).
good old index.html
Hey, i know we had another card that said something else, but in this thing that I just copied from aws, note that neither Resource nor Action needed the brackets to indiciate list items. Maybe now you don’t need brackets unless you’re actually making a whole list?
{
“Version”: “2008-10-17”,
“Id”: “PolicyForCloudFrontPrivateContent”,
“Statement”: [
{
“Sid”: “AllowCloudFrontServicePrincipal”,
“Effect”: “Allow”,
“Principal”: {
“Service”: “cloudfront.amazonaws.com”
},
“Action”: “s3:GetObject”,
“Resource”: “arn:aws:s3:::somebucketsnacks/*”,
“Condition”: {
“StringEquals”: {
“AWS:SourceArn”: “arn:aws:cloudfront::781742995911:distribution/E2R2JSCYSROKEG”
}
}
}
]
}
T
If you set up cloud front to work with an S3 bucket, does the public use the s3 bucket’s url or your cloudfront distributions Distribution Domain Name?
Public uses your cloudfront distribution’s distrubution domain name
Which of the following, if any, is false (and what is the true version)?
Caching
* A) Cache lives at each CloudFront Edge Location
* B) CloudFront identifies each object in the cache using the Cache Lock
* C) Cache expires based on TTL
* D) you want to maximize cache hit ratio to minimize requests to the origin (requests to your s3 bucket or main whatever)
* E) you can invalidate part of the cache using the CreateInvalidation API
B is false. True version is:
* B) CloudFront identifies each object in the cache using the Cache Key
CloudFront Caching & Caching Policies
T/F
CloudFront Cache Key:
* by default, consists of hostname + resource portion of the url. hostname ex: mywebsite.com; resource portion of ex: “/content/stories/example-story.html” in content/stories/example-story.html?ref=123&whatever=something
T
How might you use S3, CloudFront edge locations, and CloudFront caching, and what does this picture have to do with it?
If I set up CloudFront and S3 together, which does a user reach first when trying to get to my website?
How does CloudFront identify objects in the cache?
Using the Cache Key
Do you want ot maximize or minimize the cache hit ratio, and why? (hint, to ____ requests to the origin)
Maximize, because you want to minimize requests to the origin
T/F
You can invalidate part of the cache using the CreateInvalidation API
True
T/F
CloudFront Cache Key is a unique identifier for every object in the cache.
True
T/F
* you can add other elements to the cache key using CloudFront Cache Policies (HTTP headers, cookies, query strings)
T
How might you use EC2, CloudFront Edge Locations, and CloudFront Caching together?
Describe this.
You have an app (UI and a backend) you’re serving on an EC2 instance. Sam is trying to some data to show up in the UI. Sam ends up first going to the nearest (depending on how you set things up) CloudFront (without them knowing, of course) Edge Location. Then the Edge Location checks out it’s (perhaps each Edge Location gets it’s own Cache? Things are getting fuzzy here) cache to see if the desired data is there. If it is, that’s a cache hit and the data goes back to fill in the user’s UI. If the desired data isn’t in the edge location cache, that’s a cache miss. The edge location reaches out to your Ec2 instance, gets the data, sticks a copy in the cache and returns a copy to Sam.
Update: I didn’t look at this any kind of thoroughly, but it does seem like each CF EL has it’s own cache.
update update: Cache lives at each CloudFront Edge Location <- from lectures
Does each CloudFront Edge Location have it’s own cache?
Yes
What’s an origin request header?
The Origin request header indicates the origin (scheme, hostname, and port) that caused the request. For example, if a user agent needs to request resources included in a page, or fetched by scripts that it executes, then the origin of the page may be included in the request.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin