Skip to content

Commit

Permalink
Merge pull request #96 from zotoio/feature/sls-vpce-config
Browse files Browse the repository at this point in the history
fix(metrics):Configure Metrics Lambda with AWS Proxy
  • Loading branch information
Neko-Design authored Apr 16, 2018
2 parents 0c45690 + ce1427e commit a2a768b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/serverless/gtmGithubMetricCapture/gtmGithubMetricCapture.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
'use strict';

const AWS = require('aws-sdk');
const HTTPS = require('https');
const PROXY_AGENT = require('https-proxy-agent');

AWS.config.update({ region: process.env.GTM_AWS_REGION });
const ddb = new AWS.DynamoDB.DocumentClient({
convertEmptyValues: true

if (process.env.IAM_ENABLED) {
AWS.config.update({
httpOptions: {
agent: PROXY_AGENT(process.env.AWS_PROXY)
}
});
}

let dynamo;
if (process.env.GTM_DYNAMO_VPCE) {
console.log('Configuring DynamoDB to use VPC Endpoint');
dynamo = new AWS.DynamoDB({
httpOptions: {
agent: new HTTPS.Agent()
}
});
} else {
console.log('Configuring DynamoDB to use Global AWS Config');
dynamo = new AWS.DynamoDB();
}
let ddb = new AWS.DynamoDB.DocumentClient({
convertEmptyValues: true,
service: dynamo
});
const zlib = require('zlib');

Expand Down

0 comments on commit a2a768b

Please sign in to comment.