Skip to content

Commit

Permalink
Merge pull request #151 from newrelic/manheim-trustedAccountKeyFix
Browse files Browse the repository at this point in the history
fix: Patch for trusted account key
  • Loading branch information
mrickard authored Sep 15, 2021
2 parents 19b6f5f + ef26ad9 commit 244f661
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
46 changes: 46 additions & 0 deletions tests/fixtures/trusted-account-key-excluded.input.service.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
89 changes: 89 additions & 0 deletions tests/fixtures/trusted-account-key-excluded.output.service.json
Original file line number Diff line number Diff line change
@@ -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}"
}
}
}
}
47 changes: 47 additions & 0 deletions tests/fixtures/trusted-account-key-included.input.service.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
90 changes: 90 additions & 0 deletions tests/fixtures/trusted-account-key-included.output.service.json
Original file line number Diff line number Diff line change
@@ -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}"
}
}
}
}

0 comments on commit 244f661

Please sign in to comment.