29
29
Alias ,
30
30
Version ,
31
31
AutoVersion ,
32
+ BlueGreenVersions ,
32
33
BlueGreenAliases ,
33
34
BlueGreenAliasConfiguration ,
34
35
)
370
371
},
371
372
}
372
373
374
+ EXPECTED_BLUEGREENVERSIONS_TEMPLATE = {
375
+ "MypylambdaVersion1" : {
376
+ "Properties" : {
377
+ "Description" : "version 1 of mypylambda lambda" ,
378
+ "FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
379
+ },
380
+ "Type" : "AWS::Lambda::Version" ,
381
+ },
382
+ "MypylambdaVersion2" : {
383
+ "Properties" : {
384
+ "Description" : "version 2 of mypylambda lambda" ,
385
+ "FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
386
+ },
387
+ "Type" : "AWS::Lambda::Version" ,
388
+ },
389
+ "MypylambdaVersion3" : {
390
+ "Properties" : {
391
+ "Description" : "version 3 of mypylambda lambda" ,
392
+ "FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
393
+ },
394
+ "Type" : "AWS::Lambda::Version" ,
395
+ },
396
+ }
397
+
373
398
EXPECTED_BLUEGREENALIASES_DEFAULT_TEMPLATE = {
374
399
"MypylambdaBlueAlias" : {
375
400
"Properties" : {
376
401
"Name" : "MypylambdaBlueAlias" ,
377
402
"Description" : "blue alias for mypylambda lambda" ,
378
403
"FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
379
- "FunctionVersion" : {"Ref " : "MypylambdaVersion1" },
404
+ "FunctionVersion" : {"Fn::GetAtt " : [ "MypylambdaVersion1" , "Version" ] },
380
405
},
381
406
"Type" : "AWS::Lambda::Alias" ,
382
407
},
385
410
"Name" : "MypylambdaGreenAlias" ,
386
411
"Description" : "green alias for mypylambda lambda" ,
387
412
"FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
388
- "FunctionVersion" : {"Ref " : "MypylambdaVersion2" },
413
+ "FunctionVersion" : {"Fn::GetAtt " : [ "MypylambdaVersion2" , "Version" ] },
389
414
},
390
415
"Type" : "AWS::Lambda::Alias" ,
391
416
},
397
422
"Name" : "prod" ,
398
423
"Description" : "prod alias for mypylambda lambda" ,
399
424
"FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
400
- "FunctionVersion" : {"Ref " : "MypylambdaVersion1" },
425
+ "FunctionVersion" : {"Fn::GetAtt " : [ "MypylambdaVersion1" , "Version" ] },
401
426
"ProvisionedConcurrencyConfig" : {"ProvisionedConcurrentExecutions" : 1 },
402
427
"RoutingConfig" : {
403
428
"AdditionalVersionWeights" : [
417
442
"Name" : "beta" ,
418
443
"Description" : "beta alias for mypylambda lambda" ,
419
444
"FunctionName" : {"Fn::GetAtt" : ["Mypylambda" , "Arn" ]},
420
- "FunctionVersion" : {"Ref " : "MypylambdaVersion2" },
445
+ "FunctionVersion" : {"Fn::GetAtt " : [ "MypylambdaVersion2" , "Version" ] },
421
446
"ProvisionedConcurrencyConfig" : {"ProvisionedConcurrentExecutions" : 1 },
422
447
"RoutingConfig" : {
423
448
"AdditionalVersionWeights" : [
@@ -837,6 +862,20 @@ def test_autoversion(stack: Stack, simple_lambda_function: PyFunction) -> None:
837
862
assert auto_version .latest .name == "mypylambdaVersion3"
838
863
839
864
865
+ def test_bluegreenversions (stack : Stack , simple_lambda_function : PyFunction ) -> None :
866
+ """Test BlueGreenVersions creation."""
867
+ versions = BlueGreenVersions (
868
+ blue_version = 2 ,
869
+ green_version = 3 ,
870
+ lambda_function = simple_lambda_function ,
871
+ )
872
+ stack .add (versions )
873
+ print (stack .export ()["Resources" ])
874
+ assert stack .export ()["Resources" ] == EXPECTED_BLUEGREENVERSIONS_TEMPLATE
875
+ assert versions .blue .name == "mypylambdaVersion2"
876
+ assert versions .green .name == "mypylambdaVersion3"
877
+
878
+
840
879
def test_bluegreenaliases_default (
841
880
stack : Stack , simple_lambda_function : PyFunction
842
881
) -> None :
@@ -846,8 +885,8 @@ def test_bluegreenaliases_default(
846
885
lambda_function = simple_lambda_function ,
847
886
)
848
887
aliases = BlueGreenAliases (
849
- blue_config = BlueGreenAliasConfiguration (version = auto_version .previous . ref ),
850
- green_config = BlueGreenAliasConfiguration (version = auto_version .latest . ref ),
888
+ blue_config = BlueGreenAliasConfiguration (version = auto_version .previous ),
889
+ green_config = BlueGreenAliasConfiguration (version = auto_version .latest ),
851
890
lambda_function = simple_lambda_function ,
852
891
)
853
892
stack .add (aliases )
@@ -865,7 +904,7 @@ def test_bluegreenaliases(stack: Stack, simple_lambda_function: PyFunction) -> N
865
904
)
866
905
aliases = BlueGreenAliases (
867
906
blue_config = BlueGreenAliasConfiguration (
868
- version = auto_version .previous . ref ,
907
+ version = auto_version .previous ,
869
908
name = "prod" ,
870
909
provisioned_concurrency_config = ProvisionedConcurrencyConfiguration (
871
910
ProvisionedConcurrentExecutions = 1
@@ -879,7 +918,7 @@ def test_bluegreenaliases(stack: Stack, simple_lambda_function: PyFunction) -> N
879
918
),
880
919
),
881
920
green_config = BlueGreenAliasConfiguration (
882
- version = auto_version .latest . ref ,
921
+ version = auto_version .latest ,
883
922
name = "beta" ,
884
923
provisioned_concurrency_config = ProvisionedConcurrencyConfiguration (
885
924
ProvisionedConcurrentExecutions = 1
0 commit comments