Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const EVENTS_TABLE = process.env.GTM_DYNAMO_TABLE_EVENTS;
let INITIAL_DATA = [];
let EventMetricStream;
let elastic;
if (process.env.GTM_ELASTIC_HOST && process.env.GTM_ELASTIC_PORT) {
elastic = new elasticsearch.Client({
host: `${process.env.GTM_ELASTIC_HOST}:${process.env.GTM_ELASTIC_PORT}`,
log: 'info'
});
}
if (process.env.IAM_ENABLED) {
AWS.config.update({
httpOptions: {
agent: proxy(process.env.HTTP_PROXY)
}
});
}
async function configureRoutes(app) {
let ddb;
if (process.env.GTM_DYNAMO_VPCE) {
console.log('Configuring DynamoDB to use VPC Endpoint');
ddb = new AWS.DynamoDB({
httpOptions: {
agent: new https.Agent()
}
});
} else {
console.log('Configuring DynamoDB to use Global AWS Config');
ddb = new AWS.DynamoDB();
function create(agentId) {
if (!agentId) console.warn('agentId is not set.');
let CWLogOptions = {
region: process.env.GTM_AWS_REGION
};
if (process.env.IAM_ENABLED) {
CWLogOptions = {
region: process.env.GTM_AWS_REGION,
//accessKeyId: process.env.AWS_ACCESS_KEY_ID,
//secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
//sessionToken: process.env.AWS_SECURITY_TOKEN,
httpOptions: {
agent: proxy(process.env.HTTP_PROXY)
}
};
}
let cloudWatchStream = new CWLogsWritable({
logGroupName: getLogGroupMap()['gtmAgent'],
logStreamName: 'AGENT_ID=' + agentId,
cloudWatchLogsOptions: CWLogOptions
}).on('error', console.error);
janitorInterval = setInterval(streamJanitor, 60000);
let bunyanConf = {
name: agentId.substring(0, 7),
streams: [
{