amplify-category-api
amplify-category-api copied to clipboard
API Gateway - Customise DEFAULT_5XX gateway response
Amplify CLI Version
12.12.4
Question
I would like to customise the response template for DEFAULT_5XX gateway response (see image below).
I tried to override the API in my Amplify project by using the code following code but always fail to build the project.
export function override(
resources: AmplifyApiRestResourceStackTemplate,
amplifyProjectInfo: AmplifyProjectInfo
) {
new CfnGatewayResponse(resources.restApi.stack, 'MyGatewayResponse', {
restApiId: resources.restApi.ref,
responseType: 'DEFAULT_5XX',
statusCode: '500',
responseTemplates: {
'application/json': JSON.stringify({ message: 'Internal Error' }),
},
});
}