2828
2929
3030ARN_PREFIXES = {
31+ 'cn-north-1' : 'aws-cn' ,
32+ 'cn-northwest-1' : 'aws-cn' ,
3133 'us-gov-west-1' : 'aws-us-gov' ,
3234}
3335
@@ -529,7 +531,7 @@ def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
529531 'S3Bucket' : '{}' .format (buck_name ),
530532 'S3Key' : '{}' .format (s3_file ),
531533 },
532- 'Description' : cfg .get ('description' ),
534+ 'Description' : cfg .get ('description' , '' ),
533535 'Timeout' : cfg .get ('timeout' , 15 ),
534536 'MemorySize' : cfg .get ('memory_size' , 512 ),
535537 'VpcConfig' : {
@@ -545,7 +547,7 @@ def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
545547 'Role' : role ,
546548 'Handler' : cfg .get ('handler' ),
547549 'Code' : {'ZipFile' : byte_stream },
548- 'Description' : cfg .get ('description' ),
550+ 'Description' : cfg .get ('description' , '' ),
549551 'Timeout' : cfg .get ('timeout' , 15 ),
550552 'MemorySize' : cfg .get ('memory_size' , 512 ),
551553 'VpcConfig' : {
@@ -576,6 +578,10 @@ def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
576578
577579 client .create_function (** kwargs )
578580
581+ concurrency = get_concurrency (cfg )
582+ if concurrency > 0 :
583+ client .put_function_concurrency (FunctionName = func_name , ReservedConcurrentExecutions = concurrency )
584+
579585
580586def update_function (
581587 cfg , path_to_zip_file , existing_cfg , use_s3 = False , s3_file = None , preserve_vpc = False
@@ -627,7 +633,7 @@ def update_function(
627633 'Role' : role ,
628634 'Runtime' : cfg .get ('runtime' ),
629635 'Handler' : cfg .get ('handler' ),
630- 'Description' : cfg .get ('description' ),
636+ 'Description' : cfg .get ('description' , '' ),
631637 'Timeout' : cfg .get ('timeout' , 15 ),
632638 'MemorySize' : cfg .get ('memory_size' , 512 ),
633639 }
@@ -660,6 +666,12 @@ def update_function(
660666
661667 ret = client .update_function_configuration (** kwargs )
662668
669+ concurrency = get_concurrency (cfg )
670+ if concurrency > 0 :
671+ client .put_function_concurrency (FunctionName = cfg .get ('function_name' ), ReservedConcurrentExecutions = concurrency )
672+ elif 'Concurrency' in existing_cfg :
673+ client .delete_function_concurrency (FunctionName = cfg .get ('function_name' ))
674+
663675 if 'tags' in cfg :
664676 tags = {
665677 key : str (value )
@@ -731,6 +743,12 @@ def get_function_config(cfg):
731743 return False
732744
733745
746+ def get_concurrency (cfg ):
747+ """Return the Reserved Concurrent Executions if present in the config"""
748+ concurrency = int (cfg .get ('concurrency' , 0 ))
749+ return max (0 , concurrency )
750+
751+
734752def read_cfg (path_to_config_file , profile_name ):
735753 cfg = read (path_to_config_file , loader = yaml .load )
736754 if profile_name is not None :
0 commit comments