-
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] Cyclic dependency between APIGateway and SQS #4356
Comments
+1, I am also facing the same issue. |
I am also facing the similar issue. |
@nija-at any possibility to look into this issue on priority? The more important things is to know, if it's really a bug or a wrong usage from our side. |
#4010 only fixed cyclic reference errors when APIGateway and Lambda are defined across stacks. Other cyclic reference errors can very well exist and are bugs. I gave this a shot and the issue does arise in the way you've modeled your stacks. (For my own reference in the future - gist) However, @praman28 - this should go away if you move the definition of the The code that works for me is below. #!/usr/bin/env node
import cdk = require('@aws-cdk/core');
import apigw = require('@aws-cdk/aws-apigateway');
import sqs = require('@aws-cdk/aws-sqs');
class APIStack extends cdk.Stack {
public resource: apigw.Resource;
constructor(scope: cdk.Construct, id: string) {
super(scope, id);
const apiGateway = new apigw.RestApi(this, 'myrestapi', {
restApiName: 'myrestapi',
});
apiGateway.root.addMethod('ANY');
this.resource = new apigw.Resource(this, 'queue-api', {
parent: apiGateway.root,
pathPart: 'queue',
});
}
}
class SQSStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, private readonly resource: apigw.Resource) {
super(scope, id);
const queue = new sqs.Queue(this, 'myqueue', {
queueName : 'myqueue'
});
const queueIntegration = new apigw.AwsIntegration({
service: 'SQS',
integrationHttpMethod: 'POST',
path: queue.queueName,
});
this.resource.addMethod('POST', queueIntegration);
}
}
const app = new cdk.App();
const apiStack = new APIStack(app, 'myapistack');
new SQSStack(app, 'mysqsstack', apiStack.resource);
app.synth(); |
@nija-at Thanks for looking into this. The approach you are suggesting of keeping the APIGateway and its resource in a single stack is something i have already tried and it worked for me . What i was interested in was keeping my resources as modular as possible , in this case i always want that if i destroy my SQS then i also delete my associated resources without making any changes to APIGateway. Basically i am looking for something that works for APIGateway and Lambda and was fixed in #4010 . I'll wait for the resolution to come and meanwhile use workarounds for my code. |
@nija-at yes, this works as expected but we do want to maintain the modularity of our stacks in the bounded context of our microservice and hence would need to do it in a way that, API resources live with the API backend (microservice). |
@praman28 & @ashwgupt - I wanted to clarify a couple of things.
|
This unfortunately did not work on python. I still get the cyclic dependencies despite creating all resources in the api gateway stack. |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I created an APIGateway in one stack, and SQS and the respective APIGateway Resource in front of SQS in a separate stack. On running the
cdk synth
the code results with a cyclic dependency error as below:As per the issue ##4010 such issue is already fixed in v1.9.0. However we are still facing either the same or similar issue.
Reproduction Steps
Below is the code snippet that can be used to recreate the scenario.
SQS Queue stack
APIGateway stack
Index.ts
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: