-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Amazon.CDK.AWS.Apigatewayv2.HttpApi: missing field RouteSelectionExpression in HttpApiProps which is available in CfnApi (CDK .NET) #31104
Description
Describe the feature
When creating an HttpApi from the namespace Amazon.CDK.AWS.Apigatewayv2, there is no option to set the RouteSelectionExpression. This property is missing in HttpApiProps.
When creating the api with the L1 construct CfnApi from the namespace Amazon.CDK.AWS.Apigatewayv2, it is possible to set this property. This property is present in CfnApiProps.
Use Case
Being able to use an L2 construct for creating an HttpApi when setting the property RouteSelectionExpression is required instead of falling back to using the L1 construct CfnApi. This enables using other related L2 constructs as well instead of also falling back to L1 constructs.
Proposed Solution
Add the property RouteSelectionExpression to HttpApiProps of the L2 construct of HttpApi.
Other Information
Possible workarounds until the proposed feature is implemented below.
Workaround 1
Create the API using the L1 construct and set the property RouteSelectionExpression:
Amazon.CDK.AWS.Apigatewayv2.CfnApi someApi = new(
this,
"SomeApiIdentifier",
new Amazon.CDK.AWS.Apigatewayv2.CfnApiProps()
{
Name = "SomeApiName",
RouteSelectionExpression = "${request.method} ${request.path}",
});
Workaround 2
Create the API using an L2 construct and set the RouteSelectionExpression through the CfnApi constructed by the L2 construct:
Amazon.CDK.AWS.Apigatewayv2.HttpApi someHttpApi = new(this, "SomeHttpApiIdentifier", new Amazon.CDK.AWS.Apigatewayv2.HttpApiProps()
{
ApiName = "SomeHttpApiName",
});
if (someHttpApi.Node.DefaultChild is not Amazon.CDK.AWS.Apigatewayv2.CfnApi someHttpApiAsCfnApi)
{
throw new InvalidOperationException(
$"someHttpApi.Node.DefaultChild was expected to be of type {typeof(Amazon.CDK.AWS.Apigatewayv2.CfnApi)}");
}
someHttpApiAsCfnApi.RouteSelectionExpression = "${request.method} ${request.path}";
L2 Construct
L1 Construct
AWS CDK 2.151.0 API Reference
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.151.0
Environment details (OS name and version, etc.)
Windows 11