question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(core): Stack.exportValue() fails in an inscrutable way when called on a construct

See original GitHub issue

Trying to use .exportValue() to temporarily preserve an output from a stack. Met with a circular dependency when running cdk synth.

Reproduction Steps

import * as cdk from '@aws-cdk/core'
import * as sns from '@aws-cdk/aws-sns'

class SampleStack extends cdk.Stack {
  public readonly snsTopic: sns.Topic

  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    this.snsTopic = new sns.Topic(this, 'SNS Topic', { topicName: 'sample'})
    this.exportValue(this.snsTopic, {
      name: 'sample',
    })
  }
}

const app = new cdk.App();
new SampleStack(app, 'SampleStack');

What did you expect to happen?

Expected the synth command to work and produce CloudFormation output.

What actually happened?

 % cdk synth

/Users/.../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:127
    throw new Error('Unable to resolve object tree with circular reference. Path: ' + pathName);
          ^
Error: Unable to resolve object tree with circular reference. Path: /Outputs/${Token[SampleStack.Exportsample.LogicalID.22]}/Value/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host
    at resolve (/Users/../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:127:11)
    at Object.resolve (/Users/../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:119:77)
    at resolve (/Users/../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:230:47)
    at Object.resolve (/Users/../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:119:77)
    at resolve (/Users/../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:230:47)
    at Object.resolve (/Users/../cdk-issue/node_modules/@aws-cdk/core/lib/private/resolve.ts:119:77)
...

Environment

  • CDK CLI Version : 1.116.0 (build d04661d)
  • Framework Version: 1.116.0
  • Node.js Version: v14.16.0
  • OS : macOS 11.5 (20G71)
  • Language (Version): TypeScript (~3.9.7; resolved to 3.9.10)

Other

Might be specific to SNS Topic? Haven’t tried on other constructs.


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
rix0rrrcommented, Aug 9, 2021

To start with, we should just reject calling exportValue on anything that’s an object but not a token.

Second, it’s a good idea to list all values that are being exported from a stack (probably emitted to metadata) so that users can use this information to write matching exportValue() calls.

0reactions
github-actions[bot]commented, Jul 2, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

exportValue fails on Intrinsics · Issue #19537 · aws/aws-cdk
When attempting to use Stack.exportValue to fix an inter-stack dependency, I found that it fails on the endpoint port of an RDS serverless ......
Read more >
class Stack (construct) · AWS CDK
A root construct which represents a single CloudFormation stack. Example. import * as cdk from '@aws-cdk/core'; ...
Read more >
CDK tips, part 3 – how to unblock cross-stack references
All you have to do is pass an object from one Stack to another, and reference it there. The CDK will generate a...
Read more >
How to export and import stack output values in CDK?
To share information between CDK stacks using the low-level CloudFormation features, we need to do following: 1. Import `core` module. The ...
Read more >
@aws-cdk/core - npm
You define a Stack by defining a subclass of Stack -- let's call it MyStack -- and instantiating the constructs that make up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found