11// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: MIT-0
33
4- import { CloudFormationStackArtifact } from '@aws-cdk/cx-api' ;
5- import { SdkProvider } from 'aws-cdk/lib/api/aws-auth' ;
6- import { CloudFormationDeployments } from 'aws-cdk/lib/api/cloudformation-deployments' ;
7- import { App , CfnOutput , Stack } from '@aws-cdk/core' ;
8- import * as lambda from '@aws-cdk/aws-lambda-nodejs' ;
9- import { Runtime } from '@aws-cdk/aws-lambda' ;
4+ import { App , CfnOutput , Stack } from 'aws-cdk-lib' ;
5+ import * as lambda from 'aws-cdk-lib/aws-lambda-nodejs' ;
6+ import { Runtime } from 'aws-cdk-lib/aws-lambda' ;
107import * as AWS from 'aws-sdk' ;
118
129import { InvocationLogs } from './InvocationLogs' ;
@@ -53,25 +50,10 @@ export const createStackWithLambdaFunction = (params: StackWithLambdaFunctionOpt
5350export const generateUniqueName = ( uuid : string , runtime : string , testName : string ) : string =>
5451 `${ NAME_PREFIX } -${ runtime } -${ testName } -${ uuid } ` . substring ( 0 , 64 ) ;
5552
56- export const deployStack = async ( stackArtifact : CloudFormationStackArtifact ) : Promise < { [ name :string ] : string } > => {
57- const sdkProvider = await SdkProvider . withAwsCliCompatibleDefaults ( {
58- profile : process . env . AWS_PROFILE ,
59- } ) ;
60- const cloudFormation = new CloudFormationDeployments ( { sdkProvider } ) ;
61-
62- // WHEN lambda function is deployed
63- const result = await cloudFormation . deployStack ( {
64- stack : stackArtifact ,
65- quiet : true ,
66- } ) ;
67-
68- return result . outputs ;
69- } ;
70-
7153export const invokeFunction = async ( functionName : string , times : number = 1 , invocationMode : 'PARALLEL' | 'SEQUENTIAL' = 'PARALLEL' ) : Promise < InvocationLogs [ ] > => {
7254 const invocationLogs : InvocationLogs [ ] = [ ] ;
7355
74- const promiseFactory = ( ) : Promise < void > => {
56+ const promiseFactory = ( ) : Promise < void > => {
7557 const invokePromise = lambdaClient
7658 . invoke ( {
7759 FunctionName : functionName ,
@@ -98,20 +80,6 @@ export const invokeFunction = async (functionName: string, times: number = 1, in
9880 return invocationLogs ;
9981} ;
10082
101- export const destroyStack = async ( app : App , stack : Stack ) : Promise < void > => {
102- const stackArtifact = app . synth ( ) . getStackByName ( stack . stackName ) ;
103-
104- const sdkProvider = await SdkProvider . withAwsCliCompatibleDefaults ( {
105- profile : process . env . AWS_PROFILE ,
106- } ) ;
107- const cloudFormation = new CloudFormationDeployments ( { sdkProvider } ) ;
108-
109- await cloudFormation . destroyStack ( {
110- stack : stackArtifact ,
111- quiet : true ,
112- } ) ;
113- } ;
114-
11583const chainPromises = async ( promiseFactories : ( ( ) => Promise < void > ) [ ] ) : Promise < void > => {
11684 let chain = Promise . resolve ( ) ;
11785 promiseFactories . forEach ( factory => chain = chain . then ( factory ) ) ;
0 commit comments