serverless-apigateway-service-proxy
serverless-apigateway-service-proxy copied to clipboard
Returning custom error page on 4XX S3 Integration Response
Hello,
Thank you for an excellent package. I'm using it to proxy requests to private s3 bucket so I serve a website out of s3 bucket through the APIGW.
I have 3 questions:
-
On 4XX errors I'd like to serve custom error page error.html How do I configure it with the plugin?
-
I'm not quite clear on why should we use 'integration.request.path.object': 'context.requestId' like so and what's the purpose of it:
requestParameters:
# if requestParameters has a 'integration.request.path.object' property you should remove the key setting
'integration.request.path.object': 'context.requestId'
- I'm also not quite clear on the usage of key in your examples:
key:
pathParam: myKey
vs
key: static-key.json # use static key
vs
key:
queryStringParam: key # use query string param
Let's say I have a URL with something like https://domain.com/signin?code=XXX?state=YYY How do I use keys in this case? Redirect it to specific page?
My current config is:
custom:
apiGatewayServiceProxies:
- s3:
path: / # use path param
method: get
action: GetObject
bucket:
Ref: FrontendBucket
pathOverride: 'index.html'
cors: true
roleArn: # Optional. A default role is created when not configured
Fn::GetAtt: [apiGatewayServiceProxiesRole, Arn]
requestParameters:
# if requestParameters has a 'integration.request.path.object' property you should remove the key setting
'integration.request.path.object': 'context.requestId'
- s3:
path: /{myPath+}
method: get
action: GetObject
pathOverride: '{myPath}'
bucket:
Ref: FrontendBucket
cors: true
roleArn: # Optional. A default role is created when not configured
Fn::GetAtt: [apiGatewayServiceProxiesRole, Arn]
requestParameters:
# if requestParameters has a 'integration.request.path.object' property you should remove the key setting
'integration.request.path.myPath': 'method.request.path.myPath'
'integration.request.path.object': 'context.requestId'