Profile Applicability:
Level 2
Description
A default root object in Amazon CloudFront is the object (typically an HTML file) that CloudFront returns when a user requests the root URL of your distribution, such as https://www.example.com/ without specifying a specific file name (like index.html). Setting a default root object ensures that users are directed to a specific page, enhancing user experience and avoiding 404 errors.
Rationale
Improved User Experience: Provides a seamless user experience by directing users to a specific page.
Error Prevention: Avoids 404 errors when the root URL is accessed without specifying a file name.
Consistent Branding: Ensures that users are always directed to a consistent starting point, such as a homepage.
Impact
Pros:
Enhances user experience by directing users to a specific page.
Prevents 404 errors when the root URL is accessed.
Ensures consistent branding and user navigation.
Cons:
Requires additional configuration to set up the default root object.
Potential temporary disruption during the setup process.
Default Value
By default, CloudFront distributions do not have a default root object configured. This must be explicitly set up.
Pre-Requisite
IAM Permissions:
cloudfront:GetDistribution
cloudfront:UpdateDistribution
AWS CLI installed and configured.
Remediation
Test Plan:
Using AWS Console:
Sign in to the AWS Management Console.
Navigate to the CloudFront Dashboard.
Click on the Distributions tab in the top left navigation menu.
Select the Distribution you want to audit.
Click on the General tab in the top menu.
Check if a default root object is configured.
Using AWS CLI:
Check Default Root Object Status:
aws cloudfront get-distribution --id <distribution-id> --query 'Distribution.DistributionConfig.DefaultRootObject'
Implementation Steps:
Using AWS Console:
Sign in to the AWS Management Console.
Navigate to the CloudFront Dashboard.
Click on the Distributions tab in the top left navigation menu.
Select the Distribution you want to modify.
Click on the General tab in the top menu.
Click Edit to modify the distribution settings.
Set the Default Root Object (e.g., index.html).
Click Save changes to save the changes.
Using AWS CLI:
Set the Default Root Object:
aws cloudfront update-distribution --id <distribution-id> --distribution-config file://distconfig-root-object.json
Backout Plan
Using AWS Console:
Navigate to the CloudFront Dashboard.
Select the Distribution.
Click Edit Attributes.
Revert to the previous configuration by removing the default root object.
Click Save changes to save the changes.
Using AWS CLI:
aws cloudfront update-distribution --id <distribution-id> --distribution-config file://distconfig-original.json