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.

cli: cdk synth doesn't output yaml when having dependency stacks

See original GitHub issue

❓ General Issue

I have a LambdaStack depending on NetworkStack’s vpc. There is the code

LambdaStack

import cdk = require('@aws-cdk/core');
import lambda = require('@aws-cdk/aws-lambda');
import iam = require('@aws-cdk/aws-iam');
import vpc = require('@aws-cdk/aws-ec2')

interface LambdaStackProps extends cdk.StackProps {
  vpc: vpc.Vpc
}

export class LambdaStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: LambdaStackProps) {
    super(scope, id, props);
    // define lambdas by using props.vpc
  }
}

NetworkStack

import cdk = require('@aws-cdk/core');
import ec2 = require("@aws-cdk/aws-ec2");
import iam = require("@aws-cdk/aws-iam");


interface NetworkStackProps extends cdk.StackProps { }

export class NetworkStack extends cdk.Stack {
  public readonly vpc: ec2.Vpc;
  constructor(scope: cdk.Construct, id: string, prop: NetworkStackProps) {
    super(scope, id, prop);
    this.vpc = new ec2.Vpc(some code here);
  }
}

app

const networkStack = new NetworkStack(app, 'network-stack-dev', { env: UsEast1Env });
const lambdaStack = new LambdaStack(app, 'lambda-stack-dev', { 
  env: UsEast1Env,
  vpc: networkStack.vpc
});

I tried to generate yaml file for LambdaStack by executing

cdk synth lambda-stack-dev > template.yaml

Then I got

Including dependency stacks: network-stack-dev
Successfully synthesized to /Users/whao/Developer/serverless-dev/cdk.out
Supply a stack name (network-stack-dev, lambda-stack-dev) to display its template.

I tried cdk synth network-stack-dev lambda-stack-dev but it gave the same output. I am kinda confused with what Supply a stack name (network-stack-dev, lambda-stack-dev) to display its template. means

I have read issue #3259 but I didn’t find it helpful. Forgive me if I am asking stupid questions.

Environment

  • CDK CLI Version: 1.4.0 (build 175471f)
  • Module Version: N/A
  • OS: macOS 10.14.6
  • Language: TypeScript

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:28
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

27reactions
ctaylor-osvcommented, Aug 12, 2020

@sacag I was struggling with this myself and I found that if I added the --exclusively, -e flag to the synth command, I could get it to generate the YAML for the dependent stack. Hope that helps.

4reactions
shivlakscommented, May 19, 2020

bumping this up as a p1 to prioritize a fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS CDK Toolkit (cdk command) - AWS Documentation
The AWS CDK Toolkit, the CLI command cdk , is the primary tool for interacting with your AWS CDK app. It executes your...
Read more >
awslabs/aws-cdk - Gitter
Hey, all. Anyone know of a way to have the cdk not automatically generate outputs for each resource when there are multiple stacks?...
Read more >
Can you create cloudformation stacks in the CDK without ...
Currently I have a cloudformation template in a yaml file that I use to form a stack containing the resources needed for my...
Read more >
@aws-cdk/pipelines - npm
For the synth, use a ShellStep and specify the commands necessary to install dependencies, the CDK CLI, build your project and run cdk...
Read more >
What does CDK Synth do in AWS CDK | bobbyhadz
In order to synthesize a CloudFormation template, the CDK CLI has to first ... The output I get is the CloudFormation equivalent to...
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