This rule ensures that CloudFront distributions have a default root object configured for better accessibility.
Rule | CloudFront distributions should have a default root object configured |
Framework | AWS Foundational Security Best Practices |
Severity | ✔ Critical |
CloudFront Default Root Object Configuration
Rule Description
CloudFront distributions should have a default root object configured to enhance security and user experience. The default root object allows CloudFront to serve a specific file when a user accesses the root URL of your distribution.
Rule Explanation
Setting a default root object ensures that users accessing the root domain or URL of your CloudFront distribution are served with a specific file, like an index.html or index.php file. This ensures a consistent user experience and minimizes the risk of exposing sensitive information or directory listings.
Rule Remediation
To configure a default root object in your CloudFront distribution, follow these steps:
Troubleshooting Steps
If you face any issues while configuring the default root object for your CloudFront distribution, consider the following troubleshooting steps:
Additional Considerations
Example Code
If you prefer to configure the default root object using AWS Command Line Interface (CLI), you can use the following command:
aws cloudfront update-distribution --id DISTRIBUTION_ID --default-root-object FILENAME
Replace
DISTRIBUTION_ID
with the actual ID of your CloudFront distribution, and FILENAME
with the desired default root object filename.Please note that AWS CLI should be configured with appropriate permissions and credentials before executing the command.
Conclusion
Configuring a default root object for your CloudFront distribution is a recommended security best practice that provides a smoother user experience and ensures consistency when accessing the root URL. By following the provided remediation steps, you will be able to configure the default root object and enhance the security of your AWS infrastructure.