Within the AWS console, it is possible to add a route to an API Gateway with the value of $default. This then removes the ability to input a HTTP method for the route.
The AWS console describes it as: "You can also specify one $default route per API. The $default route is invoked when the request to the API matches no other routes."
I am trying to recreate this using AWS CDK v2 (C# in this case) however am having no luck.
I integrate my API Gateway with a Lambda function based on an image stored in ECR, unfortunately I cannot get my API Gateway to be created with the $default route.
httpApi.AddRoutes(new AddRoutesOptions()
{
Path = "$default",
Integration = lambdaProxyIntegration
});
Doing the above, defaults the HTTP method to POST. It is also possible to specify a HTTP method like so:
httpApi.AddRoutes(new AddRoutesOptions()
{
Path = "$default",
Integration = lambdaProxyIntegration,
Methods = new [] {HttpMethod.ANY}
});
But there is no option equivalent to when you enter $default within the AWS console & it greys out the drop down to select a Http Method.
Any ideas?
Thanks