@@ -664,6 +664,67 @@ def test_function_features(self, lambda_client):
664
664
665
665
# Check Lambda function doesn't exist
666
666
assert not lambda_validator .function_exists (resource_name )
667
+
668
+ def test_function_layers (self , lambda_client ):
669
+ resource_name = random_suffix_name ("functionlayers" , 24 )
670
+
671
+ resources = get_bootstrap_resources ()
672
+ logging .debug (resources )
673
+
674
+ replacements = REPLACEMENT_VALUES .copy ()
675
+ replacements ["FUNCTION_NAME" ] = resource_name
676
+ replacements ["BUCKET_NAME" ] = resources .FunctionsBucket .name
677
+ replacements ["LAMBDA_ROLE" ] = resources .EICRole .arn
678
+ replacements ["LAMBDA_FILE_NAME" ] = LAMBDA_FUNCTION_FILE_ZIP
679
+ replacements ["AWS_REGION" ] = get_region ()
680
+ replacements ["LAYERS" ] = "arn:aws:lambda:us-west-2:336392948345:layer:AWSSDKPandas-Python310:14"
681
+
682
+ # Load Lambda CR
683
+ resource_data = load_lambda_resource (
684
+ "function_layers" ,
685
+ additional_replacements = replacements ,
686
+ )
687
+ logging .debug (resource_data )
688
+
689
+ # Create k8s resource
690
+ ref = k8s .CustomResourceReference (
691
+ CRD_GROUP , CRD_VERSION , RESOURCE_PLURAL ,
692
+ resource_name , namespace = "default" ,
693
+ )
694
+ k8s .create_custom_resource (ref , resource_data )
695
+ cr = k8s .wait_resource_consumed_by_controller (ref )
696
+
697
+ assert cr is not None
698
+ assert k8s .get_resource_exists (ref )
699
+
700
+ time .sleep (CREATE_WAIT_AFTER_SECONDS )
701
+
702
+ cr = k8s .wait_resource_consumed_by_controller (ref )
703
+
704
+ lambda_validator = LambdaValidator (lambda_client )
705
+
706
+ # Check Lambda function exists
707
+ assert lambda_validator .function_exists (resource_name )
708
+
709
+ # Update cr
710
+ cr ["spec" ]["layers" ] = ["arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:68" ]
711
+
712
+ #Patch k8s resource
713
+ k8s .patch_custom_resource (ref , cr )
714
+ time .sleep (UPDATE_WAIT_AFTER_SECONDS )
715
+
716
+ #Check function_snapstart update fields
717
+ function = lambda_validator .get_function (resource_name )
718
+ assert function ["Configuration" ]["Layers" ]["Arn" ] == "arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:68"
719
+
720
+ # Delete k8s resource
721
+ _ , deleted = k8s .delete_custom_resource (ref )
722
+ assert deleted is True
723
+
724
+ time .sleep (DELETE_WAIT_AFTER_SECONDS )
725
+
726
+ # Check Lambda function doesn't exist
727
+ assert not lambda_validator .function_exists (resource_name )
667
728
668
729
def test_function_event_invoke_config (self , lambda_client ):
669
730
resource_name = random_suffix_name ("lambda-function" , 24 )
0 commit comments