Skip to content

Commit

Permalink
fix: Shimming arn for local invocation (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrickard authored Jul 10, 2019
2 parents bfceb90 + 0742810 commit 8f4058e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
node_modules
.idea
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
},
"devDependencies": {
"@iopipe/scripts": "^1.4.1",
"aws-lambda-mock-context": "^3.1.1",
"lodash": "^4.17.4",
"aws-lambda-mock-context": "^3.2.1",
"lodash": "^4.17.11",
"nock": "^9.4.1",
"pre-commit": "^1.2.2"
},
"dependencies": {
"@iopipe/core": "^1.13",
"@iopipe/core": "^1.19.1",
"archiver": "^2.1.1",
"lodash.get": "^4.4.2",
"simple-get": "^3.0.2"
"simple-get": "^3.0.3"
},
"peerDependencies": {},
"jest": {
Expand Down
13 changes: 10 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,23 @@ class ProfilerPlugin {

getFileUploadMeta() {
// returns a promise here
let { invokedFunctionArn: arn } = this.invocationInstance.context;

const {
invokedFunctionArn: arn,
awsRequestId: requestId
awsRequestId: requestId,
functionName
} = this.invocationInstance.context;

if (arn === undefined || process.env.AWS_SAM_LOCAL) {
arn = `arn:aws:lambda:local:0:function:${functionName}`;
}

return coreUtil.getFileUploadMeta({
auth: this.token,
networkTimeout: this.config.networkTimeout,
arn,
requestId
requestId,
functionName
});
}

Expand Down
28 changes: 22 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@iopipe/core@^1.13":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@iopipe/core/-/core-1.13.0.tgz#0fbbace7a58497af1fbda68eb1ab97f1f988ddb3"
"@iopipe/core@^1.19.1":
version "1.19.1"
resolved "https://registry.yarnpkg.com/@iopipe/core/-/core-1.19.1.tgz#19da388f0c900f4551915c71993b4c1269979970"
integrity sha512-JyEcARVnE+TMYodEu9jV61CpWGqmBaAqfvUWX1m5ot1kzbXDS5gvnD/opYsNRteALluiLcb42TRxlEuPCTmijQ==
dependencies:
cosmiconfig "^4"
lodash.uniqby "^4.7.0"
Expand Down Expand Up @@ -615,9 +616,10 @@ atob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.1.tgz#ae2d5a729477f289d60dd7f96a6314a22dd6c22a"

aws-lambda-mock-context@^3.1.1:
version "3.2.0"
resolved "https://registry.yarnpkg.com/aws-lambda-mock-context/-/aws-lambda-mock-context-3.2.0.tgz#6c0769669c857539cfc08d8db14da1e91c2ed904"
aws-lambda-mock-context@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/aws-lambda-mock-context/-/aws-lambda-mock-context-3.2.1.tgz#c84fe6bdec8dedb2d5d6a5e1e8e43e4f12aae709"
integrity sha512-mBqUustp9Q6yfa7w0L8UT8XJVTlIaeZTtxhvRQEEM3uhZwzQ1/l1NNN9i4F+O6CbYEOu9jDODLMCymV/J7pSYA==
dependencies:
moment "^2.10.5"
pinkie-defer "^1.0.0"
Expand Down Expand Up @@ -5043,6 +5045,11 @@ lodash@^4.0.0, lodash@^4.11.2, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5,
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

lodash@^4.17.11:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==

log-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18"
Expand Down Expand Up @@ -6817,6 +6824,15 @@ simple-get@^3.0.2:
once "^1.3.1"
simple-concat "^1.0.0"

simple-get@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-3.0.3.tgz#924528ac3f9d7718ce5e9ec1b1a69c0be4d62efa"
integrity sha512-Wvre/Jq5vgoz31Z9stYWPLn0PqRqmBDpFSdypAnHu5AvRVCYPRYGnvryNLiXu8GOBNDH82J2FRHUGMjjHUpXFw==
dependencies:
decompress-response "^3.3.0"
once "^1.3.1"
simple-concat "^1.0.0"

slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
Expand Down

0 comments on commit 8f4058e

Please sign in to comment.