@@ -899,7 +899,7 @@ test('custom IAM access role and instance role are allowed', () => {
899
899
} ) ;
900
900
} ) ;
901
901
902
- test ( 'cpu and memory properties are allowed' , ( ) => {
902
+ test ( 'cpu and memory properties as unit values are allowed' , ( ) => {
903
903
// GIVEN
904
904
const app = new cdk . App ( ) ;
905
905
const stack = new cdk . Stack ( app , 'demo-stack' ) ;
@@ -925,7 +925,7 @@ test('cpu and memory properties are allowed', () => {
925
925
} ) ;
926
926
} ) ;
927
927
928
- test ( 'custom cpu and memory units are allowed' , ( ) => {
928
+ test ( 'cpu and memory properties as numeric values are allowed' , ( ) => {
929
929
// GIVEN
930
930
const app = new cdk . App ( ) ;
931
931
const stack = new cdk . Stack ( app , 'demo-stack' ) ;
@@ -934,14 +934,14 @@ test('custom cpu and memory units are allowed', () => {
934
934
source : apprunner . Source . fromEcrPublic ( {
935
935
imageIdentifier : 'public.ecr.aws/aws-containers/hello-app-runner:latest' ,
936
936
} ) ,
937
- cpu : apprunner . Cpu . of ( 'Some vCPU ' ) ,
938
- memory : apprunner . Memory . of ( 'Some GB ' ) ,
937
+ cpu : apprunner . Cpu . of ( '1024 ' ) ,
938
+ memory : apprunner . Memory . of ( '3072 ' ) ,
939
939
} ) ;
940
940
// THEN
941
941
Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AppRunner::Service' , {
942
942
InstanceConfiguration : {
943
- Cpu : 'Some vCPU ' ,
944
- Memory : 'Some GB ' ,
943
+ Cpu : '1024 ' ,
944
+ Memory : '3072 ' ,
945
945
} ,
946
946
NetworkConfiguration : {
947
947
EgressConfiguration : {
@@ -951,6 +951,70 @@ test('custom cpu and memory units are allowed', () => {
951
951
} ) ;
952
952
} ) ;
953
953
954
+ test ( 'invalid cpu property as unit value is not allowed' , ( ) => {
955
+ // GIVEN
956
+ const app = new cdk . App ( ) ;
957
+ const stack = new cdk . Stack ( app , 'demo-stack' ) ;
958
+ // WHEN
959
+ expect ( ( ) => {
960
+ new apprunner . Service ( stack , 'DemoService' , {
961
+ source : apprunner . Source . fromEcrPublic ( {
962
+ imageIdentifier : 'public.ecr.aws/aws-containers/hello-app-runner:latest' ,
963
+ } ) ,
964
+ cpu : apprunner . Cpu . of ( '1000 vCPU' ) ,
965
+ memory : apprunner . Memory . of ( '3 GB' ) ,
966
+ } ) ;
967
+ } ) . toThrow ( 'CPU value is invalid' ) ;
968
+ } ) ;
969
+
970
+ test ( 'invalid cpu property as numeric value is not allowed' , ( ) => {
971
+ // GIVEN
972
+ const app = new cdk . App ( ) ;
973
+ const stack = new cdk . Stack ( app , 'demo-stack' ) ;
974
+ // WHEN
975
+ expect ( ( ) => {
976
+ new apprunner . Service ( stack , 'DemoService' , {
977
+ source : apprunner . Source . fromEcrPublic ( {
978
+ imageIdentifier : 'public.ecr.aws/aws-containers/hello-app-runner:latest' ,
979
+ } ) ,
980
+ cpu : apprunner . Cpu . of ( '1' ) ,
981
+ memory : apprunner . Memory . of ( '3 GB' ) ,
982
+ } ) ;
983
+ } ) . toThrow ( 'CPU value is invalid' ) ;
984
+ } ) ;
985
+
986
+ test ( 'invalid memory property as unit value is not allowed' , ( ) => {
987
+ // GIVEN
988
+ const app = new cdk . App ( ) ;
989
+ const stack = new cdk . Stack ( app , 'demo-stack' ) ;
990
+ // WHEN
991
+ expect ( ( ) => {
992
+ new apprunner . Service ( stack , 'DemoService' , {
993
+ source : apprunner . Source . fromEcrPublic ( {
994
+ imageIdentifier : 'public.ecr.aws/aws-containers/hello-app-runner:latest' ,
995
+ } ) ,
996
+ cpu : apprunner . Cpu . of ( '1 vCPU' ) ,
997
+ memory : apprunner . Memory . of ( '3000 GB' ) ,
998
+ } ) ;
999
+ } ) . toThrow ( 'Memory value is invalid' ) ;
1000
+ } ) ;
1001
+
1002
+ test ( 'invalid memory property as numeric value is not allowed' , ( ) => {
1003
+ // GIVEN
1004
+ const app = new cdk . App ( ) ;
1005
+ const stack = new cdk . Stack ( app , 'demo-stack' ) ;
1006
+ // WHEN
1007
+ expect ( ( ) => {
1008
+ new apprunner . Service ( stack , 'DemoService' , {
1009
+ source : apprunner . Source . fromEcrPublic ( {
1010
+ imageIdentifier : 'public.ecr.aws/aws-containers/hello-app-runner:latest' ,
1011
+ } ) ,
1012
+ cpu : apprunner . Cpu . of ( '1 vCPU' ) ,
1013
+ memory : apprunner . Memory . of ( '3' ) ,
1014
+ } ) ;
1015
+ } ) . toThrow ( 'Memory value is invalid' ) ;
1016
+ } ) ;
1017
+
954
1018
test ( 'environment variable with a prefix of AWSAPPRUNNER should throw an error' , ( ) => {
955
1019
// GIVEN
956
1020
const app = new cdk . App ( ) ;
0 commit comments