'Setting API Gateway URL Path Parameter mapping with the CDK
I'm attempting to deploy a greedy path parameter for a proxy endpoint in API Gateway. However every time I deploy the next time I try to use the proxying path, it fails to transform the proxy value in the path parameter. The only way I've found to set the mapping for the proxy parameter is in the Console via the method testing in the "Integration Request" tab UI pictured above. However I'm using the CDK to deploy this and cannot find the equivalent setting in the CDK documentation. I've tried below but with no success
api.root.addProxy({
defaultIntegration: new apigw.HttpIntegration(`OLD_ENDPOINT/{proxy}`),
defaultMethodOptions: {
requestParameters: {
'method.request.path.proxy': true,
},
},
});
Solution 1:[1]
You have to combine the MethodOptions and IntegrationOptions like that:
api.root.addProxy({
defaultIntegration: new HttpIntegration('NEW_API_URL/{proxy}', {
httpMethod: 'ANY',
options: {
requestParameters: {
'integration.request.path.proxy': 'method.request.path.proxy',
},
},
}),
defaultMethodOptions: {
requestParameters: {
'method.request.path.proxy': true,
},
},
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |