API Gateway (v1): Cannot provide RestApi as parent for Resource #24684
Labels
@aws-cdk/aws-apigateway
Related to Amazon API Gateway
feature-request
A feature should be added or improved.
p2
Describe the bug
When defining a
Resource
separately from aRestApi
I am unable to provide theRestApi
as the parent for theResource
despite documentation suggesting otherwise:This appears that it may have a flow-on effect when attempting to add a
CognitoUserPoolsAuthorizer
to the created resource, as it needs to be "attached to aRestApi
".Expected Behavior
To be able to provide a
RestApi
as the parent of aResource
and subsequently be able to attach aCognitoUserPoolsAuthorizer
to the resource.Current Behavior
When providing the
RestApi
as the parent the project cannot compile/synth.When providing the
RestApi
's root resource as the parent, or creating a wrapper forRestApi
that implementsAmazon.CDK.AWS.APIGateway.IResource
the project can compile, but fails synth with the following error:Reproduction Steps
Here's the constructor of a
Stage
that is used to deploy the offending resources:As you can see this sample does use some custom constructs, especially relating to the
BaseDotNetFunction
andauth
(which is used in theCognitoUserPoolsAuthorizerProps
to provide a user pool).Possible Solution
Having
Amazon.CDK.AWS.APIGateway.IResourceProps.Parent
accept bothAmazon.CDK.AWS.APIGateway.IResource
andAmazon.CDK.AWS.APIGateway.RestApi
or haveAmazon.CDK.AWS.APIGateway.RestApi
implementAmazon.CDK.AWS.APIGateway.IResource
. Additionally, haveCognitoUserPoolsAuthorizer
properly recognise when it is attached to aRestApi
.Additional Information/Context
Of note, I am having to create the
apiResource
like this to resolve a cyclic dependency between a CloudFrontDistribution
, a CognitoUserPool
, and theapiResource
.CDK CLI Version
2.69.0 (build 60a5b2a)
Framework Version
.NET 7
Node.js Version
18.15.0
OS
Windows 11 Home (10.0.22621)
Language
.NET
Language Version
C# 11
Other information
No response
The text was updated successfully, but these errors were encountered: