28
28
29
29
30
30
ARN_PREFIXES = {
31
+ 'cn-north-1' : 'aws-cn' ,
32
+ 'cn-northwest-1' : 'aws-cn' ,
31
33
'us-gov-west-1' : 'aws-us-gov' ,
32
34
}
33
35
@@ -434,7 +436,7 @@ def pip_install_to_target(path, requirements=None, local_package=None):
434
436
packages = []
435
437
if not requirements :
436
438
print ('Gathering pip packages' )
437
- pkgStr = subprocess .check_call ([sys .executable , '-m' , 'pip' , 'freeze' ])
439
+ pkgStr = subprocess .check_output ([sys .executable , '-m' , 'pip' , 'freeze' ])
438
440
packages .extend (pkgStr .decode ('utf-8' ).splitlines ())
439
441
else :
440
442
if os .path .exists (requirements ):
@@ -529,7 +531,7 @@ def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
529
531
'S3Bucket' : '{}' .format (buck_name ),
530
532
'S3Key' : '{}' .format (s3_file ),
531
533
},
532
- 'Description' : cfg .get ('description' ),
534
+ 'Description' : cfg .get ('description' , '' ),
533
535
'Timeout' : cfg .get ('timeout' , 15 ),
534
536
'MemorySize' : cfg .get ('memory_size' , 512 ),
535
537
'VpcConfig' : {
@@ -545,7 +547,7 @@ def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
545
547
'Role' : role ,
546
548
'Handler' : cfg .get ('handler' ),
547
549
'Code' : {'ZipFile' : byte_stream },
548
- 'Description' : cfg .get ('description' ),
550
+ 'Description' : cfg .get ('description' , '' ),
549
551
'Timeout' : cfg .get ('timeout' , 15 ),
550
552
'MemorySize' : cfg .get ('memory_size' , 512 ),
551
553
'VpcConfig' : {
@@ -576,6 +578,10 @@ def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
576
578
577
579
client .create_function (** kwargs )
578
580
581
+ concurrency = get_concurrency (cfg )
582
+ if concurrency > 0 :
583
+ client .put_function_concurrency (FunctionName = func_name , ReservedConcurrentExecutions = concurrency )
584
+
579
585
580
586
def update_function (
581
587
cfg , path_to_zip_file , existing_cfg , use_s3 = False , s3_file = None , preserve_vpc = False
@@ -627,7 +633,7 @@ def update_function(
627
633
'Role' : role ,
628
634
'Runtime' : cfg .get ('runtime' ),
629
635
'Handler' : cfg .get ('handler' ),
630
- 'Description' : cfg .get ('description' ),
636
+ 'Description' : cfg .get ('description' , '' ),
631
637
'Timeout' : cfg .get ('timeout' , 15 ),
632
638
'MemorySize' : cfg .get ('memory_size' , 512 ),
633
639
}
@@ -660,6 +666,12 @@ def update_function(
660
666
661
667
ret = client .update_function_configuration (** kwargs )
662
668
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
+
663
675
if 'tags' in cfg :
664
676
tags = {
665
677
key : str (value )
@@ -731,6 +743,12 @@ def get_function_config(cfg):
731
743
return False
732
744
733
745
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
+
734
752
def read_cfg (path_to_config_file , profile_name ):
735
753
cfg = read (path_to_config_file , loader = yaml .load )
736
754
if profile_name is not None :
0 commit comments