diff --git a/package-lock.json b/package-lock.json index 67a82996..b861913b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "serverless-newrelic-lambda-layers", - "version": "2.1.2", + "version": "2.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "2.1.2", + "version": "2.1.3", "license": "Apache-2.0", "dependencies": { "fs-extra": "^9.1.0", diff --git a/package.json b/package.json index f60f4f13..d2cbdba0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-newrelic-lambda-layers", - "version": "2.1.2", + "version": "2.1.3", "description": "Serverless plugin for NewRelic APM AWS Lambda layers.", "main": "dist/index.js", "files": [ diff --git a/src/index.ts b/src/index.ts index 50adb053..4ddff0e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -450,9 +450,9 @@ https://blog.newrelic.com/product-news/aws-lambda-extensions-integrations/ environment.NEW_RELIC_TRUSTED_ACCOUNT_KEY = environment.NEW_RELIC_TRUSTED_ACCOUNT_KEY ? environment.NEW_RELIC_TRUSTED_ACCOUNT_KEY - : environment.NEW_RELIC_ACCOUNT_ID - ? environment.NEW_RELIC_ACCOUNT_ID - : this.config.trustedAccountKey; + : this.config.trustedAccountKey + ? this.config.trustedAccountKey + : environment.NEW_RELIC_ACCOUNT_ID; if (runtime.match("python")) { environment.NEW_RELIC_SERVERLESS_MODE_ENABLED = "true"; diff --git a/tests/fixtures/trusted-account-key-excluded.input.service.json b/tests/fixtures/trusted-account-key-excluded.input.service.json new file mode 100644 index 00000000..1f4e61fc --- /dev/null +++ b/tests/fixtures/trusted-account-key-excluded.input.service.json @@ -0,0 +1,46 @@ +{ + "service": "newrelic-lambda-layers-nodejs-example", + "provider": { + "name": "aws", + "stage": "prod", + "region": "us-east-1", + "stackTags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + }, + "tags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + } + }, + "plugins": ["serverless-newrelic-lambda-layers"], + "configValidationMode": "warn", + "custom": { + "newRelic": { + "accountId": "${env:NEW_RELIC_ACCOUNT_ID}" + } + }, + "disabledDeprecations": [], + "functions": { + "layer-nodejs10x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "handler.handler", + "package": { "exclude": ["./**"], "include": ["handler.js"] }, + "runtime": "nodejs10.x" + }, + "layer-nodejs12x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "handler.handler", + "package": { "exclude": ["./**"], "include": ["handler.js"] }, + "runtime": "nodejs12.x" + }, + "layer-nodejs14x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "handler.handler", + "package": { "exclude": ["./**"], "include": ["handler.js"] }, + "runtime": "nodejs14.x" + } + } +} diff --git a/tests/fixtures/trusted-account-key-excluded.output.service.json b/tests/fixtures/trusted-account-key-excluded.output.service.json new file mode 100644 index 00000000..e8b50e3d --- /dev/null +++ b/tests/fixtures/trusted-account-key-excluded.output.service.json @@ -0,0 +1,89 @@ +{ + "service": "newrelic-lambda-layers-nodejs-example", + "provider": { + "name": "aws", + "stage": "prod", + "region": "us-east-1", + "stackTags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + }, + "tags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + } + }, + "plugins": ["serverless-newrelic-lambda-layers"], + "configValidationMode": "warn", + "custom": { + "newRelic": { + "accountId": "${env:NEW_RELIC_ACCOUNT_ID}", + "enableExtension": true + } + }, + "disabledDeprecations": [], + "functions": { + "layer-nodejs10x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "newrelic-lambda-wrapper.handler", + "layers": [ + "arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54" + ], + "package": { + "exclude": ["./**", "!newrelic-wrapper-helper.js"], + "include": ["handler.js"] + }, + "runtime": "nodejs10.x", + "environment": { + "NEW_RELIC_ACCOUNT_ID": "${env:NEW_RELIC_ACCOUNT_ID}", + "NEW_RELIC_APP_NAME": "layer-nodejs10x", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "true", + "NEW_RELIC_LAMBDA_HANDLER": "handler.handler", + "NEW_RELIC_NO_CONFIG_FILE": "true", + "NEW_RELIC_TRUSTED_ACCOUNT_KEY": "${env:NEW_RELIC_ACCOUNT_ID}" + } + }, + "layer-nodejs12x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "newrelic-lambda-wrapper.handler", + "layers": [ + "arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52" + ], + "package": { + "exclude": ["./**", "!newrelic-wrapper-helper.js"], + "include": ["handler.js"] + }, + "runtime": "nodejs12.x", + "environment": { + "NEW_RELIC_ACCOUNT_ID": "${env:NEW_RELIC_ACCOUNT_ID}", + "NEW_RELIC_APP_NAME": "layer-nodejs12x", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "true", + "NEW_RELIC_LAMBDA_HANDLER": "handler.handler", + "NEW_RELIC_NO_CONFIG_FILE": "true", + "NEW_RELIC_TRUSTED_ACCOUNT_KEY": "${env:NEW_RELIC_ACCOUNT_ID}" + } + }, + "layer-nodejs14x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "newrelic-lambda-wrapper.handler", + "layers": [ + "arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22" + ], + "package": { + "exclude": ["./**", "!newrelic-wrapper-helper.js"], + "include": ["handler.js"] + }, + "runtime": "nodejs14.x", + "environment": { + "NEW_RELIC_ACCOUNT_ID": "${env:NEW_RELIC_ACCOUNT_ID}", + "NEW_RELIC_APP_NAME": "layer-nodejs14x", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "true", + "NEW_RELIC_LAMBDA_HANDLER": "handler.handler", + "NEW_RELIC_NO_CONFIG_FILE": "true", + "NEW_RELIC_TRUSTED_ACCOUNT_KEY": "${env:NEW_RELIC_ACCOUNT_ID}" + } + } + } +} diff --git a/tests/fixtures/trusted-account-key-included.input.service.json b/tests/fixtures/trusted-account-key-included.input.service.json new file mode 100644 index 00000000..46f30458 --- /dev/null +++ b/tests/fixtures/trusted-account-key-included.input.service.json @@ -0,0 +1,47 @@ +{ + "service": "newrelic-lambda-layers-nodejs-example", + "provider": { + "name": "aws", + "stage": "prod", + "region": "us-east-1", + "stackTags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + }, + "tags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + } + }, + "plugins": ["serverless-newrelic-lambda-layers"], + "configValidationMode": "warn", + "custom": { + "newRelic": { + "accountId": "${env:NEW_RELIC_ACCOUNT_ID}", + "trustedAccountKey": "${env:NEW_RELIC_TRUSTED_ACCOUNT_KEY}" + } + }, + "disabledDeprecations": [], + "functions": { + "layer-nodejs10x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "handler.handler", + "package": { "exclude": ["./**"], "include": ["handler.js"] }, + "runtime": "nodejs10.x" + }, + "layer-nodejs12x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "handler.handler", + "package": { "exclude": ["./**"], "include": ["handler.js"] }, + "runtime": "nodejs12.x" + }, + "layer-nodejs14x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "handler.handler", + "package": { "exclude": ["./**"], "include": ["handler.js"] }, + "runtime": "nodejs14.x" + } + } +} diff --git a/tests/fixtures/trusted-account-key-included.output.service.json b/tests/fixtures/trusted-account-key-included.output.service.json new file mode 100644 index 00000000..af93e0be --- /dev/null +++ b/tests/fixtures/trusted-account-key-included.output.service.json @@ -0,0 +1,90 @@ +{ + "service": "newrelic-lambda-layers-nodejs-example", + "provider": { + "name": "aws", + "stage": "prod", + "region": "us-east-1", + "stackTags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + }, + "tags": { + "environment": "us-testing", + "owning_team": "LAMBDA", + "product": "aws-lambda" + } + }, + "plugins": ["serverless-newrelic-lambda-layers"], + "configValidationMode": "warn", + "custom": { + "newRelic": { + "accountId": "${env:NEW_RELIC_ACCOUNT_ID}", + "enableExtension": true, + "trustedAccountKey": "${env:NEW_RELIC_TRUSTED_ACCOUNT_KEY}" + } + }, + "disabledDeprecations": [], + "functions": { + "layer-nodejs10x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "newrelic-lambda-wrapper.handler", + "layers": [ + "arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54" + ], + "package": { + "exclude": ["./**", "!newrelic-wrapper-helper.js"], + "include": ["handler.js"] + }, + "runtime": "nodejs10.x", + "environment": { + "NEW_RELIC_ACCOUNT_ID": "${env:NEW_RELIC_ACCOUNT_ID}", + "NEW_RELIC_APP_NAME": "layer-nodejs10x", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "true", + "NEW_RELIC_LAMBDA_HANDLER": "handler.handler", + "NEW_RELIC_NO_CONFIG_FILE": "true", + "NEW_RELIC_TRUSTED_ACCOUNT_KEY": "${env:NEW_RELIC_TRUSTED_ACCOUNT_KEY}" + } + }, + "layer-nodejs12x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "newrelic-lambda-wrapper.handler", + "layers": [ + "arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52" + ], + "package": { + "exclude": ["./**", "!newrelic-wrapper-helper.js"], + "include": ["handler.js"] + }, + "runtime": "nodejs12.x", + "environment": { + "NEW_RELIC_ACCOUNT_ID": "${env:NEW_RELIC_ACCOUNT_ID}", + "NEW_RELIC_APP_NAME": "layer-nodejs12x", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "true", + "NEW_RELIC_LAMBDA_HANDLER": "handler.handler", + "NEW_RELIC_NO_CONFIG_FILE": "true", + "NEW_RELIC_TRUSTED_ACCOUNT_KEY": "${env:NEW_RELIC_TRUSTED_ACCOUNT_KEY}" + } + }, + "layer-nodejs14x": { + "events": [{ "schedule": "rate(5 minutes)" }], + "handler": "newrelic-lambda-wrapper.handler", + "layers": [ + "arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22" + ], + "package": { + "exclude": ["./**", "!newrelic-wrapper-helper.js"], + "include": ["handler.js"] + }, + "runtime": "nodejs14.x", + "environment": { + "NEW_RELIC_ACCOUNT_ID": "${env:NEW_RELIC_ACCOUNT_ID}", + "NEW_RELIC_APP_NAME": "layer-nodejs14x", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "true", + "NEW_RELIC_LAMBDA_HANDLER": "handler.handler", + "NEW_RELIC_NO_CONFIG_FILE": "true", + "NEW_RELIC_TRUSTED_ACCOUNT_KEY": "${env:NEW_RELIC_TRUSTED_ACCOUNT_KEY}" + } + } + } +}