serverless-newrelic-lambda-layers
Advanced tools
Comparing version 2.4.1 to 3.0.0
@@ -31,4 +31,4 @@ "use strict"; | ||
}).catch((e) => { | ||
context.serverless.log(`Error fetching from NerdGraph; ${context.caller}`); | ||
context.serverless.log.log(e); | ||
context.log.error(`Error fetching from NerdGraph; ${context.caller}`); | ||
context.log.error(e); | ||
return null; | ||
@@ -35,0 +35,0 @@ }); |
@@ -15,2 +15,3 @@ "use strict"; | ||
const semver = require("semver"); | ||
const logging = require("log"); | ||
const api_1 = require("./api"); | ||
@@ -29,2 +30,3 @@ const integration_1 = require("./integration"); | ||
this.options = options; | ||
this.log = logging; | ||
this.awsProvider = this.serverless.getProvider("aws"); | ||
@@ -175,3 +177,3 @@ this.licenseKey = null; | ||
if (semver.lt(version, "1.34.0")) { | ||
this.serverless.cli.log(`Serverless ${version} does not support layers. Please upgrade to >=1.34.0.`); | ||
this.log.info(`Serverless ${version} does not support layers. Please upgrade to >=1.34.0.`); | ||
return; | ||
@@ -183,10 +185,10 @@ } | ||
} | ||
this.serverless.cli.log(`Plugins: ${JSON.stringify(plugins)}`); | ||
this.log.info(`Plugins: ${JSON.stringify(plugins)}`); | ||
if (plugins.indexOf("serverless-webpack") > | ||
plugins.indexOf("serverless-newrelic-lambda-layers")) { | ||
this.serverless.cli.log("serverless-newrelic-lambda-layers plugin must come after serverless-webpack in serverless.yml; skipping."); | ||
this.log.error("serverless-newrelic-lambda-layers plugin must come after serverless-webpack in serverless.yml; skipping."); | ||
return; | ||
} | ||
if (!this.config.apiKey) { | ||
this.serverless.cli.log(`Please use a valid New Relic API key as your apiKey value; skipping.`); | ||
this.log.error(`Please use a valid New Relic API key as your apiKey value; skipping.`); | ||
return; | ||
@@ -196,3 +198,3 @@ } | ||
if (!_.isEmpty(exclude) && !_.isEmpty(include)) { | ||
this.serverless.cli.log("exclude and include options are mutually exclusive; skipping."); | ||
this.log.error("exclude and include options are mutually exclusive; skipping."); | ||
return; | ||
@@ -207,3 +209,3 @@ } | ||
if (this.config.proxy) { | ||
this.serverless.cli.log(`HTTP proxy set to ${this.config.proxy}`); | ||
this.log.info(`HTTP proxy set to ${this.config.proxy}`); | ||
} | ||
@@ -233,3 +235,3 @@ if (!this.licenseKeySecretDisabled) { | ||
if (this.autoSubscriptionDisabled) { | ||
this.serverless.cli.log("Skipping adding log subscription. Explicitly disabled"); | ||
this.log.info("Skipping adding log subscription. Explicitly disabled"); | ||
return; | ||
@@ -248,3 +250,3 @@ } | ||
} | ||
this.serverless.cli.log(`log filter: ${cloudWatchFilterString}`); | ||
this.log.info(`log filter: ${cloudWatchFilterString}`); | ||
const promises = []; | ||
@@ -255,3 +257,3 @@ for (const funcName of Object.keys(funcs)) { | ||
} | ||
this.serverless.cli.log(`Configuring New Relic log subscription for ${funcName}`); | ||
this.log.info(`Configuring New Relic log subscription for ${funcName}`); | ||
const funcDef = funcs[funcName]; | ||
@@ -262,3 +264,3 @@ promises.push(this.ensureLogSubscription(funcDef.name, cloudWatchFilterString)); | ||
if (this.extFellBackToCW) { | ||
this.serverless.cli.log(this.extFallbackMessage); | ||
this.log.info(this.extFallbackMessage); | ||
} | ||
@@ -270,3 +272,3 @@ }); | ||
if (this.autoSubscriptionDisabled) { | ||
this.serverless.cli.log("Skipping removing log subscription. Explicitly disabled"); | ||
this.log.info("Skipping removing log subscription. Explicitly disabled"); | ||
return; | ||
@@ -278,3 +280,3 @@ } | ||
const { name } = funcs[funcName]; | ||
this.serverless.cli.log(`Removing New Relic log subscription for ${funcName}`); | ||
this.log.info(`Removing New Relic log subscription for ${funcName}`); | ||
promises.push(this.removeSubscriptionFilter(name)); | ||
@@ -287,5 +289,5 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.serverless.cli.log(`Adding NewRelic layer to ${funcName}`); | ||
this.log.info(`Adding NewRelic layer to ${funcName}`); | ||
if (!this.region) { | ||
this.serverless.cli.log("No AWS region specified for NewRelic layer; skipping."); | ||
this.log.warm("No AWS region specified for NewRelic layer; skipping."); | ||
return; | ||
@@ -295,3 +297,3 @@ } | ||
if (!this.config.accountId && !environment.NEW_RELIC_ACCOUNT_ID) { | ||
this.serverless.cli.log(`No New Relic Account ID specified for "${funcName}"; skipping.`); | ||
this.log.warn(`No New Relic Account ID specified for "${funcName}"; skipping.`); | ||
return; | ||
@@ -311,3 +313,3 @@ } | ||
(wrappableRuntime && !this.config.enableExtension)) { | ||
this.serverless.cli.log(`Unsupported runtime "${runtime}" for NewRelic layer; skipping.`); | ||
this.log.warn(`Unsupported runtime "${runtime}" for NewRelic layer; skipping.`); | ||
return; | ||
@@ -327,3 +329,3 @@ } | ||
if (newRelicLayers.length) { | ||
this.serverless.cli.log(`Function "${funcName}" already specifies an NewRelic layer; skipping.`); | ||
this.log.warn(`Function "${funcName}" already specifies an NewRelic layer; skipping.`); | ||
} | ||
@@ -387,3 +389,3 @@ else { | ||
} | ||
this.serverless.cli.log(`Skipping plugin serverless-newrelic-lambda-layers for stage ${this.stage}`); | ||
this.log.warn(`Skipping plugin serverless-newrelic-lambda-layers for stage ${this.stage}`); | ||
return true; | ||
@@ -396,7 +398,7 @@ } | ||
include.indexOf(funcName) === -1) { | ||
this.serverless.cli.log(`Excluded function ${funcName}; is not part of include skipping`); | ||
this.log.warn(`Excluded function ${funcName}; is not part of include; skipping`); | ||
return true; | ||
} | ||
if (_.isArray(exclude) && exclude.indexOf(funcName) !== -1) { | ||
this.serverless.cli.log(`Excluded function ${funcName}; skipping`); | ||
this.log.warn(`Excluded function ${funcName}; skipping`); | ||
return true; | ||
@@ -447,3 +449,3 @@ } | ||
(compatibleLayers.length < 1 && architecture)) { | ||
this.serverless.cli.log(`${architecture} is not yet supported by New Relic layers for ${runtime} in ${this.region}. Skipping.`); | ||
this.log.warn(`${architecture} is not yet supported by New Relic layers for ${runtime} in ${this.region}. Skipping.`); | ||
return false; | ||
@@ -454,5 +456,5 @@ } | ||
.catch((reason) => { | ||
this.serverless.cli.log(`Unable to get layer ARN for ${runtime} in ${this.region}`); | ||
this.serverless.cli.log(`URL: ${url}`); | ||
this.serverless.cli.log(reason); | ||
this.log.error(`Unable to get layer ARN for ${runtime} in ${this.region}`); | ||
this.log.error(`URL: ${url}`); | ||
this.log.error(reason); | ||
return; | ||
@@ -492,3 +494,3 @@ }); | ||
if (err.providerError) { | ||
this.serverless.cli.log(err.providerError.message); | ||
this.log.error(err.providerError.message); | ||
} | ||
@@ -503,12 +505,12 @@ return; | ||
catch (err) { | ||
this.serverless.cli.log(`Could not find a \`${logIngestionFunctionName}\` function installed.`); | ||
this.serverless.cli.log("Details about setup requirements are available here: https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#enable-process"); | ||
this.log.error(`Could not find a \`${logIngestionFunctionName}\` function installed.`); | ||
this.log.warn("Details about setup requirements are available here: https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-new-relic-monitoring-aws-lambda#enable-process"); | ||
if (err.providerError) { | ||
this.serverless.cli.log(err.providerError.message); | ||
this.log.error(err.providerError.message); | ||
} | ||
if (!apiKey) { | ||
this.serverless.cli.log("Unable to create newrelic-log-ingestion because New Relic API key not configured."); | ||
this.log.error("Unable to create newrelic-log-ingestion because New Relic API key not configured."); | ||
return; | ||
} | ||
this.serverless.cli.log(`creating required newrelic-log-ingestion function in region ${this.region}`); | ||
this.log.info(`creating required newrelic-log-ingestion function in region ${this.region}`); | ||
yield this.addLogIngestionFunction(); | ||
@@ -523,3 +525,3 @@ return; | ||
if (err.providerError) { | ||
this.serverless.cli.log(err.providerError.message); | ||
this.log.error(err.providerError.message); | ||
} | ||
@@ -530,7 +532,7 @@ return; | ||
if (competingFilters.length) { | ||
this.serverless.cli.log("WARNING: Found a log subscription filter that was not installed by New Relic. This may prevent the New Relic log subscription filter from being installed. If you know you don't need this log subscription filter, you should first remove it and rerun this command. If your organization requires this log subscription filter, please contact New Relic at serverless@newrelic.com for assistance with getting the AWS log subscription filter limit increased."); | ||
this.log.warn("WARNING: Found a log subscription filter that was not installed by New Relic. This may prevent the New Relic log subscription filter from being installed. If you know you don't need this log subscription filter, you should first remove it and rerun this command. If your organization requires this log subscription filter, please contact New Relic at serverless@newrelic.com for assistance with getting the AWS log subscription filter limit increased."); | ||
} | ||
const existingFilters = subscriptionFilters.filter((filter) => filter.filterName === "NewRelicLogStreaming"); | ||
if (existingFilters.length) { | ||
this.serverless.cli.log(`Found log subscription for ${funcName}, verifying configuration`); | ||
this.log.info(`Found log subscription for ${funcName}, verifying configuration`); | ||
yield Promise.all(existingFilters | ||
@@ -544,3 +546,3 @@ .filter((filter) => filter.filterPattern !== cloudWatchFilterString) | ||
else { | ||
this.serverless.cli.log(`Adding New Relic log subscription to ${funcName}`); | ||
this.log.info(`Adding New Relic log subscription to ${funcName}`); | ||
yield this.addSubscriptionFilter(funcName, destinationArn, cloudWatchFilterString); | ||
@@ -560,4 +562,4 @@ } | ||
catch (e) { | ||
this.serverless.cli.log(`Error getting ingestion function destination ARN.`); | ||
this.serverless.cli.log(e); | ||
this.log.error(`Error getting ingestion function destination ARN.`); | ||
this.log.error(e); | ||
} | ||
@@ -570,3 +572,3 @@ }); | ||
if (!templateUrl) { | ||
this.serverless.cli.log("Unable to create newRelic-log-ingestion without sar template."); | ||
this.log.error("Unable to create newRelic-log-ingestion without sar template."); | ||
return; | ||
@@ -592,7 +594,7 @@ } | ||
catch (e) { | ||
this.serverless.cli.log(`Unable to get stack information.`); | ||
this.serverless.cli.log(e); | ||
this.log.error(`Unable to get stack information.`); | ||
this.log.error(e); | ||
} | ||
const { Id, StackId } = cfResponse; | ||
this.serverless.cli.log("Waiting for change set creation to complete, this may take a minute..."); | ||
this.log.info("Waiting for change set creation to complete, this may take a minute..."); | ||
yield (0, utils_1.waitForStatus)({ | ||
@@ -606,3 +608,3 @@ awsMethod: "describeChangeSet", | ||
catch (err) { | ||
this.serverless.cli.log("Unable to create newrelic-log-ingestion function. Please verify that required environment variables have been set."); | ||
this.log.warn("Unable to create newrelic-log-ingestion function. Please verify that required environment variables have been set."); | ||
} | ||
@@ -648,3 +650,3 @@ }); | ||
catch (err) { | ||
this.serverless.cli.log(`Something went wrong while fetching the sar template: ${err}`); | ||
this.log.error(`Something went wrong while fetching the sar template: ${err}`); | ||
} | ||
@@ -659,3 +661,3 @@ }); | ||
}); | ||
this.serverless.cli.log("Waiting for newrelic-log-ingestion install to complete, this may take a minute..."); | ||
this.log.info("Waiting for newrelic-log-ingestion install to complete, this may take a minute..."); | ||
yield (0, utils_1.waitForStatus)({ | ||
@@ -669,3 +671,3 @@ awsMethod: "describeStacks", | ||
catch (changeSetErr) { | ||
this.serverless.cli.log(`Something went wrong while executing the change set: ${changeSetErr}`); | ||
this.log.error(`Something went wrong while executing the change set: ${changeSetErr}`); | ||
} | ||
@@ -694,3 +696,3 @@ }); | ||
if (err.providerError) { | ||
this.serverless.cli.log(err.providerError.message); | ||
this.log.error(err.providerError.message); | ||
} | ||
@@ -708,3 +710,3 @@ }); | ||
if (err.providerError) { | ||
this.serverless.cli.log(err.providerError.message); | ||
this.log.error(err.providerError.message); | ||
} | ||
@@ -711,0 +713,0 @@ }); |
@@ -16,4 +16,5 @@ "use strict"; | ||
class Integration { | ||
constructor({ config, awsProvider, serverless, region, licenseKey }) { | ||
constructor({ config, awsProvider, serverless, region, licenseKey, log, }) { | ||
this.config = config; | ||
this.log = log; | ||
this.awsProvider = awsProvider; | ||
@@ -38,3 +39,3 @@ this.serverless = serverless; | ||
if (match.length < 1) { | ||
this.serverless.cli.log("No New Relic AWS Lambda integration found for this New Relic linked account and aws account."); | ||
this.log.warn("No New Relic AWS Lambda integration found for this New Relic linked account and aws account."); | ||
if (enableIntegration && enableIntegration !== "false") { | ||
@@ -44,6 +45,6 @@ this.enable(externalId); | ||
} | ||
this.serverless.cli.log("Please enable the configuration manually or add the 'enableIntegration' config var to your serverless.yaml file."); | ||
this.log.info("Please enable the configuration manually or add the 'enableIntegration' config var to your serverless.yaml file."); | ||
return; | ||
} | ||
this.serverless.cli.log("Existing New Relic integration found for this linked account and aws account, skipping creation."); | ||
this.log.info("Existing New Relic integration found for this linked account and aws account, skipping creation."); | ||
}); | ||
@@ -67,3 +68,3 @@ } | ||
catch (err) { | ||
this.serverless.cli.log(`Problem getting list of current policies. ${JSON.stringify(err)}`); | ||
this.log.error(`Problem getting list of current policies. ${JSON.stringify(err)}`); | ||
} | ||
@@ -107,6 +108,6 @@ }); | ||
`${err}`.indexOf("already exists") > -1) { | ||
this.serverless.cli.log(JSON.stringify(err)); | ||
this.log.error(JSON.stringify(err)); | ||
return { stackId: "already created", stackName, policyName }; | ||
} | ||
this.serverless.cli.log(`Something went wrong while creating NewRelicLicenseKeySecret: ${err}`); | ||
this.log.error(`Something went wrong while creating NewRelicLicenseKeySecret: ${err}`); | ||
} | ||
@@ -125,3 +126,3 @@ return false; | ||
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}.`); | ||
this.log.info(`Enabling New Relic integration for linked account: ${linkedAccount} and aws account: ${externalId}.`); | ||
const res = yield (0, api_1.nerdgraphFetch)(apiKey, nrRegion, (0, api_1.cloudLinkAccountMutation)(accountId, roleArn, linkedAccount), proxy, { | ||
@@ -148,6 +149,6 @@ caller: "enable integration, cloudLinkAccountMutation", | ||
} | ||
this.serverless.cli.log(`New Relic AWS Lambda cloud integration created successfully.`); | ||
this.log.info(`New Relic AWS Lambda cloud integration created successfully.`); | ||
} | ||
catch (err) { | ||
this.serverless.cli.log(`Error while creating the New Relic AWS Lambda cloud integration: ${err}.`); | ||
this.log.error(`Error while creating the New Relic AWS Lambda cloud integration: ${err}.`); | ||
} | ||
@@ -163,3 +164,3 @@ }); | ||
catch (err) { | ||
this.serverless.cli.log("No AWS config found, please configure a default AWS config."); | ||
this.log.error("No AWS config found, please configure a default AWS config."); | ||
} | ||
@@ -182,3 +183,3 @@ }); | ||
if (!accountId) { | ||
this.serverless.cli.log("No New Relic Account ID specified; Cannot check for required NewRelicLambdaIntegrationRole."); | ||
this.log.error("No New Relic Account ID specified; Cannot check for required NewRelicLambdaIntegrationRole."); | ||
return; | ||
@@ -195,3 +196,3 @@ } | ||
catch (fallbackErr) { | ||
this.serverless.cli.log(`Neither NewRelicLambdaIntegrationRole_${accountId} nor NewRelicInfrastructure-Integrations can be found. | ||
this.log.error(`Neither NewRelicLambdaIntegrationRole_${accountId} nor NewRelicInfrastructure-Integrations can be found. | ||
Creating Stack with NewRelicLambdaIntegrationRole.`); | ||
@@ -233,3 +234,3 @@ const stackId = yield this.createCFStack(accountId); | ||
catch (err) { | ||
this.serverless.cli.log(`Something went wrong while creating NewRelicLambdaIntegrationRole: ${JSON.stringify(err)}`); | ||
this.log.error(`Something went wrong while creating NewRelicLambdaIntegrationRole: ${JSON.stringify(err)}`); | ||
} | ||
@@ -236,0 +237,0 @@ }); |
@@ -17,3 +17,3 @@ "use strict"; | ||
const waitForStatus = (requestParams, serverlessProps, retryCount = 0) => __awaiter(void 0, void 0, void 0, function* () { | ||
const { awsProvider, serverless } = serverlessProps; | ||
const { awsProvider, log } = serverlessProps; | ||
const { awsMethod, callbackMethod, methodParams, statusPath } = requestParams; | ||
@@ -27,3 +27,3 @@ try { | ||
else if (status === "CREATE_COMPLETE") { | ||
serverless.cli.log("Resource successfully created."); | ||
log("Resource successfully created."); | ||
callbackMethod(); | ||
@@ -35,3 +35,3 @@ return; | ||
catch (stackErr) { | ||
serverless.cli.log(`Something went wrong while creating aws resource: ${stackErr}`); | ||
log(`Something went wrong while creating aws resource: ${stackErr}`); | ||
} | ||
@@ -38,0 +38,0 @@ }); |
{ | ||
"name": "serverless-newrelic-lambda-layers", | ||
"version": "2.4.1", | ||
"version": "3.0.0", | ||
"description": "Serverless plugin for NewRelic APM AWS Lambda layers.", | ||
@@ -41,3 +41,3 @@ "main": "dist/index.js", | ||
"@types/ramda": "^0.27.64", | ||
"@types/serverless": "^1.78.43", | ||
"@types/serverless": "^3.0.0", | ||
"get-installed-path": "^4.0.8", | ||
@@ -48,3 +48,3 @@ "husky": "^4.3.8", | ||
"ramda": "^0.28.0", | ||
"serverless": "^2.72.1", | ||
"serverless": "^3.2.1", | ||
"ts-jest": "^27.1.3", | ||
@@ -61,2 +61,3 @@ "tslint": "^6.1.3", | ||
"lodash": "^4.17.21", | ||
"log": "^6.3.1", | ||
"node-fetch": "^2.6.7", | ||
@@ -63,0 +64,0 @@ "path": "^0.12.7", |
@@ -8,3 +8,3 @@ # serverless-newrelic-lambda-layers | ||
- [serverless](https://github.com/serverless/serverless) >= 2.21.1 | ||
- [serverless](https://github.com/serverless/serverless) >= 3.2.1 | ||
@@ -164,3 +164,3 @@ ## Features | ||
Allows the creation of New Relic aws cloud integration when absent. Defaults to `false` | ||
Allows the creation of New Relic aws cloud integration when absent. Defaults to `false`. If an integration already exists for your AWS account,you can omit this. | ||
@@ -167,0 +167,0 @@ ```yaml |
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
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
1054
75584
7
+ Addedlog@^6.3.1
+ Addedd@1.0.2(transitive)
+ Addedduration@0.2.2(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedlog@6.3.2(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedsprintf-kit@2.0.2(transitive)
+ Addedtype@2.7.3(transitive)
+ Addeduni-global@1.0.0(transitive)