-
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
API Gateway not working with custom Deployment/Stage resources #6068
Comments
Does anyone know any workaround for this issue, if it'll really require a fix? |
Thanks for reporting this @celiolatorraca. I acknowledge that this is a bug on the CDK side. |
The workaround is to add the following line for every instance of (deployment.node.defaultChild! as CfnResource).addDependsOn(method.node.defaultChild as CfnResource); |
…ecified Per the documentation from CloudFormation, when an explicit AWS::ApiGateway::Deployment resource is specified, it needs to contain an explicit 'DependsOn' field declared to all of the AWS::ApiGateway::Method resources that are part of the RestAPI. Doc - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html#aws-resource-apigateway-deployment--example fixes #6068
Fix is here - #6165 |
…ecified (#6165) Per the documentation from CloudFormation, when an explicit AWS::ApiGateway::Deployment resource is specified, it needs to contain an explicit 'DependsOn' field declared to all of the AWS::ApiGateway::Method resources that are part of the RestAPI. Doc - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html#aws-resource-apigateway-deployment--example fixes #6068 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sorry for this late answer! Just to update here... The workaround works, so I'm using it while we don't have a new version of the CDK! Thanks @nija-at for the quicky fix!! |
I faced also this issue on version 1.61.1 To my understanding, when another resource is created before adding methods to the API it will throw an error. Example, this will fail:
While this would pass:
|
agree with ghost, this bug is definetly still there. hopefully, @nija-at workaround is working. |
Hey!
I'm having a problem with API Gateway and I think it's related to CDK.
I'll try to explain my problem but I don't know if I'll make myself clear... Here it is!
Instead of letting the
apigateway.RestApi
to handle the deployment/stage creation, we decided to do it by our selves, according to the documentation (https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigateway-readme.html#deployments).But, after doing that, fresh deployments fail to run (it works if you already have an API deployed before this change), with a message saying we need to define Methods before creating the Deployment (which we are already doing).
Following some workarounds on the internet, it says you need to add a
dependsOn
in the Deployment resource to depends on the Method resource (https://stackoverflow.com/questions/56944526/cloudformation-stack-errors-with-rest-api-doesnt-contain-any-methods).It's done by default if you don't choose to create the deployment yourself.
Here is the CloudFormation template when you let the
RestAPI
to create theDeployment
.And here is the CloudFormation template when you create the
Deployment
by yourself.I also tried to use the
deployment.node.addDependency
but it adds more resources than the default one and cyclical reference error happens.Here is our the template looks like:
And here is the error message:
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: