</>
Skip to content
AWS lessons (28/47)

AWS — CloudFront

What is CloudFront?

CDN service that delivers content with low latency globally.

Create distribution

aws cloudfront create-distribution \
  --origin-domain-name mybucket.s3.amazonaws.com \
  --default-root-object index.html

S3 + CloudFront

# Create OAI
aws cloudfront create-origin-access-identity \
  --cloud-origin-access-identity-config CallerReference=my-oai

# Update bucket policy
aws s3api put-bucket-policy \
  --bucket mybucket \
  --policy file://policy.json

Invalidation

aws cloudfront create-invalidation \
  --distribution-id E1234567890ABC \
  --paths "/*"

Price classes

ClassCoverage
PriceClass_AllAll edge locations
PriceClass_200US, Europe, Asia
PriceClass_100US, Europe only

Custom domains

aws cloudfront create-distribution \
  --origin-domain-name mybucket.s3.amazonaws.com \
  --aliases Items=mydomain.com Quantity=1 \
  --viewer-certificate ACMCertificateArn=arn:aws:acm:...

Behaviors

aws cloudfront create-distribution \
  --default-cache-behavior \
    ForwardedValues={QueryStrings=false,Cookies={Forward=none}}, \
    ViewerProtocolPolicy=redirect-to-https, \
    MinTTL=86400

Best practices

  1. Use HTTPS
  2. Enable compression
  3. Set appropriate cache policies
  4. Use invalidation wisely

Mini Practice

  1. Create a CloudFront distribution
  2. Connect to S3
  3. Set up custom domain
  4. Configure caching

Up Next

Continue with Route 53 - DNS Management.

Related Topics

Frequently Asked Questions about CloudFront

What is CloudFront in AWS?

CloudFront is a fundamental concept in AWS. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn CloudFront?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn CloudFront.

Why is CloudFront important in AWS?

CloudFront is essential for AWS development. Understanding this concept will help you write better code and solve real-world problems more effectively.