- Newest
- Most votes
- Most comments
Did you set the CloudFront distribution to forward the relevant query string parameters to the origin? The available options at the distribution level are explained in this documentation section: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesQueryString
You can also add query string parameters to origin requests without including them in the cache key with origin request policies: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-request-understand-origin-request-policy.html#origin-request-understand-origin-request-policy-settings
The behavior you're observing is consistent with how CloudFront handles requests to Amazon S3 origins. When you make a ListObjectsV2 request directly to the S3 bucket, S3 processes the request parameters, including the delimiter, as expected. However, when the same request goes through CloudFront, it appears that CloudFront is not passing along or honoring the delimiter parameter in the same way.
This difference in behavior occurs because CloudFront is designed to forward certain types of requests to S3, but it doesn't necessarily process or interpret all S3-specific query parameters in the same way that S3 does directly. CloudFront is primarily designed for content delivery and caching, not for replicating all S3 API functionalities.
When CloudFront receives a GET request with query parameters, it typically forwards the entire request to the S3 origin. However, CloudFront's behavior regarding S3-specific operations like ListObjectsV2 may not align perfectly with direct S3 API calls, especially when it comes to parameters like delimiters that affect how S3 processes and returns results.
It's important to note that CloudFront is optimized for serving and caching individual objects, rather than for listing operations. If you need to perform S3 API operations like ListObjectsV2 with specific parameters, it's generally recommended to do so directly against the S3 endpoint rather than through CloudFront.
If you require both the content delivery capabilities of CloudFront and the full functionality of S3 API operations, you might consider using separate endpoints: CloudFront for content delivery and direct S3 API calls for operations like listing objects with specific parameters.
Sources
Request and response behavior for Amazon S3 origins - Amazon CloudFront
HTTP 403 status code (Permission Denied) - Amazon CloudFront
Relevant content
asked 3 years ago
asked 4 years ago

Thank you. Using the legacy cache settings worked fine. However, it still doesn't work with an origin request policy. Anyway, your answer put me in the right track. I'll continue making more tests.
That's great. For reference, there's a specific way cache policies and origin request policies interact. It's summarised in this documentation article: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/understanding-how-origin-request-policies-and-cache-policies-work-together.html