Follow the instructions below to build and run example code.
- NodeJS version 16.20.1+, 18.x or above
- A Trend Vision One API key - for more information, see the Trend Vision One API key documentation.
The following instructions assumes you are at the <top level>/client/ts/examples
directory.
-
Navigate to
'cli/'
or'cli-esm/'
.cd cli/
or
cd cli-esm/
-
Export the following environment variables. Replace
__YOUR_VISION_ONE_API_KEY_REGION__
and__YOUR_VISION_ONE_API_KEY__
with your own API key region and Vision One API key.export TM_AM_SERVER_ADDR=__YOUR_VISION_ONE_API_KEY_REGION__ export TM_AM_AUTH_KEY=__YOUR_VISION_ONE_API_KEY__
-
To configuring the SDK's active logging level, export the following environment. The change is applied globally to all AMaaS Client instances. Valid values are OFF, FATAL, ERROR, WARN, INFO, and DEBUG; default level is OFF. Replace
__LOG_LEVEL__
with one of the valid values.export TM_AM_LOG_LEVEL=__LOG_LEVEL__
-
Install dependencies. This will install the SDK and all required devDependencies.
npm install
-
Build the example using one of the following commands:
- fileScan:
SOURCE=fileScan.ts npm run build # cli
SOURCE=fileScan.js npm run build # cli-esm
- bufferScan:
SOURCE=bufferScan.ts npm run build # cli
SOURCE=bufferScan.js npm run build # cli-esm
- batchFileScan:
SOURCE=batchFileScan.ts npm run build # cli
SOURCE=batchFileScan.js npm run build # cli-esm
- batchBufferScan
SOURCE=batchBufferScan.ts npm run build # cli
SOURCE=batchBufferScan.js npm run build # cli-esm
-
Run the example using following command:
npm run client
- Create a new Lambda function. Go to the AWS Lambda console and click "Create function". Choose "Author from scratch" and fill in the following details:
- Function name: Choose a name for your function
- Runtime: Node.js 18.x or above
- Handler: index.handler
- Architecture: x86_64 or arm64
-
Set up environment variables for your function by clicking on "Configuration" and then "Environment variables". Add the following keys and values. Replace
__YOUR_VISION_ONE_API_KEY_REGION__
and__YOUR_VISION_ONE_API_KEY__
with your own API key region and Vision One API key.Key Value Default value TM_AM_SERVER_ADDR __YOUR_VISION_ONE_API_KEY_REGION__
TM_AM_AUTH_KEY __YOUR_VISION_ONE_API_KEY__
TM_AM_LOG_LEVEL FATAL | ERROR | WARN | INFO | DEBUG OFF -
Navigate to 'lambda/' or 'lambda-esm/'.
cd lambda/
or
cd lambda-esm/
-
Install dependencies. This will install the SDK and all required devDependencies.
npm install
-
You should have the a 7-Zip executable (v16.02 or greater) available in your system.
- On Debian and Ubuntu install the p7zip-full package or use 7-Zip 21.02 alpha or higher
- On Mac OSX use Homebrew brew install p7zip
- On Windows get 7-Zip from 7-Zip download page.
-
Build the example by running one of the following commands:
- fileScan:
SOURCE=fileScan.ts npm run build # lambda
SOURCE=fileScan.js npm run build # lambda-esm
- bufferScan:
SOURCE=bufferScan.ts npm run build # lambda
SOURCE=bufferScan.js npm run build # lambda-esm
- bufferS3Scan:
SOURCE=bufferS3Scan.ts npm run build # lambda
SOURCE=bufferS3Scan.js npm run build # lambda-esm
- batchFileScan:
SOURCE=batchFileScan.ts npm run build # lambda
SOURCE=batchFileScan.js npm run build # lambda-esm
- batchBufferScan:
SOURCE=batchBufferScan.ts npm run build # lambda
SOURCE=batchBufferScan.js npm run build # lambda-esm
An archive file
index.zip
which contains index.js and node_modules will be generated under the 'dist/' directory. -
Deploy
dist/index.zip
to your Lambda function created in step 1 by clicking on "Function code" and then "Upload from" and selecting the index.zip file. -
Create a test for your function by clicking on "Configure test events" and then "Create new test event". Choose "Hello World" as the template and click "Create". Click "Test" to run the test.