Closed muddassirmunirmakula closed 2 months ago
Hwello, This is not possible in the path pattern definition of CloudFront today. Can you tell me why do you need this?
I see. So I came across a use case where I needed to process an image which has .PNG extension and I was looking for an easier way to resolve this than having to add Cache Behaviours for this and other usecases e.g. JPG, JPEG etc.
@muddassirmunirmakula Please see Path pattern section on Amazon CloudFront Developer Guide.
If the default path pattern (*
, capturing all requests) does not work for you, I would suggest deploying the solution on a specific prefix only, for example for paths that start with /images/*
.
To stay on the safe side, you can build in additional validation of the file extension against the regex in the viewer request function. If the extension doesn't match the regex, you can return 400 Bad Request response from the function to the clients.
Hi @achrafsouk , is there any way we can add case sensitive types too? i.e. I want the cache behaviour to accept all variant cases of png, i.e. PNG, Png, pNG etc. I have tried the following ^..png$, .[png,PNG,Png], .[pP][nN][gG] but all of these result in error: The parameter globPattern can only contain these characters: [a-zA-Z0-9_-.$/~"'&@:?+].