Regarding your concern about your approach "adding a new function means touching both your template.yaml and your webpack.config.ts files." someone else figured out how to keep them in sync:
// Extract the AWS::Serverless::Function Resources as they// are the entires we need to compile.const{Resources}=CloudFormation.yamlParse(fs.readFileSync('template.yml'))constentries=Object.values(Resources).filter(resource=>resource.Type=='AWS::Serverless::Function').filter(resource=>resource.Properties.Runtime.startsWith('nodejs')).map(resource=>{constfile=resource.Properties.Handler.split('.')[0]constprefix=resource.Properties.CodeUri.substr(9)return{name:`${prefix}/${file}`,entry:`${prefix}/${file}.ts`,}}).reduce((accumulator,resource)=>{const{name,entry}=resourcereturnObject.assign(accumulator,{[name]:path.resolve(entry),})},{})module.exports={entry:entries,...}
Thanks for sharing this is a great post!!.
Regarding your concern about your approach "adding a new function means touching both your template.yaml and your webpack.config.ts files." someone else figured out how to keep them in sync:
Here is the full config: gist.github.com/henrikbjorn/d2eef5...
I think combining both approaches is a great toolchain to have.
Thank you.
Thanks so much for the comment. I'll definitely try this!
Here's the Typescript version as well.
Nice and thanks for the reminder. Got to get around to trying this!
After leaving the same silly comment twice, I finally got around to putting this in and it works great. Thanks so much for the input!