Skip to content

docs: document how to get around cyclic deps created by connections calls #5047

@vertti

Description

@vertti

Stumbled to another cyclic dependency error.

Reproduction Steps

Create one stack that has a VPC (in my code it's called ProductVpcStack).
Create another stack (in my code it's called TtpImporterStack) that deploys a Lambda to that VPC. In this stack create an InterfaceEndpoint and then call endpoint.connections.allowDefaultPortFrom(ingestLambda) whereingestLambda is the lambda created in this stack.

The resulting error is:

Error: 'TtpImporterStack' depends on 'ProductVpcStack' (TtpImporterStack -> ProductVpcStack/CustomVPC/Resource.Ref). Adding this dependency (ProductVpcStack -> TtpImporterStack/TTPIngestFunction/SecurityGroup/Resource.GroupId) would create a cyclic reference.

Error Log

       throw new Error(`'${stack.node.path}' depends on '${this.node.path}' (${dep.join(', ')}). Adding this dependency (${reason}) would create a cyclic reference.`);
              ^
Error: 'TtpImporterStack' depends on 'ProductVpcStack' (TtpImporterStack -> ProductVpcStack/CustomVPC/Resource.Ref). Adding this dependency (ProductVpcStack -> TtpImporterStack/TTPIngestFunction/SecurityGroup/Resource.GroupId) would create a cyclic reference.
    at VpcStack.addDependency (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/stack.ts:312:15)
    at TtpImporterStack.prepareCrossReference (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/stack.ts:795:24)
    at VpcStack.prepare (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/stack.ts:651:37)
    at Function.prepare (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/construct.ts:81:28)
    at Function.synth (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/construct.ts:40:10)
    at App.synth (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/app.ts:142:36)
    at process.App.process.once (/home/vertti/dev/kesko/k-ruoka-product-service/node_modules/@aws-cdk/core/lib/app.ts:121:45)
    at Object.onceWrapper (events.js:286:20)
    at process.emit (events.js:198:13)
    at process.EventEmitter.emit (domain.js:448:20)

Environment

  • CLI Version : 1.5.0
  • Framework Version: 1.5.0
  • OS : Ubuntu
  • Language : Typescript

This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.cross-stackRelated to cross-stack resource sharingdocs/generatedRelated to the generated API Reference documentationeffort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions