-
Notifications
You must be signed in to change notification settings - Fork 4k
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
apigateway: Unable to import existing API Gateway with Stage (Stage.from_stage_attributes
returns __StageBaseProxy
)
#30385
Comments
Stage.from_stage_attributes
returns __StageBaseProxy
)
@fabian4cast Good afternoon. I was able to reproduce the issue by:
The reason you are getting the error is that @jsii.interface(jsii_type="aws-cdk-lib.aws_apigateway.IRestApi")
class IRestApi(_IResource_c80c4260, typing_extensions.Protocol):
@builtins.property
@jsii.member(jsii_name="restApiId")
def rest_api_id(self) -> builtins.str:
'''The ID of this API Gateway RestApi.
:attribute: true
'''
...
@builtins.property
@jsii.member(jsii_name="deploymentStage")
def deployment_stage(self) -> "Stage":
'''API Gateway stage that points to the latest deployment (if defined).'''
...
@deployment_stage.setter
def deployment_stage(self, value: "Stage") -> None:
... Using the similar code in TypeScript reports same issue where IRestApi.deploymentStage is of type Stage. I'm unsure about the workaround right now. Would review this with team. Thanks, |
Stage.from_stage_attributes
returns __StageBaseProxy
)Stage.from_stage_attributes
returns __StageBaseProxy
)
Hi The
We do not have any public reference on migrating from serverless framework to CDK as there might be some different migration strategies, each has its pros and cons to consider. I would suggest to reach out to AWS specialists to work together with your team to help you define the migration strategy. Feel free to ping me on cdk.dev if you need any further assistance. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Hey, thanks for the replies! @ashishdhingra as of my experience it often is not so much of an issue whether a method returns e.g.
For this is, however, a blocker for us, but we are considering to find any other workaround that might help us for now. |
@fabian4cast - not sure if/how you resolved this, but I did the following:
Hope that helps someone |
Describe the bug
Hello folks,
We previously deployed a Stack with an API Gateway via the Serverless framework, and decided to switch to CDK and hence rewrote the Stack configuration in CDK.
We managed to let CDK recognize most of the existing resources by overriding the logical IDs, e.g.
This way CDK recognizes (or imports) the resources in the already existing Stack and updates them (if required) instead of deleting and re-creating. This works well for the RestApi. However, we also have a Stage that already exists for the RestApi, and doing the same with the existing Stage leads to the error
Stage already exists
. Here it seems that CDK is not able to recognize the existing Stage and just import it, but attempts to create a new one with the same name instead.Hence, we attempted to just reference the existing Stage using
aws_apigateway.Stage.from_stage_attributes
asand this then fails because
According to the docs
aws_apigateway.Stage.from_stage_attributes
should returnIStage
, but apparently it seems to return_StageBaseProxy
instead.Thanks for the help in advance!
Moving from Serverless to CDK has generally been a great experience, at least from the point where we discovered the
override_logical_id
"hack", since that allowed us to import all previously existing resources that were part of the stacks, and didn't requirecdk import
.Expected Behavior
aws_cdk.aws_apigateway.Stage.from_stage_attributes
returnsaws_cdk.aws_apigateway.IStage
Current Behavior
aws_cdk.aws_apigateway.Stage.from_stage_attributes
returnsaws_cdk.aws_apigateway._StageBaseProxy
Reproduction Steps
then
cdk synth
Possible Solution
No response
Additional Information/Context
It is also worth mentioning that the Stage (and its corresponding Deployment) do currently not appear as a Resource of the Stack as of the state Serverless created! It just exists in the AWS API Gateway Console (or area, idk how to describe it). It seems that it was previously implicitly created by setting
Stage
attributes in Serverless, e.g.CDK CLI Version
2.138.0 (build 6b41c8b)
Framework Version
No response
Node.js Version
v21.7.3
OS
Ubuntu 22.04 LTS
Language
Python
Language Version
3.12.0
Other information
The text was updated successfully, but these errors were encountered: