It retrieves data from Amazon S3 bucket and distributes it to multiple datacenter locations.
It delivers the data through a network of data centers called edge locations. The nearest edge location is routed when the user requests for data, resulting in lowest latency, low network traffic, fast access to data, etc.
Set up
AWS Console - public bucket
Sign in to AWS management console.
Upload Amazon S3 and choose every permission public.
Go to CloudFront console: Select a delivery method for your content - > Get Started. 4.Origin Domain Name -> Amazon S3 bucket created.
Next, dafult, and Create Distribution button.
When the Status column changes from “In Progress” to “Deployed”, select the Enable option.
Wait around 15 minutes for the domain name to be available in the Distributions list.
Cloudformation - private bucket
graph LR;
A[Bucket]
B[Cloudfront]
C[User]
A -- bucket data --> B;
B -- bucket data --> C;
C --> B;
B -- request with OAI --> A;
BucketPolicy: Type:AWS::S3::BucketPolicy Properties: Bucket:private-bucket PolicyDocument: Version:'2012-10-17' Statement: -Effect:Allow Principal: AWS:!Sub'arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity' # you may get the recently created with '${CloudFrontOriginIdentity}' Action:'s3:GetObject' Resource:arn:aws:s3:::private-bucket/*