Retrieving Resource Values as Strings

I am using the CDK to create a public Route53 zone:

 const externalRoute53Zone =  new Route53Zone(this, 'externalRoute53Zone', {
    name: cfg.externalDomainName,

One created, I’d like to retrieve the name servers created, and print them to the screen (actually log to a file but am using console.log() for demonstration purposes.

I don’t understand how to get these to display. For example, I’ve done:

console.log(new TerraformOutput(this, 'nameServers', {
  value: externalRoute53Zone.nameServers

The above attempts result in:

[ '#{Token[TOKEN.2]}' ]

<ref *1> TerraformOutput {
  rawOverrides: {},
  stack: MyStack {
    rawOverrides: {},
    artifactFile: '',
    cdktfVersion: '0.0.17',
    [Symbol(@aws-cdk/core.DependableTrait)]: { dependencyRoots: [Array] }
  value: [ '#{Token[TOKEN.3]}' ],
  description: undefined,
  sensitive: undefined,
  dependsOn: undefined,
  [Symbol(@aws-cdk/core.DependableTrait)]: { dependencyRoots: [ [Circular *1] ] }

I’m hoping to get back an array or anything I can parse, example:

name_servers  = [

Any help would be appreciated!

Running your app directly will just generate a cdktf.json file just like running cdktf synth. This means that any logging you add is just what’s available during that synth process (mainly internal data).

You’re on the right track by having a TerraformOutput. That will show up in the console when you run cdktf deploy. Take a look here for an example of what that looks like.

Thank you for the advice! I’m going to change my approach and perform this sort of work outside of the synth itself through a larger application/pipeline. For example. the synth will create TF outputs that I can later query to log/generate documentation.