serverless-newrelic-lambda-layers
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -13,8 +13,11 @@ "use strict"; | ||
exports.fetchLicenseKey = exports.fetchLinkedAccounts = exports.cloudServiceIntegrationMutation = exports.cloudLinkAccountMutation = exports.nerdgraphFetch = void 0; | ||
const https_proxy_agent_1 = require("https-proxy-agent"); | ||
const node_fetch_1 = require("node-fetch"); | ||
exports.nerdgraphFetch = (apiKey, region, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
exports.nerdgraphFetch = (apiKey, region, query, proxy) => __awaiter(void 0, void 0, void 0, function* () { | ||
const gqlUrl = region === "eu" | ||
? "https://api.eu.newrelic.com/graphql" | ||
: "https://api.newrelic.com/graphql"; | ||
const agent = typeof proxy === "undefined" ? null : new https_proxy_agent_1.HttpsProxyAgent(proxy); | ||
const res = yield node_fetch_1.default(gqlUrl, { | ||
agent, | ||
body: JSON.stringify({ query }), | ||
@@ -21,0 +24,0 @@ headers: { |
@@ -199,2 +199,5 @@ "use strict"; | ||
} | ||
if (this.config.proxy) { | ||
this.serverless.cli.log(`HTTP proxy set to ${this.config.proxy}`); | ||
} | ||
if (!this.licenseKeySecretDisabled) { | ||
@@ -555,4 +558,4 @@ // before adding layer, attach secret access policy | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { apiKey, accountId, nrRegion } = this.config; | ||
const userData = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.fetchLicenseKey(accountId)); | ||
const { apiKey, accountId, nrRegion, proxy } = this.config; | ||
const userData = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.fetchLicenseKey(accountId), proxy); | ||
this.licenseKey = _.get(userData, "data.actor.account.licenseKey", null); | ||
@@ -559,0 +562,0 @@ return this.licenseKey; |
@@ -25,5 +25,5 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { accountId, enableIntegration, apiKey, nrRegion } = this.config; | ||
const { accountId, enableIntegration, apiKey, nrRegion, proxy } = this.config; | ||
const { linkedAccount = `New Relic Lambda Integration - ${accountId}` } = this.config; | ||
const integrationData = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.fetchLinkedAccounts(accountId)); | ||
const integrationData = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.fetchLinkedAccounts(accountId), proxy); | ||
const linkedAccounts = _.get(integrationData, "data.actor.account.cloud.linkedAccounts", []); | ||
@@ -118,6 +118,6 @@ const externalId = yield this.getCallerIdentity(); | ||
} | ||
const { accountId, apiKey, nrRegion } = this.config; | ||
const { accountId, apiKey, nrRegion, proxy } = this.config; | ||
const { linkedAccount = `New Relic Lambda Integration - ${accountId}` } = this.config; | ||
this.serverless.cli.log(`Enabling New Relic integration for linked account: ${linkedAccount} and aws account: ${externalId}.`); | ||
const res = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.cloudLinkAccountMutation(accountId, roleArn, linkedAccount)); | ||
const res = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.cloudLinkAccountMutation(accountId, roleArn, linkedAccount), proxy); | ||
const { linkedAccounts, errors } = _.get(res, "data.cloudLinkAccount", { | ||
@@ -130,3 +130,3 @@ errors: ["data.cloudLinkAccount missing in response"] | ||
const linkedAccountId = _.get(linkedAccounts, "[0].id"); | ||
const integrationRes = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.cloudServiceIntegrationMutation(accountId, "aws", "lambda", linkedAccountId)); | ||
const integrationRes = yield api_1.nerdgraphFetch(apiKey, nrRegion, api_1.cloudServiceIntegrationMutation(accountId, "aws", "lambda", linkedAccountId), proxy); | ||
const { errors: integrationErrors } = _.get(integrationRes, "data.cloudConfigureIntegration", { | ||
@@ -133,0 +133,0 @@ errors: ["data.cloudConfigureIntegration missing in response"] |
{ | ||
"name": "serverless-newrelic-lambda-layers", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Serverless plugin for NewRelic APM AWS Lambda layers.", | ||
@@ -57,2 +57,3 @@ "main": "dist/index.js", | ||
"fs-extra": "^9.1.0", | ||
"https-proxy-agent": "^5.0.0", | ||
"lodash": "^4.17.20", | ||
@@ -59,0 +60,0 @@ "node-fetch": "^2.6.1", |
@@ -319,2 +319,12 @@ # serverless-newrelic-lambda-layers | ||
#### `proxy` (optional) | ||
This plugin makes various HTTP requests to public APIs in order to retrieve data about the New Relic and cloud provider accounts. If you are behind a proxy when this plugin runs, the HTTP agent needs the proxy information to connect to those APIs. Use the given URL as a proxy for HTTP requests. | ||
```yaml | ||
custom: | ||
newRelic: | ||
proxy: http://yourproxy.com:8080 | ||
``` | ||
## Supported Runtimes | ||
@@ -321,0 +331,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72864
991
364
8
1
+ Addedhttps-proxy-agent@^5.0.0
+ Addedagent-base@6.0.2(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedms@2.1.3(transitive)