0.9.40 • Published 3 days ago

s3-file-scan-cat v0.9.40

Weekly downloads
74
License
-
Repository
github
Last release
3 days ago

s3-file-scan-cat

A utility library that exists to concatenate multiple small JSON files into a single compressed gunzip file.

Install

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.6 or higher is required.

Installation is done using the npm install command:

$ npm install s3-file-scan-cat

Example

Configuration

Configuration is divided between three main sections, AWS S3 configuration (bucket, etc.), AWS secrets (accessKeyId, secretAccessKey), and the scanner.

Breaking these three sections into two JSON files is recommended. One files contains the credentials for AWS and should never be committed to a repository and the second file contains everything else and can be committed to a repository depending on your deployment strategy.

Example: secrets.json
{
  "aws": {
    "accessKeyId": "_secret_key_",
    "secretAccessKey": "_secret_access_key_"
  }
}
Example: appConfig.json
{
  "aws" : {
    "s3": {
      "bucket": "bucket-name",
      "scannerPrefix": "src-prefix",
      "destinationPrefix": "dest-prefix"
    }
  },
  "scanner": {
    "logLevel": 4,
    "partitionStack" : [
      "year",
      "month",
      "day",
      "part-04",
      "part-05"
    ],
    "limits" : {
      "maxBuildPrefixList":   100,
      "prefixListObjectsLimit": 100,
      "objectFetchBatchSize":        200,
      "objectBodyFetchLimit":   300,
      "objectBodyPutLimit":         250,
      "minPercentRamFree":    25.0,
      "maxFileSizeBytes": 134217728
    },
    "bounds": {
      "startDate": "2020-01-01",
      "endDate": "2020-01-01"
    }
  }
}

Performing the scan

import * as fs from 'fs';
import { AWSSecrets, S3FileScanCat, ScannerConfig } from 's3-file-scan-cat';

const scannerConfig = JSON.parse(fs.readFileSync('./config/manager_config.json').toString('utf8')) as ScannerConfig
const awsSecrets = JSON.parse(fs.readFileSync('./config/private/secrets.json').toString('utf8')).aws as AWSSecrets

const s3Scanner = new S3FileScanCat(scannerConfig.scanner, awsSecrets)
s3Scanner
    .scanAndProcessFiles(scannerConfig.aws.s3.bucket, scannerConfig.aws.s3.scannerPrefix, scannerConfig.aws.s3.destinationPrefix)
    .then(() => {
        process.exit(0)
    })
    .catch((error) => {
        console.error(`Failed: ${error}`)
        process.exit(-1)
    })
0.9.40

3 days ago

0.9.32

9 days ago

0.9.30

2 years ago

0.9.20

3 years ago

0.9.10

3 years ago

0.9.11

3 years ago

0.9.9

3 years ago

0.9.8

3 years ago

0.9.7

3 years ago

0.9.6

4 years ago

0.9.5

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.4

4 years ago

0.5.6

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago