0
0
AWScloud~5 mins

Edge locations and CloudFront overview in AWS - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you want your website or app to load faster for people all over the world, you need a way to deliver content quickly no matter where they are. CloudFront uses many small data centers called edge locations close to users to speed up delivery and reduce delays.
When you want to serve images and videos quickly to users worldwide without delays
When you want to protect your website from sudden traffic spikes by caching content
When you want to reduce the load on your main server by delivering cached copies
When you want to improve user experience by lowering the time it takes to load your site
When you want to securely deliver content with encryption and access controls
Commands
This command lists all CloudFront distributions in your AWS account so you can see what content delivery setups you have.
Terminal
aws cloudfront list-distributions
Expected OutputExpected
DistributionList: Items: - Id: E1A2B3C4D5E6F7 DomainName: d1234abcd.cloudfront.net Status: Deployed LastModifiedTime: 2024-06-01T12:00:00Z Enabled: true Quantity: 1
This command shows detailed information about a specific CloudFront distribution, including its settings and edge locations used.
Terminal
aws cloudfront get-distribution --id E1A2B3C4D5E6F7
Expected OutputExpected
Distribution: Id: E1A2B3C4D5E6F7 Status: Deployed DomainName: d1234abcd.cloudfront.net DistributionConfig: Enabled: true Origins: Items: - Id: my-origin DomainName: myapp.example.com DefaultCacheBehavior: TargetOriginId: my-origin ViewerProtocolPolicy: redirect-to-https LastModifiedTime: 2024-06-01T12:00:00Z
--id - Specifies the ID of the CloudFront distribution to get details for
This command retrieves the configuration settings of the CloudFront distribution, useful for reviewing or updating cache behaviors and origins.
Terminal
aws cloudfront get-distribution-config --id E1A2B3C4D5E6F7
Expected OutputExpected
DistributionConfig: CallerReference: 20240601120000 Comment: Example CloudFront distribution Enabled: true Origins: Items: - Id: my-origin DomainName: myapp.example.com DefaultCacheBehavior: TargetOriginId: my-origin ViewerProtocolPolicy: redirect-to-https PriceClass: PriceClass_100
--id - Specifies the distribution ID to get the configuration for
Key Concept

If you remember nothing else from this pattern, remember: CloudFront uses edge locations worldwide to deliver your content faster by caching it close to your users.

Common Mistakes
Trying to access CloudFront content using the origin server URL instead of the CloudFront domain name
This bypasses the edge locations and caching, causing slower delivery and more load on your origin server
Always use the CloudFront distribution domain name (like d1234abcd.cloudfront.net) to access your content
Not enabling the distribution after creating it
The distribution will not serve content until it is enabled, so users will get errors or no content
Make sure the Enabled flag is set to true when creating or updating the distribution
Summary
Use 'aws cloudfront list-distributions' to see your CloudFront setups.
Use 'aws cloudfront get-distribution' with the distribution ID to see details including edge locations.
Use 'aws cloudfront get-distribution-config' to review or update your distribution settings.
CloudFront speeds up content delivery by caching content at edge locations near users.
Always access your content through the CloudFront domain to benefit from caching and speed.