AWS Elastic Beanstalk not deploying code fixes - django

I'm using aws EB to deploy my django app. I use the AWSEBCLI.
Everything works fine but if for some reason I mistakenly deploy broken code the ebcli will never deploy a new corrected version.
I'll have to SSH into the EC2 instance and fix it manually. Why? is there a way to force new code?
For example, I do some edits and I run git add . then git commit -m 'xx' then eb deploy
the result is:
TabError: inconsistent use of tabs and spaces in indentation.
container_command 01_migrate in .ebextensions/02_python.config failed.
For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-xxx'. Aborting the operation.
ERROR: Failed to deploy application.
At this point even if I edit the code, fix the indentation make the new git adds & commits eb will always show me this error until I SSH into the instance and I fix it manually.
Only then it will start to accept new commits. I really don't understand why and is rather annoying. Any ideas on how to skip the whole SSH part?

Related

Errors when applying AWS eb commands

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html
I'm trying to follow these steps to deploy an example of an Express application for the first time. After installing the Elastic Beanstalk Command Line Interface (EB CLI), I can apply eb commands in the Command Prompt (using Windows 10). After initializing a Git repository, I should use commands to configure an EB CLI repository.
These command are being applied in the directory of an an ExpressJS project:
First I enter the command: eb init – platform Node.js – region us-east-2 which results in the message in a separate window Application AWS2 has been created.
Next I enter command: eb create – sample node-express-env which results in the error message ERROR: InvalidParameterValueError - Environment node-express-env already exists.
Then when I enter the command: eb open the message says ERROR: This branch does not have a default environment. You must either specify an environment by typing "eb open my-env-name" or set a default environment by typing "eb use my-env-name".
Then when I enter: eb open node-express-env there's another message ERROR: NotFoundError - Environment "node-express-env" not Found. which contradicts the message from 2.
Make sure that, you configured the CLI to use the same region in which your environment is created.

AWS: ERROR: Pre-processing of application version xxx has failed and Some application versions failed to process. Unable to continue deployment

Hi I am trying to deploy a node application from cloud 9 to ELB but I keep getting the below error.
Starting environment deployment via CodeCommit
--- Waiting for Application Versions to be pre-processed --- ERROR: Pre-processing of application version app-491a-200623_151654 has
failed. ERROR: Some application versions failed to process. Unable to
continue deployment.
I have attached an image of the IAM roles that I have. Any solutions?
Go to your console and open up your elastic beanstalk console. Go to both applications and environments and delete them. Then in your terminal hit
eb init #Follow instructions
eb create --single ##Follow instructions.
It would fix the error, which is due to some application states which are failed. If you want to check those do
aws elasticbeanstalk describe-application-versions
I was searching for this answer as a result of watching a YouTube tutorial for how to pass the AWS Certified Developer Associate exam. If anyone else gets this error as a result of that tutorial, delete the 002_node_command.config file created in the tutorial and commit that change, as that is causing the error to occur.
A failure within the pre-processing phase, may be caused by an invalid manifest, configuration or .ebextensions file.
If you deploy an (invalid) application version using eb deploy and you enable the preprocess option, The details of the error will not be revealed.
You can remove the --process flag and enable the verbose option to improve error output.
in my case I deploy using this command:
eb deploy -l "XXX" -p
And can return a failure when I mess around with .ebextensions:
ERROR: Pre-processing of application version xxx has failed.
ERROR: Some application versions failed to process. Unable to continue deployment.
With that result I can't figure up what is wrong,
but deploying without -p (or --process)and adding -v (verbose) flag:
eb deploy -l "$deployname" -v
It returns something more useful:
Uploading: [##################################################] 100% Done...
INFO: Creating AppVersion xxx
ERROR: InvalidParameterValueError - The configuration file .ebextensions/16-my_custom_config_file.config in application version xxx contains invalid YAML or JSON.
YAML exception: Invalid Yaml: while scanning a simple key
in 'reader', line 6, column 1:
(... details of the error ...)
, JSON exception: Invalid JSON: Unexpected character (#) at position 0.. Update the configuration file.
Now I can fix the problem.

AWS Elastic Beanstalk Issues Failed to deploy on all servers

Yesterday and today i tried to deploy on aws eb but I always get this error:
INFO: Environment update is starting.
INFO: Deploying new version to instance(s).
INFO: Environment health has transitioned from Ok to Info. Command is executing on all instances.
WARN: Environment health has transitioned from Info to Severe. None of the instances are sending data.
ERROR: Failed to run npm install. Snapshot logs for more details.
ERROR: [Instance: i-0632a672238b6ee0b] Command failed on instance. Return code: 1 Output: (TRUNCATED).../opt/elasticbeanstalk/containerfiles/ebnode.py", line 166, in npm_install
raise e
subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status -9.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-0632a672238b6ee0b'. Aborting the operation.
ERROR: Failed to deploy application.
ERROR: Failed to deploy application.
The built was successfull yesterday and i tried to push the old version and on another instance i just tried to deploy again. every instance is now in status severe or degraded.
Is this a aws issues, did i do something wrong? I did all the steps i do everyday and until now i never had any issues. Even after i uploaded the old applicationzip which was okay nothing changed.
I am having exactly the same issue. Build started to fail during the last weekend. Due to logs, the problem seems to be that while running npm install, the process runs out of memory. It doesn't matter whether I deploy directly or use a Docker container.
I am using a free tier micro instance with 1 GB of memory. I just can't understand why it worked before and now it doesn't work even if I deploy the same version that was working before...

I am deploying with 'eb deploy' in aws but getting the following error

I am using 'eb deploy' for deploying my commits but getting this error
WARNING: You have uncommitted changes.
Creating application version archive "6fea".
Uploading: [##################################################] 100% Done...
INFO: Environment update is starting.
INFO: Deploying new version to instance(s).
ERROR: [Instance: i-10d1f9ec] Command failed on instance. Return code: 126
Output: /bin/sh: ./scripts/update-ftp-dns.sh: /bin/sh^M: bad interpreter: No such file or directory.
container_command 07-update_ftp_dns in .ebextensions/03-vsftpd.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
INFO: New application version was deployed to running EC2 instances.
ERROR: Update environment operation is complete, but with errors. For more information, see troubleshooting documentation.
Please help me to solve this.
The error message is a bit hidden, but it's in there:
Output: /bin/sh: ./scripts/update-ftp-dns.sh: /bin/sh^M: bad interpreter: No such file or directory.
If I had to guess, you have a line break with both a line feed and a carriage return in it. It's treating the carriage return character as if it's part of the name of the executable.
Make sure that you've converted the /scripts/update-ftp-dns.sh script so that it uses Unix line endings only.
See ./configure : /bin/sh^M : bad interpreter
I had something similar, and the cause was having Git's autocrlf value set to true. What this means is that Git will convert the file to a Windows-formatted one when git checkout is run - which unfortunately means that the Elastic Beanstalk tool tries to upload Windows-formatted files to your Linux server, which will manifest in errors like this.
I fixed it by switching autoclrf to false, and committing the relevant file again. Do be aware of the repercussions of this however.

AWS Elastic Beanstalk - ERROR: No Application Version named 'v0_9_2-76-gf5a4' found

I'm trying to deploy my code to AWS Beanstalk and get this error. I researched that it could be that the number of versions is more than 500, so I deleted a lot of versions. But, I still get this error.
eb deploy
ERROR: No Application Version named 'v0_9_2-76-gf5a4' found.
I also tried
git aws.push
Error: Failed to create the AWS Elastic Beanstalk application version
Edit:
Trying with eb deploy --debug I now get:
Instance: i-2ad238d5 Module: AWSEBAutoScalingGroup ConfigSet: null Command failed on instance. Return code: 1 Output: Error occurred during build: Command hooks failed . Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 18
ebcli.objects.exceptions.ServiceError: Update environment operation is
complete, but with errors. For more information, see troubleshooting
documentation.
Did you update the file .elasticbeanstalk/config.yml ? It may have a wrong setup.
Make a backup of .elasticbeanstalk/ folder and remove it
Execute eb create
Select the same region you deployed it before. You can check the region on .elasticbeanstalk/config.yml backup
A list with the environments will appear, select the right one
Deploy now
Remove the .elasticbeanstalk/config.yml backup
Check for the .elasticbeanstalk/config.yml file
environment: CORRECT_ENV_NAME
global:
application_name: CORRECT_APP_NAME
In my case, I was doing eb deploy X where X was an environment for a different project.
When I had the error
InvalidParameterValueError: No Application Version named 'app-9f5c-180927_071528' found.
I fixed this by specifying the label I wanted to push up.
eb deploy XXX-env -l XXX.0.0.1
The -l flag is documented AWS EB Deploy Docs
most likely, the deploy is trying an incorrect Elasticbeanstalk Application. it could be because you renamed the application in the AWS console.
so double check you're pointing to the correct elasticbeanstalk Environment and Application. it could be picking out default values from your .elasticbeanstalk/config.yml file.