@@ -16,7 +16,6 @@ import { Stack, Duration } from '@aws-cdk/core';
16
16
import { LambdaToSagemakerEndpoint , LambdaToSagemakerEndpointProps } from '../lib' ;
17
17
import * as defaults from '@aws-solutions-constructs/core' ;
18
18
import * as lambda from '@aws-cdk/aws-lambda' ;
19
- // import * as ec2 from '@aws-cdk/aws-ec2';
20
19
import * as iam from '@aws-cdk/aws-iam' ;
21
20
import { SynthUtils } from '@aws-cdk/assert' ;
22
21
import '@aws-cdk/assert/jest' ;
@@ -276,46 +275,6 @@ test('Test for errot when existing Lambda function does not have vpc and deployV
276
275
expect ( app ) . toThrowError ( ) ;
277
276
} ) ;
278
277
279
- // // -----------------------------------------------------------------------------------------------------------------------------------------
280
- // // Pattern deployment with new Lambda function, new Sagemaker endpoint, deployVpc = true and deployNatGateway = true
281
- // // -----------------------------------------------------------------------------------------------------------------------------------------
282
- // test('Pattern deployment with new Lambda function, new Sagemaker endpoint, deployVpc = true and deployNatGateway = true', () => {
283
- // // Initial Setup
284
- // const stack = new Stack();
285
- // // Create IAM Role to be assumed by Sagemaker
286
- // const sagemakerRole = new iam.Role(stack, 'SagemakerRole', {
287
- // assumedBy: new iam.ServicePrincipal('sagemaker.amazonaws.com'),
288
- // });
289
- // sagemakerRole.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerFullAccess'));
290
- // sagemakerRole.addToPolicy(
291
- // new iam.PolicyStatement({
292
- // actions: ['s3:GetObject', 's3:PutObject', 's3:DeleteObject', 's3:ListBucket'],
293
- // resources: ['arn:aws:s3:::*'],
294
- // })
295
- // );
296
- // const props: LambdaToSagemakerEndpointProps = {
297
- // modelProps: {
298
- // executionRoleArn: sagemakerRole.roleArn,
299
- // primaryContainer: {
300
- // image: '<AccountId>.dkr.ecr.<region>.amazonaws.com/linear-learner:latest',
301
- // modelDataUrl: 's3://<bucket-name>/<prefix>/model.tar.gz',
302
- // },
303
- // },
304
- // deployVpc: true,
305
- // lambdaFunctionProps: {
306
- // runtime: lambda.Runtime.PYTHON_3_8,
307
- // code: lambda.Code.fromAsset(`${__dirname}/lambda`),
308
- // handler: 'index.handler',
309
- // timeout: Duration.minutes(5),
310
- // memorySize: 128,
311
- // },
312
- // role: sagemakerRole,
313
- // };
314
- // new LambdaToSagemakerEndpoint(stack, 'test-lambda-sagemaker', props);
315
- // // Assertion 1
316
- // expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
317
- // });
318
-
319
278
// -------------------------------------------------------------------------------------------------------
320
279
// Pattern deployment with existing Lambda function (with VPC), new Sagemaker endpoint, and existingVpc
321
280
// -------------------------------------------------------------------------------------------------------
@@ -466,105 +425,6 @@ test('Test for error with primaryContainer=undefined (not supplied by user)', ()
466
425
expect ( app ) . toThrowError ( ) ;
467
426
} ) ;
468
427
469
- // // --------------------------------------------------------------------------------------------------------------------
470
- // // Pattern deployment with new Lambda function with new Sagemaker endpoint, existingVpc and deployNatGateway = false
471
- // // --------------------------------------------------------------------------------------------------------------------
472
- // test('Pattern deployment with new Lambda function with existingVpcObj and deployNatGateway = false', () => {
473
- // // Initial Setup
474
- // const stack = new Stack();
475
- // // Create IAM Role to be assumed by Sagemaker
476
- // const sagemakerRole = new iam.Role(stack, 'SagemakerRole', {
477
- // assumedBy: new iam.ServicePrincipal('sagemaker.amazonaws.com'),
478
- // });
479
- // sagemakerRole.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerFullAccess'));
480
- // sagemakerRole.addToPolicy(
481
- // new iam.PolicyStatement({
482
- // actions: ['s3:GetObject', 's3:PutObject', 's3:DeleteObject', 's3:ListBucket'],
483
- // resources: ['arn:aws:s3:::*'],
484
- // })
485
- // );
486
-
487
- // const vpc = defaults.buildVpc(stack, {
488
- // defaultVpcProps: defaults.DefaultIsolatedVpcProps(),
489
- // constructVpcProps: {
490
- // enableDnsHostnames: true,
491
- // enableDnsSupport: true,
492
- // },
493
- // });
494
-
495
- // // Add S3 VPC Gateway Endpint, required by Sagemaker to access Models artifacts via AWS private network
496
- // defaults.AddAwsServiceEndpoint(stack, vpc, defaults.ServiceEndpointTypes.S3);
497
- // // Add SAGEMAKER_RUNTIME VPC Interface Endpint, required by the lambda function to invoke the SageMaker endpoint
498
- // defaults.AddAwsServiceEndpoint(stack, vpc, defaults.ServiceEndpointTypes.SAGEMAKER_RUNTIME);
499
-
500
- // const props: LambdaToSagemakerEndpointProps = {
501
- // modelProps: {
502
- // executionRoleArn: sagemakerRole.roleArn,
503
- // primaryContainer: {
504
- // image: '<AccountId>.dkr.ecr.<region>.amazonaws.com/linear-learner:latest',
505
- // modelDataUrl: 's3://<bucket-name>/<prefix>/model.tar.gz',
506
- // },
507
- // },
508
- // existingVpc: vpc,
509
- // lambdaFunctionProps: {
510
- // runtime: lambda.Runtime.PYTHON_3_8,
511
- // code: lambda.Code.fromAsset(`${__dirname}/lambda`),
512
- // handler: 'index.handler',
513
- // timeout: Duration.minutes(5),
514
- // memorySize: 128,
515
- // },
516
- // role: sagemakerRole,
517
- // };
518
- // new LambdaToSagemakerEndpoint(stack, 'test-lambda-sagemaker', props);
519
- // // Assertion 1
520
- // expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
521
- // });
522
-
523
- // // --------------------------------------------------------------------------------------------
524
- // // Pattern deployment with new Lambda function and existingSagemakerendpointObj (no vpc)
525
- // // --------------------------------------------------------------------------------------------
526
- // test('Pattern deployment with new Lambda function and existingSagemakerendpointObj (no vpc)', () => {
527
- // // Initial Setup
528
- // const stack = new Stack();
529
- // // Create IAM Role to be assumed by Sagemaker
530
- // const sagemakerRole = new iam.Role(stack, 'SagemakerRole', {
531
- // assumedBy: new iam.ServicePrincipal('sagemaker.amazonaws.com'),
532
- // });
533
- // sagemakerRole.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerFullAccess'));
534
- // sagemakerRole.addToPolicy(
535
- // new iam.PolicyStatement({
536
- // actions: ['s3:GetObject', 's3:PutObject', 's3:DeleteObject', 's3:ListBucket'],
537
- // resources: ['arn:aws:s3:::*'],
538
- // })
539
- // );
540
-
541
- // const [sagemakerEndpoint] = defaults.deploySagemakerEndpoint(stack, {
542
- // modelProps: {
543
- // executionRoleArn: sagemakerRole.roleArn,
544
- // primaryContainer: {
545
- // image: '<AccountId>.dkr.ecr.<region>.amazonaws.com/linear-learner:latest',
546
- // modelDataUrl: 's3://<bucket-name>/<prefix>/model.tar.gz',
547
- // },
548
- // },
549
- // role: sagemakerRole,
550
- // });
551
-
552
- // const props: LambdaToSagemakerEndpointProps = {
553
- // existingSagemakerEndpointObj: sagemakerEndpoint,
554
- // lambdaFunctionProps: {
555
- // runtime: lambda.Runtime.PYTHON_3_8,
556
- // code: lambda.Code.fromAsset(`${__dirname}/lambda`),
557
- // handler: 'index.handler',
558
- // timeout: Duration.minutes(5),
559
- // memorySize: 128,
560
- // },
561
- // role: sagemakerRole,
562
- // };
563
- // new LambdaToSagemakerEndpoint(stack, 'test-lambda-sagemaker', props);
564
- // // Assertion 1
565
- // expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
566
- // });
567
-
568
428
// -------------------------------------------------------------------------------------------------
569
429
// Test getter methods: existing Lambda function (with VPC), new Sagemaker endpoint, and existingVpc
570
430
// -------------------------------------------------------------------------------------------------
0 commit comments