77from pathlib import Path
88from aws_cdk import (
99 aws_lambda as lambda_ ,
10- aws_apigateway as api_gw ,
1110 aws_efs as efs ,
1211 aws_ec2 as ec2
1312)
14- from aws_cdk import App , Stack , Duration , RemovalPolicy
13+ from aws_cdk import App , Stack , Duration , RemovalPolicy , Tags
14+
1515from constructs import Construct
1616
1717class ServerlessHuggingFaceStack (Stack ):
@@ -39,7 +39,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
3939 base = os .path .basename (path )
4040 filename = os .path .splitext (base )[0 ]
4141 # Lambda Function from docker image
42- function = lambda_ .DockerImageFunction (
42+ lambda_ .DockerImageFunction (
4343 self , filename ,
4444 code = lambda_ .DockerImageCode .from_image_asset (docker_folder ,
4545 cmd = [
@@ -48,23 +48,13 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
4848 memory_size = 8096 ,
4949 timeout = Duration .seconds (600 ),
5050 vpc = vpc ,
51- filesystem = lambda_ .FileSystem .from_efs_access_point (
52- access_point , '/mnt/hf_models_cache' ),
53- environment = {
54- "TRANSFORMERS_CACHE" : "/mnt/hf_models_cache" },
51+ filesystem = lambda_ .FileSystem .from_efs_access_point (access_point , '/mnt/hf_models_cache' ),
52+ environment = {"TRANSFORMERS_CACHE" : "/mnt/hf_models_cache" },
5553 )
5654
57- # adds method for the function
58- lambda_integration = api_gw .LambdaIntegration (function , proxy = False , integration_responses = [
59- api_gw .IntegrationResponse (status_code = '200' ,
60- response_parameters = {
61- 'method.response.header.Access-Control-Allow-Origin' : "'*'"
62- })
63- ])
64-
6555app = App ()
6656
67- ServerlessHuggingFaceStack (app , "ServerlessHuggingFaceStack" )
57+ stack = ServerlessHuggingFaceStack (app , "ServerlessHuggingFaceStack" )
58+ Tags .of (stack ).add ("AwsSample" , "ServerlessHuggingFace" )
6859
69- app .synth ()
70- # %%
60+ app .synth ()
0 commit comments