Unknown or duplicate parameter: NodeCommand - amazon-web-services

I'm trying to deploy a Node.js API with Elastic beanstalk.
I want to set the node command to start the app.
This is my nodecommand.config:
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeCommand: "npm start"
This is my file structure:
Whenever I try to run eb deploy, I get this error:
2020-05-13 19:03:44 INFO Environment update is starting.
2020-05-13 19:03:48 ERROR "option_settings" in one of the configuration files failed validation. More details to follow.
2020-05-13 19:03:48 ERROR Unknown or duplicate parameter: NodeCommand
2020-05-13 19:03:48 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.

I just encountered this very same issue. Upon investigation I found that "NodeCommand" is the legacy way to run your application with custom commands.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html
I removed the ".ebextensions" directory and added a file called "Procfile" to my source directory.
Inside Procfile, try putting the following:
web: npm start
Make sure you update your repository with these changes if necessary before trying to deploy.
Hope this helps!

I used Procfile to deploy app
in Procfile
web: npm run deploy
In package.json, added new command deploy
"scripts": {
"deploy": "npm run build && npm run start"
},

For those who came here through Google, I had a similar problem and was getting this response:
ERROR: ServiceError - Configuration validation exception: Unknown or duplicate parameter: NodeVersion
After trying a lot of things I learned this is now legacy. I deleted that file and added a ProcFile at the root of my application (file name is case sensitive, there doesn't seem to be a required extension), with this line:
web: npm start
That error disappeared (to be replaced by a different one about role permissions, but any progress is good progress, right?).

Related

Deploying simple docker app with docker-compose on Elastic Beanstalk

I have a simple docker app that is able to run for me locally via docker-compose up, and when I send the .yml file to my friend, they are also able to get it up and running on their local machine. However, when I try to deploy it on Elastic Beanstalk, I get errors (specifically, something related to error:open /var/pids/eb-docker-compose-log.pid: no such file or directory, as I'll show below). I've tried to upload multiple times to Elastic Beanstalk, with the same errors. This is a custom app, but they are the same errors I got when I was trying to follow the instructions on https://docker-curriculum.com/#docker-on-aws. Here is the docker-compose.yml for my current app:
version: "3"
services:
server:
image: mfatigati/shop-server
container_name: shop-server
ports:
- "4000:4000"
client:
image: mfatigati/shop-client
depends_on:
- server
ports:
- "3000:3000"
mfatigati/shop-server and mfatigati/shop-client are both Node.JS apps, i.e., FROM node:16 in their Dockerfile.
To deploy this on AWS, I go to my EB console, and then:
Click "Create Application" to take me to the create app screen
Choose "Docker" as the platform
Choose "Upload local code", and upload the above-mentioned .yml file.
Click "Create Application"
Based on the notes here, I think this should be all I need to do (maybe I'm wrong about that?), but I get errors every time that point me to the eb.engine.log file. I've pasted what seems to be the relevant section below, as it is the only section that mentions errors, and it also reflects what appears in the AWS GUI console. The main problem seems reflected by the bit about error:open /var/pids/eb-docker-compose-log.pid: no such file or directory:
2022/02/14 14:17:23.619888 [ERROR] update processes [cfn-hup eb-docker-events healthd eb-docker-compose-events eb-docker-compose-log docker] pid symlinks failed with error Read pid source file /var/pids/eb-docker-compose-log.pid failed with error:open /var/pids/eb-docker-compose-log.pid: no such file or directory
2022/02/14 14:17:23.619901 [ERROR] An error occurred during execution of command [app-deploy] - [Track pids in healthd]. Stop running the command. Error: update processes [cfn-hup eb-docker-events healthd eb-docker-compose-events eb-docker-compose-log docker] pid symlinks failed with error Read pid source file /var/pids/eb-docker-compose-log.pid failed with error:open /var/pids/eb-docker-compose-log.pid: no such file or directory
2022/02/14 14:17:23.619905 [INFO] Executing cleanup logic
2022/02/14 14:17:23.620005 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1644848243,"severity":"ERROR"}]}]}
Any insight would be greatly appreciated! I'm pasting some screenshots below, in case that helps.
GUI corresponding to step 2; GUI corresponding to step 3; GUI errors
I had the same error:open /var/pids/eb-docker-compose-log.pid: no such file or directory error happening for my Docker Compose app when trying to deploy it to my Elastic Beanstalk environment; I'm not sure if my solution will be the same solution you need, but I hope it points you in the right direction (and helps future devs facing a similar problem).
What caused the error for me:
This ...eb-docker-compose-log.pid: no such file... error was a false error that was triggered by a separate issue; my separate error was actually a problem with my application code not finding the environment variables set in my Elastic Beanstalk environment. See below for how I found the problem, and what I did to fix it.
How I found my real problem:
I downloaded the Full Logs:
go to your EB environment
click Logs on the left nav
click the Request Logs dropdown button (at the top right)
click Full Logs
click the Download link once the full logs are ready
Inside of the logs, I found the real problem in the eb-docker/containers/eb-current-app/eb-stdouterr.log file, the issue being that my application code wasn't able to find the environment variables that were setup in my Elastic Beanstalk Software configuration.
In case you're curious what my error said:
panic: required key ONE_OF_MY_ENV_KEYS missing value
(I also had a couple other errors in this log that I fixed, but fixing the error shown above is what ended up solving the ...eb-docker-compose-log.pid: no such file... error).
How I fixed this error:
I turns out that if you use docker-compose.yml, while setting up your environment variables in your Elastic Beanstalk Software configuration, you have to make sure you use the .env file that Elastic Beanstalk creates for you; otherwise (from my own testing), EB only see's/uses the environment variable keys/values you specify in your own .env file or environment: list you can specify in docker-compose.yml.
NOTE: see the Elastic Beanstalk "Environment properties and Environment Variables" and "Referencing environment variables in containers" sections in the docs here, in particular this bit:
"Elastic Beanstalk generates a Docker Compose environment file called .env in the root directory of your application project. This file stores the environment variables you configured for Elastic Beanstalk.
Note
If you include a .env file in your application bundle, Elastic Beanstalk will not generate an .env file."
I solved my problem by updating my docker-compose.yml file to point to the supposed .env file that EB would create for me (by adding env_file: .env to my services that needed it), i.e.:
version: "3"
services:
my_service1:
# ...
env_file: .env
my_service2:
# ...
env_file: .env

Problems with requirement.txt when deploying flask app in AWS Elastic Beanstalk

I am trying to deploy my web app built with flask in python to elastic beanstalk. This is the first time I use this service and I am trying to upload it from the console of AWDS. However, the log file displays errors with the file requirements.txt, which I created from my local computer by typing "pip freeze > requirements.txt". This created me a 360 lines requirements file (is it not too much?) and the log displays errors like this one all the time like:
--------------------------------------------------------
2020/11/10 09:22:02.505005 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 1. Stderr:ERROR: Could not find a version that satisfies the requirement anaconda-client==1.7.2 (from -r requirements.txt (line 5)) (from versions: 1.1.1, 1.2.2)
ERROR: No matching distribution found for anaconda-client==1.7.2 (from -r requirements.txt (line 5))
2020/11/10 09:22:02.505022 [INFO] Executing cleanup logic
2020/11/10 09:22:02.505119 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed to install application dependencies. The deployment failed.","timestamp":1605000122,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1605000122,"severity":"ERROR"}]}]}
---------------------------------------------------------
I deleted the entry "anaconda-client==1.7.2" and still does not work. Same problem as well with anaconda-navigator==1.9.12, anaconda-project==0.8.3, Automat==20.2.0... I erased them all but there is always a new wrong requirement.
I guess the requirements.txt file is just wrong... any ideas to solve the problem? Did I
create the requirements.txt correctly? Might it be any kind of problem with the enviroments?
thanks a lot

===== docker migrate release ===== [FATAL tini (8)] exec /app/migrate.sh failed: Permission denied

Successfully tagged app-registry-local.aldryn.net/agrowdevapi-test-37ae123fee35488aa7afaf88779408b0.2403de75863d452293464511e6f01f0d:rel-57c445067a40479da6af0e140792c18a
finished docker build
===== docker migrate release =====
[FATAL tini (6)] exec /app/migrate.sh failed: Permission denied
Unfortunately because you are using an external Git repository, I cannot see exactly what is
occurring. However, based on experience, this is the issue.
The deployment fails because an error when it runs the migration commands:
[FATAL tini (6)] exec /app/migrate.sh failed: No such file or directory
You can see the same thing occurs locally if you run:
docker-compose run web ./migrate.sh
It's still not very informative, but try this:
docker-compose run web bash
followed by:
./migrate.sh
You will see:
bash: ./migrate.sh: /bin/sh^M: bad interpreter: No such file or directory
And this is the clue.
The first line of the ./migrate.sh file contains a ^Mcharacter, a Windows line ending. I think this may not be the only file affected - a git diff in your project seemed to show that many, many files were changed.
What editor are you using? You will need to resave that file, and possibly others. Please see https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings.
0
Unfortunately because you are using an external Git repository, I cannot see exactly what is occurring. However, based on experience, this is the issue. The deployment fails because an error when it runs the migration commands:
[FATAL tini (6)] exec /app/migrate.sh failed: No such file or directory
You can see the same thing occurs locally if you
run: docker-compose run web ./migrate.sh It's still not very informative, but try this:
docker-compose run web bash
followed by:
./migrate.sh
You will see:
bash: ./migrate.sh: /bin/sh^M: bad interpreter: No such file or directory
And this is the clue. The first line of the ./migrate.sh file contains a ^Mcharacter, a Windows line ending. I think this may not be the only file affected - a git diff in your project seemed to show that many, many files were changed.
What editor are you using? You will need to resave that file, and possibly others. Please see https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings.

trying to debug "502 Bad Gateway" error after deploying react app to gcp?

I've deployed a React app via "gcloud app deploy". The "gcloud app browse" command opens a browser which tries to load for a while but then displays a browser title of "502 Bad Gateway." I found the following troubleshooting page:
https://cloud.google.com/endpoints/docs/openapi/troubleshoot-response-errors#gae_errors
The following info on the troubleshoting page appears to be a good match for my scenario:
"An error code 502 with BAD_GATEWAY in the message usually indicates
that App Engine terminated the application because it ran out of
memory. The default App Engine flexible VM only has 1GB of memory,
with only 600MB available for the application container."
But I don't see any "out of memory" error reference in my logs for this. I think I probably need to ensure that I "gcloud app deploy" with a proper app.yaml file. I'm having problems identifying what is a valid minimum yaml file for my React app for which I can be assured that my "gcloud app deploy" will have the expected result. I found the following reference which appears to be a good starting point:
https://cloud.google.com/endpoints/docs/openapi/get-started-app-engine
^^^ This page refers to the following yaml sample code:
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/endpoints/getting-started/src/main/appengine/app.yaml
But the url refers to "java-docs-sample" so not sure if this is a vaid yaml file for a React app deployment. Can you provide some guidance on this? I'm really just looking for the minimum yaml file that I can use for a successful deployment. This is the structure of the yaml file that I used for my initial "gcloud app deploy", and the deployment process appeared to indicate success, but not sure if there is any type of fatal flaw here or anything else that may be missing:
runtime: nodejs
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
From what I understand, you just want a minimal good app.yaml for react apps as the out of memory seems to be the issue if everything else is correct.
A sample app.yaml for react is the following:
# [START runtime]
runtime: nodejs
env: flex
# [END runtime]
# [START handlers]
handlers:
- url: /
static_files: index.html
upload: index.html
# [END handlers]
But you need to modify your handlers according to your needs/ configuration.
502 error sometimes indicates that your app has an issue itself. So it's better to test locally first and make sure your app is working.
Then for the memory part, you can try specifying the instance type to be one with a higher memory. If it still throws the same error then most likely the issue is within your app or dependencies.
I think there is something about react-scripts start that google cloud doesn't like; I've had trouble with this (react app + google cloud deployment) twice in completely different environments (one had docker and one did not); but the first time I never posted anything to stack overflow so I had to go through the pain again :p
Try changing the package.json file to not use react-scripts start when you run npm run start.
Note that this will overwrite the npm run start and npm start command, so if you use this, you can also update the package json with another keyword such as local and change your local running process to involve writing npm run local
"scripts": {
"start": "serve -s build",
"local": "react-scripts start",
"build": "react-scripts build",
...
},
A working repo

eb deploy always fails

I have created a ruby env on amazon elastic beanstalk, but when I try to deploy my rails app from command line using eb deploy I get this error:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
You need to install git to be able to use gems from git repositories. For help
installing git, please refer to GitHub's tutorial at
https://help.github.com/articles/set-up-git (Executor::NonZeroExitStatus)
[2015-08-09T15:50:38.513Z] INFO [4217] - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/10_bundle_install.sh] : Activity failed.
[2015-08-09T15:50:38.513Z] INFO [4217] - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2015-08-09T15:50:38.513Z] INFO [4217] - [CMD-AppDeploy/AppDeployStage0] : Activity failed.
[2015-08-09T15:50:38.514Z] INFO [4217] - [CMD-AppDeploy] : Completed activity. Result:
Command CMD-AppDeploy failed.
So, shall I install git at amazon instance bash directly? will this effect autoscaling?
I don't know if you fixed this, but you need to tell Elastic Beanstalk to install git.
In the root directory of your project, add a folder called .ebextensions.
Create a file inside that folder called (something like) install_git.config (the .config is important).
Add the following lines to that file:
packages:
yum:
git: []
Then redeploy your application, and you shouldn't see that error anymore.