Skip to content
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

(apigatewayv2): cyclic dependency introduced when HttpApi and Route are in different stacks #13021

Closed
NGL321 opened this issue Feb 12, 2021 · 10 comments · Fixed by #13010
Closed
Assignees
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@NGL321
Copy link
Contributor

NGL321 commented Feb 12, 2021

Please add your +1 👍 to let us know you have encountered this

Status: INVESTIGATING

Overview:

From @hoegertn:

The changes in #12528 introduced a regression when having the following setup:

ApiStack -> ChildStack with Lambda, HttpRoute, etc

By moving the instantiation of the HttpIntegration class to the HttpApi. _addIntegration method the scope was changed from the Route to the HttpApi object. This leads to a cyclic reference in the architecture described above.

So starting with 1.87.0 all my ApiGateway applications no longer synthesize.

Complete Error Message:

'myapp-backend-pipeline/myapp-backend-dev/Api' depends on 'myapp-backend-pipeline/myapp-backend-dev/Api/Config' (myapp-backend-pipeline/myapp-backend-dev/Api -> myapp-backend-pipeline/myapp-backend-dev/Api/Config/Fncors/Resource.Arn, myapp-backend-pipeline/myapp-backend-dev/Api -> myapp-backend-pipeline/myapp-backend-dev/Api/Config/Fnopenapi/Resource.Arn). Adding this dependency (myapp-backend-pipeline/myapp-backend-dev/Api/Config -> myapp-backend-pipeline/myapp-backend-dev/Api/Api/Resource/Resource.Ref) would create a cyclic reference.
Error: 'myapp-backend-pipeline/myapp-backend-dev/Api' depends on 'myapp-backend-pipeline/myapp-backend-dev/Api/Config' (myapp-backend-pipeline/myapp-backend-dev/Api -> myapp-backend-pipeline/myapp-backend-dev/Api/Config/Fncors/Resource.Arn, myapp-backend-pipeline/myapp-backend-dev/Api -> myapp-backend-pipeline/myapp-backend-dev/Api/Config/Fnopenapi/Resource.Arn). Adding this dependency (myapp-backend-pipeline/myapp-backend-dev/Api/Config -> myapp-backend-pipeline/myapp-backend-dev/Api/Api/Resource/Resource.Ref) would create a cyclic reference.
    at BackendApiImplStack._addAssemblyDependency (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/stack.ts:724:13)
    at Object.addDependency (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/deps.ts:52:20)
    at BackendApiImplStack.addDependency (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/stack.ts:479:5)
    at resolveValue (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/private/refs.ts:103:12)
    at Object.resolveReferences (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/private/refs.ts:33:24)
    at Object.prepareApp (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/private/prepare-app.ts:31:3)
    at Object.synthesize (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/private/synthesis.ts:24:3)
    at myappBackendStage.synth (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/stage.ts:188:23)
    at synthNestedAssemblies (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/private/synthesis.ts:52:13)
    at synthNestedAssemblies (/Users/hoegertn/repo/myapp/backend/node_modules/@aws-cdk/core/lib/private/synthesis.ts:54:7)

Workaround:

Solution:

Related Issues:

First reported by @hoegertn: #13007

@NGL321 NGL321 added bug This issue is a bug. management/tracking Issues that track a subject or multiple issues p0 @aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 labels Feb 12, 2021
@NGL321
Copy link
Contributor Author

NGL321 commented Feb 12, 2021

Original Issue: #13007

@hoegertn
Copy link
Contributor

hoegertn commented Feb 12, 2021

@NGL321 The regression is in the HttpRoute/HttpIntegration of the ApiGateway v2. Maybe you want to edit the title.

@hoegertn
Copy link
Contributor

You can find a repro here: https://github.com/hoegertn/httproute-regression

@ericzbeard ericzbeard changed the title (aws-apigatewayv2): !!! NOTICE: 1.87.0 introduces regression to APIStack (aws-apigatewayv2): !!! NOTICE: 1.87.0 introduces regression to apigatewayv2.HttpIntegration Feb 12, 2021
@peterwoodworth
Copy link
Contributor

I was able to reproduce the issue on 1.89.0 using my own code that was essentially the same as the repro @hoegertn provided

@nija-at nija-at changed the title (aws-apigatewayv2): !!! NOTICE: 1.87.0 introduces regression to apigatewayv2.HttpIntegration (apigatewayv2): cyclic dependency introduced when HttpApi and Route are in different stacks Feb 15, 2021
@hoegertn
Copy link
Contributor

refs #13010

@nija-at
Copy link
Contributor

nija-at commented Feb 15, 2021

@hoegertn already has a tentative fix - #13010. Thanks!

Do you need help with this @hoegertn? Looks like the build is failing.

@hoegertn
Copy link
Contributor

Let's see. The build failure was somewhere else in the build process.

@nija-at
Copy link
Contributor

nija-at commented Feb 15, 2021

Since we've had only one report in 6 days (since the latest release), I'm reducing the priority of this issue to a p1. I'll re-raise the priority if this changes substantially.

We're actively working on fixing this for the next release.

@nija-at nija-at added effort/small Small work item – less than a day of effort p1 and removed management/tracking Issues that track a subject or multiple issues p0 labels Feb 15, 2021
@hoegertn
Copy link
Contributor

Given that it is broken since 1.87.0 this is fine for me. It only happens in multi-stack setups and not many people might do this.

@mergify mergify bot closed this as completed in #13010 Feb 15, 2021
mergify bot pushed a commit that referenced this issue Feb 15, 2021
…es (#13010)

When the Route construct with an integration is defined
in a separate stack from the one defining the HttpApi
construct, a circular dependency error is thrown.

The bug was introduced in - 855ce59 - where the
refactor of moving the creation of Integration resulted in
using the HttpApi as the scope of the Integration
construct, rather than the Route.

fixes #13021

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@skinny85 skinny85 unpinned this issue Feb 18, 2021
NovakGu pushed a commit to NovakGu/aws-cdk that referenced this issue Feb 18, 2021
…es (aws#13010)

When the Route construct with an integration is defined
in a separate stack from the one defining the HttpApi
construct, a circular dependency error is thrown.

The bug was introduced in - 855ce59 - where the
refactor of moving the creation of Integration resulted in
using the HttpApi as the scope of the Integration
construct, rather than the Route.

fixes aws#13021

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants