@@ -213,7 +213,7 @@ def bootstrap_account():
213213 return True
214214
215215
216- def generate_sam_template ():
216+ def generate_sam_template (* , skip_durable_config = False ):
217217 """Generate SAM template for all examples."""
218218 catalog = load_catalog ()
219219
@@ -240,24 +240,27 @@ def generate_sam_template():
240240 }
241241
242242 for example in catalog ["examples" ]:
243- function_name = example ["handler" ].replace ("_" , "" ).title () + "Function"
243+ # Convert handler name to PascalCase (e.g., hello_world -> HelloWorld)
244+ handler_base = example ["handler" ].replace (".handler" , "" )
245+ function_name = "" .join (word .capitalize () for word in handler_base .split ("_" ))
244246 template ["Resources" ][function_name ] = {
245247 "Type" : "AWS::Serverless::Function" ,
246248 "Properties" : {
247249 "CodeUri" : "build/" ,
248- "Handler" : f" { example [' handler' ] } .handler" ,
250+ "Handler" : example [" handler" ] ,
249251 "Description" : example ["description" ],
250252 },
251253 }
252254
253- if "durableConfig" in example :
255+ if not skip_durable_config and "durableConfig" in example :
254256 template ["Resources" ][function_name ]["Properties" ]["DurableConfig" ] = (
255257 example ["durableConfig" ]
256258 )
257259
258260 import yaml
259261
260- with open ("template.yaml" , "w" ) as f :
262+ template_path = Path (__file__ ).parent / "template.yaml"
263+ with open (template_path , "w" ) as f :
261264 yaml .dump (template , f , default_flow_style = False , sort_keys = False )
262265
263266 return True
@@ -495,7 +498,14 @@ def main():
495498 subparsers .add_parser ("list" , help = "List available examples" )
496499
497500 # SAM template command
498- subparsers .add_parser ("sam" , help = "Generate SAM template for all examples" )
501+ sam_parser = subparsers .add_parser (
502+ "sam" , help = "Generate SAM template for all examples"
503+ )
504+ sam_parser .add_argument (
505+ "--skip-durable-config" ,
506+ action = "store_true" ,
507+ help = "Skip adding DurableConfig properties to functions" ,
508+ )
499509
500510 # Deploy command
501511 deploy_parser = subparsers .add_parser ("deploy" , help = "Deploy an example" )
@@ -533,7 +543,7 @@ def main():
533543 elif args .command == "list" :
534544 list_examples ()
535545 elif args .command == "sam" :
536- generate_sam_template ()
546+ generate_sam_template (skip_durable_config = args . skip_durable_config )
537547 elif args .command == "deploy" :
538548 deploy_function (args .example_name , args .function_name )
539549 elif args .command == "invoke" :
0 commit comments