I have an API Gateway REST API with an integration to S3. We don't want to directly expose the buckets and object keys so there is an authorizer that is taking a path parameter and returning an object key. This object key may contain a number of path parameters, eg, path/to/object. I want to be able to rewrite the integration path to include this.
When I try using a path variable the value is replaced but it's URL encoded, ie, path%2Fto%2Fobject so of course the S3 request fails. I don't see any way of replacing the path variable with a value that contains multiple path parameters. I've also tried the same thing using #context.requestOverride.path.XXX in a mapping template and it also ends up URL encoded. I've tried using $utils.urlDecode() but again the result is encoded.
Is there any way to replace a path variable with multiple path segments? Otherwise, is there a way to completely replace the path in a mapping template (not just specific path variables)? Or is there another way to achieve this eg can the object key be passed in a header?