aws / aws/aws-cdk

(aws-apigatewayv2): add routes to imported httpapi (IHttpApi)

Open
#12,337 14 comments 43 reactions 0 assignees View on GitHub
@aws-cdk/aws-apigatewayv2 effort/medium feature-request feature/enhancement p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

Allow routes to be added to an existing HttpApi. Currently this is not an option

### Use Case

We currently have an api gateway connected to an alb via vpclink on the default route and are slowly peeling off services and converting them to lambdas. This is easily done by defining explicit routes for our services as we move them over. The problem is that these new services are built and managed in their own cdk projects (deployed via codepipeline cdk stacks in their projects) but since the api gateway is defined elsewhere it needs to be imported to add the routes.

It looks like the only option we have currently would be to move all rest service stacks into the project the api gateway is in but this will quickly lead to a bloated and inefficient build/deploy process

### Proposed Solution

allow routes to be added on IHttpApi or provide some other way to import an existing gateway and add routes

```
const api = HttpApi.fromHttpApiAttributes(this, 'gateway', {
httpApiId: 'myGateway',
});

api.addRoutes({
path,
methods,
integration,
});
```

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Research direction

Start with the aws-apigatewayv2 HttpApi/IHttpApi entry points, especially HttpApi.fromHttpApiAttributes and addRoutes. Compare how an imported API is represented with the proposed path, methods, and integration inputs; done means an imported HttpApi can accept routes from separate CDK projects without moving stacks.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
api, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.