-
Notifications
You must be signed in to change notification settings - Fork 250
/
Copy pathinteg.deployFunction.ts
48 lines (41 loc) · 1.69 KB
/
integ.deployFunction.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
// Imports
import { Stack, Duration, App } from '@aws-cdk/core';
import { LambdaToSagemakerEndpoint, LambdaToSagemakerEndpointProps } from '../lib';
import * as lambda from '@aws-cdk/aws-lambda';
import { getSagemakerModel } from './test-helper';
// Setup
const app = new App();
const stack = new Stack(app, 'test-lambda-sagemakerendpoint');
stack.templateOptions.description = 'Integration Test for aws-lambda-sagemakerendpoint';
const [containerMap, modelAsset ] = getSagemakerModel(stack);
const constructProps: LambdaToSagemakerEndpointProps = {
modelProps: {
primaryContainer: {
image: containerMap.findInMap(Stack.of(stack).region, "containerArn"),
modelDataUrl: modelAsset.s3ObjectUrl
},
},
lambdaFunctionProps: {
runtime: lambda.Runtime.PYTHON_3_8,
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
handler: 'index.handler',
timeout: Duration.minutes(5),
memorySize: 128,
},
};
const lambdaToSagemakerConstruct = new LambdaToSagemakerEndpoint(stack, 'test-lambda-sagemaker', constructProps);
lambdaToSagemakerConstruct.node.addDependency(modelAsset);
// Synth
app.synth();