aws-amplify / aws-amplify/amplify-cli
Amplify mock function uses mysterious version of NodeJS
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/dev/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v16.16.0
### Amplify CLI Version
9.2.1
### What operating system are you using?
Mac
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
Yes. Notably, I added/updated LambdaFunction properties:
```
"Runtime": "nodejs16.x",
"Architectures": [
"arm64"
],
"Layers": [],
"MemorySize": 256,
"Timeout": 300
```
### Amplify Categories
function
### Amplify Commands
Not applicable
### Describe the bug
When I mock functions, they're using NodeJS v14.18.1.
From what I can tell, I don't even have that version installed.
`amplify mock function myAppMylambda --event src/event.json `
Verified by console logging the node version within the Lambda:
```
import { version } from 'node:process'
console.log(`NodeJS Version: ${version}`)
```
### Expected behavior
amplify mock function should use the runtime described in the function's cloudformation template.
Or perhaps use the 'default' version of NodeJS, perhaps with a warning that the local node may be different than the one the Lambda will run in the cloud.
### Reproduction steps
1. Make a lambda that prints the version of node it's using
2. `amplify mock function`
3. Behold! An old mysterious node is found and used.
### GraphQL schema(s)
_No response_
### Project Identifier
_No response_
### Log output
```
# Put your logs below this line
```
### Additional information
@josefaidt on Discord
> It appears the CLI is likely using the Node 14 runtime shipped with the packaged CLI rather than the available Node binary on the system
(Looks like `amplify mock` is missing from the amplify commands drop down.)
Thanks!
Contributor guide
Research direction
Start at the `amplify mock function` command and trace how the packaged CLI selects the Node.js runtime for a Lambda function. Compare that behavior with the function's CloudFormation runtime, then verify that mocking uses the declared runtime or clearly warns when it cannot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, node.js
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100