0
0
AwsConceptBeginner · 3 min read

What is Origin in CloudFront: Simple Explanation and Example

In CloudFront, an origin is the source location where your content lives, such as an S3 bucket or a web server. CloudFront fetches content from this origin to deliver it quickly to users worldwide.
⚙️

How It Works

Think of CloudFront as a delivery service and the origin as the warehouse where your products (content) are stored. When someone orders a product, CloudFront goes to the origin to get it and then delivers it to the customer.

The origin can be an AWS S3 bucket, an HTTP server, or other storage locations. CloudFront caches copies of your content at edge locations near users to speed up delivery. When a user requests content, CloudFront first checks if it has a cached copy; if not, it fetches it from the origin.

💻

Example

This example shows how to define an origin in a CloudFront distribution using AWS CloudFormation. It sets an S3 bucket as the origin for the distribution.

yaml
Resources:
  MyCloudFrontDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        Enabled: true
        Origins:
          - Id: MyS3Origin
            DomainName: my-bucket.s3.amazonaws.com
            S3OriginConfig: {}
        DefaultCacheBehavior:
          TargetOriginId: MyS3Origin
          ViewerProtocolPolicy: redirect-to-https
          AllowedMethods:
            - GET
            - HEAD
          CachedMethods:
            - GET
            - HEAD
Output
Creates a CloudFront distribution that fetches content from the specified S3 bucket origin.
🎯

When to Use

Use an origin in CloudFront whenever you want to deliver content like websites, videos, or files to users quickly and reliably. The origin is where your original content is stored.

Common use cases include:

  • Serving a static website hosted in an S3 bucket.
  • Delivering media files from a web server.
  • Using a custom origin server for dynamic content.

CloudFront improves performance by caching content from the origin closer to users worldwide.

Key Points

  • An origin is the source of your content for CloudFront.
  • It can be an S3 bucket, HTTP server, or other storage.
  • CloudFront fetches content from the origin when needed.
  • Origins are configured when creating a CloudFront distribution.
  • Caching at edge locations reduces load on the origin and speeds delivery.

Key Takeaways

An origin is where CloudFront gets your original content to deliver to users.
Origins can be S3 buckets, web servers, or other storage locations.
CloudFront caches content from origins at edge locations to speed up delivery.
You configure origins when setting up a CloudFront distribution.
Using origins helps improve website and content performance globally.