Package: aws-solutions-constructs.aws-lambda-sagemakerendpoint
aws-lambda-sagemakerendpoint module---All classes are under active development and subject to non-backward compatible changes or removal in any
future version. These are not subject to theSemantic Versioningmodel.
This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.Reference Documentation:https://docs.aws.amazon.com/solutions/latest/constructs/LanguagePackagePythonaws_solutions_constructs.aws_lambda_sagemakerendpointTypescript@aws-solutions-constructs/aws-lambda-sagemakerendpointJavasoftware.amazon.awsconstructs.services.lambdasagemakerendpointOverviewThis AWS Solutions Construct implements an AWS Lambda function connected to an Amazon Sagemaker Endpoint.Here is a minimal deployable pattern definition:Typescriptimport{Construct}from'constructs';import{Stack,StackProps,Duration}from'aws-cdk-lib';import*aslambdafrom'aws-cdk-lib/aws-lambda';import{LambdaToSagemakerEndpoint,LambdaToSagemakerEndpointProps}from'@aws-solutions-constructs/aws-lambda-sagemakerendpoint';constconstructProps:LambdaToSagemakerEndpointProps={modelProps:{primaryContainer:{image:'<AccountId>.dkr.ecr.<region>.amazonaws.com/linear-learner:latest',modelDataUrl:"s3://<bucket-name>/<prefix>/model.tar.gz",},},lambdaFunctionProps:{runtime:lambda.Runtime.PYTHON_3_8,code:lambda.Code.fromAsset(`lambda`),handler:'index.handler',timeout:Duration.minutes(5),memorySize:128,},};newLambdaToSagemakerEndpoint(this,'LambdaToSagemakerEndpointPattern',constructProps);PythonfromconstructsimportConstructfromaws_solutions_constructs.aws_lambda_sagemakerendpointimportLambdaToSagemakerEndpoint,LambdaToSagemakerEndpointPropsfromaws_cdkimport(aws_lambdaas_lambda,aws_sagemakerassagemaker,Duration,Stack)fromconstructsimportConstructLambdaToSagemakerEndpoint(self,'LambdaToSagemakerEndpointPattern',model_props=sagemaker.CfnModelProps(primary_container=sagemaker.CfnModel.ContainerDefinitionProperty(image='<AccountId>.dkr.ecr.<region>.amazonaws.com/linear-learner:latest',model_data_url='s3://<bucket-name>/<prefix>/model.tar.gz',),execution_role_arn="executionRoleArn"),lambda_function_props=_lambda.FunctionProps(code=_lambda.Code.from_asset('lambda'),runtime=_lambda.Runtime.PYTHON_3_9,handler='index.handler',timeout=Duration.minutes(5),memory_size=128))Javaimportsoftware.constructs.Construct;importsoftware.amazon.awscdk.Stack;importsoftware.amazon.awscdk.StackProps;importsoftware.amazon.awscdk.Duration;importsoftware.amazon.awscdk.services.lambda.*;importsoftware.amazon.awscdk.services.lambda.Runtime;importsoftware.amazon.awscdk.services.sagemaker.*;importsoftware.amazon.awsconstructs.services.lambdasagemakerendpoint.*;newLambdaToSagemakerEndpoint(this,"LambdaToSagemakerEndpointPattern",newLambdaToSagemakerEndpointProps.Builder().modelProps(newCfnModelProps.Builder().primaryContainer(newCfnModel.ContainerDefinitionProperty.Builder().image("<AccountId>.dkr.ecr.<region>.amazonaws.com/linear_learner:latest").modelDataUrl("s3://<bucket_name>/<prefix>/model.tar.gz").build()).executionRoleArn("executionRoleArn").build()).lambdaFunctionProps(newFunctionProps.Builder().runtime(Runtime.NODEJS_16_X).code(Code.fromAsset("lambda")).handler("index.handler").timeout(Duration.minutes(5)).build()).build());Pattern Construct PropsNameTypeDescriptionexistingLambdaObj?lambda.FunctionAn optional, existing Lambda function to be used instead of the default function. Providing both this andlambdaFunctionPropswill cause an error.lambdaFunctionProps?lambda.FunctionPropsOptional user-provided properties to override the default properties for the Lambda function.existingSagemakerEndpointObj?sagemaker.CfnEndpointAn optional, existing SageMaker Endpoint to be used. Providing both this andendpointProps?will cause an error.modelProps?sagemaker.CfnModelPropsanyendpointConfigProps?sagemaker.CfnEndpointConfigPropsOptional user-provided properties to override the default properties for the SageMaker Endpoint Config.endpointProps?sagemaker.CfnEndpointPropsOptional user-provided properties to override the default properties for the SageMaker Endpoint Config.existingVpc?ec2.IVpcAn optional, existing VPC into which this construct should be deployed. When deployed in a VPC, the Lambda function and Sagemaker Endpoint will use ENIs in the VPC to access network resources. An Interface Endpoint will be created in the VPC for Amazon SageMaker Runtime, and Amazon S3 VPC Endpoint. If an existing VPC is provided, thedeployVpc?property cannot betrue.vpcProps?ec2.VpcPropsOptional user-provided properties to override the default properties for the new VPC.enableDnsHostnames,enableDnsSupport,natGatewaysandsubnetConfigurationare set by the Construct, so any values for those properties supplied here will be overridden. IfdeployVpc?is nottruethen this property will be ignored.deployVpc?booleanWhether to create a new VPC based onvpcPropsinto which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:One isolated subnet in each Availability Zone used by the CDK programenableDnsHostnamesandenableDnsSupportwill both be set to trueIf this property istruethenexistingVpccannot be specified. Defaults tofalse.sagemakerEnvironmentVariableName?stringOptional Name for the Lambda function environment variable set to the name of the SageMaker endpoint. Default: SAGEMAKER_ENDPOINT_NAMEPattern PropertiesNameTypeDescriptionlambdaFunctionlambda.FunctionReturns an instance of the Lambda function created by the pattern.sagemakerEndpointsagemaker.CfnEndpointReturns an instance of the SageMaker Endpoint created by the pattern.sagemakerEndpointConfig?sagemaker.CfnEndpointConfigReturns an instance of the SageMaker EndpointConfig created by the pattern, ifexistingSagemakerEndpointObj?is not provided.sagemakerModel?sagemaker.CfnModelReturns an instance of the SageMaker Model created by the pattern, ifexistingSagemakerEndpointObj?is not provided.vpc?ec2.IVpcReturns an instance of the VPC created by the pattern, ifdeployVpc?istrue, orexistingVpc?is provided.Default settingsOut of the box implementation of the Construct without any override will set the following defaults:AWS Lambda FunctionConfigure limited privilege access IAM role for Lambda functionEnable reusing connections with Keep-Alive for NodeJs Lambda functionAllow the function to invoke the SageMaker endpoint for InferencesConfigure the function to access resources in the VPC, where the SageMaker endpoint is deployedEnable X-Ray TracingSet environment variables:(default) SAGEMAKER_ENDPOINT_NAMEAWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions).Amazon SageMaker EndpointConfigure limited privilege to create SageMaker resourcesDeploy SageMaker model, endpointConfig, and endpointConfigure the SageMaker endpoint to be deployed in a VPCDeploy S3 VPC Endpoint and SageMaker Runtime VPC InterfaceArchitecture© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.