Skip to content

Commit

Permalink
Merge pull request #156 from newrelic/mrickard/lambda-1338/add-ARM-su…
Browse files Browse the repository at this point in the history
…pport

feat: Add support for ARM64 architecture
  • Loading branch information
mrickard authored Nov 11, 2021
2 parents bd47ad8 + 2d92079 commit bebb71c
Show file tree
Hide file tree
Showing 23 changed files with 5,857 additions and 7,248 deletions.
11 changes: 0 additions & 11 deletions examples/nodejs/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ custom:
logLevel: debug

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)
Expand Down
12,819 changes: 5,637 additions & 7,182 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-newrelic-lambda-layers",
"version": "2.1.4",
"version": "2.2.0",
"description": "Serverless plugin for NewRelic APM AWS Lambda layers.",
"main": "dist/index.js",
"files": [
Expand Down Expand Up @@ -41,11 +41,11 @@
"@types/serverless": "^1.72.6",
"get-installed-path": "^4.0.8",
"husky": "^4.3.0",
"jest": "^26.6.3",
"jest": "^27.3.1",
"prettier": "^1.19.1",
"ramda": "^0.27.1",
"serverless": "^2.59.0",
"ts-jest": "^26.4.4",
"serverless": "^2.66.1",
"ts-jest": "^27.0.7",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
Expand Down
14 changes: 11 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ https://blog.newrelic.com/product-news/aws-lambda-extensions-integrations/
environment = {},
handler,
runtime = _.get(this.serverless.service, "provider.runtime"),
architecture = _.get(
this.serverless.service,
"provider.architecture",
null
),
layers = [],
package: pkg = {}
} = funcDef;
Expand Down Expand Up @@ -405,7 +410,7 @@ https://blog.newrelic.com/product-news/aws-lambda-extensions-integrations/

const layerArn = this.config.layerArn
? this.config.layerArn
: await this.getLayerArn(runtime);
: await this.getLayerArn(runtime, architecture);

const newRelicLayers = layers.filter(
layer => typeof layer === "string" && layer.match(layerArn)
Expand Down Expand Up @@ -538,8 +543,11 @@ https://blog.newrelic.com/product-news/aws-lambda-extensions-integrations/
}
}

private async getLayerArn(runtime: string) {
const url = `https://${this.region}.layers.newrelic-external.com/get-layers?CompatibleRuntime=${runtime}`;
private async getLayerArn(runtime: string, architecture?: string) {
let url = `https://${this.region}.layers.newrelic-external.com/get-layers?CompatibleRuntime=${runtime}`;
if (architecture) {
url = `${url}&CompatibleArchitecture=${architecture}`;
}
return request(url)
.then(response => {
const awsResp = JSON.parse(response);
Expand Down
65 changes: 65 additions & 0 deletions tests/fixtures/arm64.input.service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"service": "newrelic-lambda-layers-nodejs-example",
"provider": {
"name": "aws",
"stage": "prod",
"region": "us-east-1",
"architecture": "arm64",
"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"
],
"custom": {
"newRelic": {
"accountId": "${env:NEW_RELIC_ACCOUNT_ID}",
"apiKey": "${env:NEW_RELIC_PERSONAL_API_KEY}",
"logLevel": "debug"
}
},
"functions": {
"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"
}
}
}
92 changes: 92 additions & 0 deletions tests/fixtures/arm64.output.service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"configValidationMode": "warn",
"custom": {
"newRelic": {
"accountId": "${env:NEW_RELIC_ACCOUNT_ID}",
"apiKey": "${env:NEW_RELIC_PERSONAL_API_KEY}",
"enableExtension": true,
"logLevel": "debug"
}
},
"disabledDeprecations": [],
"functions": {
"layer-nodejs12x": {
"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}"
},
"events": [
{
"schedule": "rate(5 minutes)"
}
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12XARM64:3"
],
"package": {
"exclude": [
"./**",
"!newrelic-wrapper-helper.js"
],
"include": [
"handler.js"
]
},
"runtime": "nodejs12.x"
},
"layer-nodejs14x": {
"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}"
},
"events": [
{
"schedule": "rate(5 minutes)"
}
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14XARM64:2"
],
"package": {
"exclude": [
"./**",
"!newrelic-wrapper-helper.js"
],
"include": [
"handler.js"
]
},
"runtime": "nodejs14.x"
}
},
"plugins": [
"serverless-newrelic-lambda-layers"
],
"provider": {
"architecture": "arm64",
"name": "aws",
"region": "us-east-1",
"stackTags": {
"environment": "us-testing",
"owning_team": "LAMBDA",
"product": "aws-lambda"
},
"stage": "prod",
"tags": {
"environment": "us-testing",
"owning_team": "LAMBDA",
"product": "aws-lambda"
}
},
"service": "newrelic-lambda-layers-nodejs-example"
}
6 changes: 3 additions & 3 deletions tests/fixtures/debug-log-level.output.service.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -55,7 +55,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:58"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -78,7 +78,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:28"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/debug.output.service.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -54,7 +54,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:58"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -77,7 +77,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:28"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -53,7 +53,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:58"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/eu.output.service.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -57,7 +57,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:58"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -84,7 +84,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:28"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/include.output.service.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"events": [{ "schedule": "rate(5 minutes)" }],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": { "exclude": ["./**", "!newrelic-wrapper-helper.js"], "include": ["handler.js"] },
"runtime": "nodejs10.x"
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/lambda-extension-disabled.output.service.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -49,7 +49,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:58"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -73,7 +73,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:28"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/lambda-extension-enabled.output.service.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:54"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS10X:55"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -50,7 +50,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:52"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS12X:58"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand All @@ -74,7 +74,7 @@
],
"handler": "newrelic-lambda-wrapper.handler",
"layers": [
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:22"
"arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS14X:28"
],
"package": {
"exclude": ["./**", "!newrelic-wrapper-helper.js"],
Expand Down
Loading

0 comments on commit bebb71c

Please sign in to comment.