stratospheric-dev / stratospheric

All you need to know to get your Spring Boot application into production with AWS 🍃
https://stratospheric.dev
Apache License 2.0
266 stars 188 forks source link

Bug in chapter 10 - "npm run service:deploy" includes more than a single stack #222

Closed hjoly2003 closed 1 year ago

hjoly2003 commented 1 year ago

What's going wrong and not working?

Hi,
when invoking npm run service:deploy, the system replies

> stratospheric-cdk@0.1.0 service:deploy
> cdk deploy --app "./mvnw -e -q compile exec:java -Dexec.mainClass=dev.stratospheric.todoapp.cdk.ServiceApp" --require-approval never
Since this app includes more than a single stack, specify which stacks to use (wildcards are supported) or specify `--all`
Stacks: ServiceParameters-1688911388362 · ServiceStack

Indeed, ServiceApp.java defines two stacks: the parametersStack and the serviceStack.

Expected outcome

To resolve this issue and have npm run service:deploy silently deploying the stacks, you would have to modify the package.json file so to include an --all option to that command:

    "service:deploy": "cdk deploy --all --app \"./mvnw -e -q compile exec:java -Dexec.mainClass=dev.stratospheric.todoapp.cdk.ServiceApp\" --require-approval never",
rieckpil commented 1 year ago

Thanks for the fix, feel free to provide a PR to fix it in the code :)

hjoly2003 commented 1 year ago

Doing a follow-up on this issue.

I've found out that when invoking npm run service:deploy (with the suggested -all option), two stacks of ServiceParameters are created, each with a distinct timestamp in its name. Each has its pair of json files synthetized under the cdk.out subdirectory. Somehow, within ServiceApp.main, the long timestamp = System.currentTimeMillis(); snippet is invoked twice! Later, when I run npm run service:destroy, it deletes only one of the two ServiceParameters.

To resolve the issue on my side, I have removed the timestamp from the name of the ServiceParameters stack. Hence, the service:deploy command, within the package.json file, do not need the -all option anymore. Further investigation would be needed as for why the above snippet is executed twice.

Cheers

BjoernKW commented 1 year ago

Thanks a lot for the follow-up. Since this seems to have been resolved, I'm closing this issue for now.