-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Please add your +1 👍 to let us know you have encountered this
Status: IN-PROGRESS
Overview:
A recent change to the init templates caused the application emitted by default java init template to not instantiate the stack class correctly. This results in cdk synth emitting an empty template.
Complete Error Message:
No error emitted, result is an empty stack.
Workaround:
Change the call to the builder of the generated stack to a call to the class constructor instead.
example:
change
MyAppStack.Builder.create(app, "MyAppStack")
.build();to
new MyAppStack(app, "MyAppStack")Solution:
Remove the attempted usage of the nested builder classes in the init template output and replace with call to stack constructor.
Related Issues:
Original Issue
After running cdk init --language java, the generated App doesn't use the generated Stack.
Reproduction Steps
$ mkdir cdk-init-broken && cd cdk-init-broken
$ cdk init --language java
# Setup a stack in CdkInitBrokenStack.java
$ cdk synth
# Stack is empty
What did you expect to happen?
Expected my stack to be rendered into cloud formation templates.
What actually happened?
Generated an empty stack.
Environment
- CDK CLI Version : 1.96.0
- Framework Version: 1.96.0
- Node.js Version: v10.19.0
- OS : Ubuntu 20.04
- Language (Version): Java
Other
Replaced generated App code with code from examples and it worked great:
public class CdkInitBrokenApp {
public static void main(final String[] args) {
App app = new App();
new CdkInitBrokenStack(app, "CdkInitBrokenStack");
app.synth();
}
}This is 🐛 Bug Report