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:
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)
- OS: Amazon Linux
- If using SAM CLI,
sam --version
:FROM public.ecr.aws/sam/build-nodejs14.x:latest
(should be1.55.0
) - AWS region:
us-east-1