aws-sam-webpack-plugin icon indicating copy to clipboard operation
aws-sam-webpack-plugin copied to clipboard

Support for nested applications

Open buggy opened this issue 4 years ago • 13 comments

Standard sam build seems to have pretty bad support for nested applications. It would be really good if this plugin could build all of the stacks at once.

buggy avatar Oct 12 '19 13:10 buggy

I have almost gotten this to work, using the experimental project option.

It currently outputs each stack into its respective build folder, which I then have to manually combine. But I think that could be solved by output.path.

aksel avatar Jan 22 '20 15:01 aksel

I ended up writing my own plugin, heavily inspired by yours. Here's a gist

But I got it working, specifically for our use case, which is Node-only functions, only one depth of nested stacks (this breaks after second recursion), all of which are local, and organized in a specific folder structure.

It's also incredibly hacky when it comes to file paths and such. But it works™

aksel avatar Jan 23 '20 14:01 aksel

@aksel Thanks for posting the link to the gist. Nested stacks will be coming shortly. I have a reasonable urgent need for them myself. I just need to find a chunk of time that I can dedicate to fixing all of the related issues.

buggy avatar Jan 23 '20 20:01 buggy

@aksel Thanks for posting the link to the gist. Nested stacks will be coming shortly. I have a reasonable urgent need for them myself. I just need to find a chunk of time that I can dedicate to fixing all of the related issues.

Hi @buggy how did you go with the nested stacks? I've been using your plugin and it works great, but recently split my cloud formation file into nested stacks as it was becoming too big to wrap my head around. I noticed that its sitting in the next milestone.

danieljarrett74 avatar Aug 03 '21 12:08 danieljarrett74

@danieljarrett74 It's a feature that I still want to implement but I haven't had the time to dedicate to it.

buggy avatar Aug 06 '21 12:08 buggy

Hey! 👋 I've been using this plugin on a project and it's been fantastic.

We're planning to move to nested stacks as our cloudformation file is getting too big.

This support for nested applications would be great!

artiomnist avatar Aug 11 '21 16:08 artiomnist

@buggy Thanks for the update.

@artiomnist and @buggy I hacked away at a forked version of this the other morning and came up with this https://github.com/danieljarrett74/aws-sam-webpack-plugin . I've stripped out the vscode stuff and other bits to make it faster for me to modify it. But I am using it now and it works for me. However I'm finding my local machine chokes when webpack runs, comes close to running out of memory. I don't know if thats more a webpack thing or something with the way I've done the plugin.

Have a go with it @artiomnist if you want and let me know if it works ok for you. If it seems to work and anyone is interested I can break it off as its own thing and publish it to npm.

danieljarrett74 avatar Aug 11 '21 23:08 danieljarrett74

@danieljarrett74 - Hey this is Interesting I tried it out - but it doesn't seem to work with our nested stacks. Maybe because we're using Type: AWS::Serverless::Application in our template. I tried adapting your plugin to work with Type: AWS::Serverless::Application but had no luck!

I'm finding it slow on my local machine too - takes some time - but eventually manages to build- just missing the nested stack functions!

artiomnist avatar Aug 12 '21 14:08 artiomnist

@danieljarrett74 - Hey this is Interesting I tried it out - but it doesn't seem to work with our nested stacks. Maybe because we're using Type: AWS::Serverless::Application in our template. I tried adapting your plugin to work with Type: AWS::Serverless::Application but had no luck!

I'm finding it slow on my local machine too - takes some time - but eventually manages to build- just missing the nested stack functions!

Scratch that - I've managed to get a version of your hack to work with Type === AWS::Serverless::Application - I've not written any unit tests for this - but from inital runs it seems to work. Maybe I can raise a PR to your project adding this in?

or maybe we can combine our efforts and get a PR for @buggy to review for nested stacks / nested applications.

artiomnist avatar Aug 12 '21 15:08 artiomnist

@artiomnist yes I'm happy for you to add to this. And yes if @buggy wants to pull it back in go for it. But I have concerns that it's a big change and I've rearranged a lot of the existing code and it's not really tested well. The performance issue concerns me a bit, but It runs fine on github actions which works ok for me but maybe not others. @buggy what are your thoughts? did you want to use any of this fork and bring it back in to this project?

@artiomnist do you want to go ahead with your pull request?

danieljarrett74 avatar Aug 12 '21 23:08 danieljarrett74

I'll try to find some time this week to look at it. The first thing I want to understand is how SAM handles nested apps so I can maintain as much compatibility as possible.

buggy avatar Aug 13 '21 15:08 buggy

@buggy Your plugin support many projects in sametime. I have not this situation in my project. Can you attach filetree with templates that will simultaneously be few projects and nested stacks for testing I will make changes to support nested stack and multi project.

baxneo avatar Aug 21 '21 21:08 baxneo

I have put together an experimental version implementing this feature. Reviews/comments would be greatly appreciated.

sam-holder-zava avatar Dec 22 '21 17:12 sam-holder-zava