Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon.CDK.AWS.Apigatewayv2.HttpApi: missing field RouteSelectionExpression in HttpApiProps which is available in CfnApi (CDK .NET) #31104

Closed
2 tasks
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@tombeuckelaere
Copy link

tombeuckelaere commented Aug 14, 2024

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

@tombeuckelaere tombeuckelaere added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2024
@github-actions github-actions bot added the @aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 label Aug 14, 2024
@ashishdhingra ashishdhingra self-assigned this Aug 14, 2024
@ashishdhingra ashishdhingra added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2024
@ashishdhingra
Copy link
Contributor

CfnApiProps does support property routeSelectionExpression, mapping to RouteSelectionExpression property of AWS::ApiGatewayV2::Api resource.

@ashishdhingra ashishdhingra added effort/medium Medium work item – several days of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Aug 14, 2024
@ashishdhingra ashishdhingra removed their assignment Aug 14, 2024
@mergify mergify bot closed this as completed in #31373 Sep 13, 2024
@mergify mergify bot closed this as completed in 36baf51 Sep 13, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.