aws / aws/serverless-application-model
HttpApi circular dependency between RouteSettings and Route
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Description
### Description:
When creating HTTP API and Stage resources for the first time using `AWS::Serverless::HttpApi`, adding `RouteSettings` will fail for routes that you may be creating at the same time. (You cannot create the Route resource ahead of time because it needs to belong to the API that you are creating.) The circular dependency _can_ be resolved by first creating the `HttpApi` along with a defined `Route` resource, and then doing a subsequent update to add `RouteSettings` that will match it to existing routes, but this is inefficient and not a golden path.
### Steps to reproduce:
Example template snippet:
```yaml
Resources:
TestHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
FailOnWarnings: true
StageName: 'test'
RouteSettings:
'GET /path':
ThrottlingBurstLimit: 100
ThrottlingRateLimit: 100
TestRoute:
Type: AWS::ApiGatewayV2::Route
Properties:
ApiId: !Ref TestHttpApi
RouteKey: 'GET /path'
Target: !Join
- /
- - integrations
- !Ref TestIntegration
TestIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref TestHttpApi
# [...]
```
### Observed result:
The `AWS::ApiGatewayV2::Stage` resource results in a `CREATE_FAILED` in CloudFormation with the following error:
```
Unable to find Route by key GET /path within the provided RouteSettings (Service: AmazonApiGatewayV2; Status Code: 404; Error Code: NotFoundException; Request ID: x-x-x-x-x; Proxy: null))
```
### Expected result:
The expectation is that the SAM deploy can create the API, Stage and Route together in a single deployment, resolving the circular dependency of the Route needing to exist before the Stage's `RouteSettings` can be applied.
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: Amazon Linux
2. If using SAM CLI, `sam --version`: `FROM public.ecr.aws/sam/build-nodejs14.x:latest` (should be `1.55.0`)
3. AWS region: `us-east-1`
Contributor guide
Assessment
This issue has not been assessed yet.