99 aws_lambda as lambda_ ,
1010 aws_apigateway as api_gw ,
1111 aws_efs as efs ,
12- aws_ec2 as ec2 ,
13- core as cdk
12+ aws_ec2 as ec2
1413)
14+ from aws_cdk import App , Stack , Duration , RemovalPolicy
15+ from constructs import Construct
1516
16-
17- class ServerlessHuggingFaceStack (cdk .Stack ):
18- def __init__ (self , scope : cdk .Construct , id : str , ** kwargs ) -> None :
17+ class ServerlessHuggingFaceStack (Stack ):
18+ def __init__ (self , scope : Construct , id : str , ** kwargs ) -> None :
1919 super ().__init__ (scope , id , ** kwargs )
2020
2121 # EFS needs to be setup in a VPC
@@ -24,7 +24,7 @@ def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
2424 # creates a file system in EFS to store cache models
2525 fs = efs .FileSystem (self , 'FileSystem' ,
2626 vpc = vpc ,
27- removal_policy = cdk . RemovalPolicy .DESTROY )
27+ removal_policy = RemovalPolicy .DESTROY )
2828 access_point = fs .add_access_point ('MLAccessPoint' ,
2929 create_acl = efs .Acl (
3030 owner_gid = '1001' , owner_uid = '1001' , permissions = '750' ),
@@ -46,7 +46,7 @@ def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
4646 filename + ".handler" ]
4747 ),
4848 memory_size = 8096 ,
49- timeout = cdk . Duration .seconds (600 ),
49+ timeout = Duration .seconds (600 ),
5050 vpc = vpc ,
5151 filesystem = lambda_ .FileSystem .from_efs_access_point (
5252 access_point , '/mnt/hf_models_cache' ),
@@ -62,7 +62,7 @@ def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
6262 })
6363 ])
6464
65- app = cdk . App ()
65+ app = App ()
6666
6767ServerlessHuggingFaceStack (app , "ServerlessHuggingFaceStack" )
6868
0 commit comments