Elastic Beanstalk: How can my team deploy code to the same environment? - amazon-web-services

I was previously on Google App Engine and have migrated to Amazon Elastic Beanstalk. My team and I are working together on a website, but only I have managed to deploy code from my own computer.
How would my team go about deploying the code to the environment from their own computers? They have installed the eb command line tool.

They need to install EB CLI on their computer. Once EB CLI is install they can run "eb deploy" command. More information here.

Run eb init and eb create on one machine so that the environment is up and running.
On all machines you need setup .elasticbeanstalk and ..ebextensions folders, add them to git for example.
Run aws configure on each machine. The profile name in .elasticbeanstalk/config needs to match to the credentials in ~/.aws/config
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
Don't forget to add permissions to your users. You can start with power user permission, but you should create a more specific role/policy for this later.
When this is setup all your users should be able to eb deploy.

Related

Elastic Beanstalk Always Updates Environment On Deploy From Codebuild

I have a large, multi-component django application I am trying to deploy to elastic beanstalk. I am using the multi-docker environment. THis is my current workflow
Git commit triggers AWS code pipeline
AWS Codebuild builds docker image (docker-compose build), runs some tests, and pushes this image to AWS Elastic Container Registry
AWS Code Build calls eb deploy
The issue I am running into is that when I call eb deploy from my local box, the it simply upgrades the application, but when I call it from Code Build, it is upgrading the environment every time, which takes about 30 minutes for some reason
I run the deploy command with -v and confirmed that the same files are being zipped. Any ideas on what is going on here, is my setup incorrect?
I also tried to deploy the application from Code Deploy in the pipeline and can confirm that it also always upgrades the entire environement.
I think that if you use CB to update your EB env, it just replaces it as it is being considered as a new environment. In your local workstation you are using only one single environment, but with new application version.
I would consider replacing CB for updating your EB environment, with the EB deploy provider in your CP. This should successful just upload your new application version to an existing EB environment.
CP natively supports a number of deploy action providers, one of the being Elastic Beanstalk:
You can configure CodePipeline to use Elastic Beanstalk to deploy your code. You can create the Elastic Beanstalk application and environment to use in a deploy action in a stage either before you create the pipeline or when you use the Create Pipeline wizard.

AWS How to deploy my internet site created with Typescript on AWS

I have create a website using VS Code in NodeJS with typescript language.
Now I want to try to deploy it on AWS. I read so many things about EC2 , Cloud9 , Elastic Beanstalk, etc...
So I'm totally lost about what to use to deploy my website.
Honestly I'm a programmer, not a site manager or sysops.
Right Now I create an EC2 instances. One with a Key name and One with no key Name.
In the Elastic Beanstalk, I have a button Upload and Deploy.
Can someone send me the way to create my project as a valid package to upload and deploy it ?
I never deploy a website. (Normally it was the sysops at the job). So I don't know what to do to have a correct distributing package.
Does I need to create both EC2 and Beanstalk ?
Thanks
If you go with ElasticBeanstalk, it will take care of creating the EC2 instances for your.
It actually takes care of creating EC2 instance, DB, loadbalancers, CloudWatch trails and many more. This is pretty much what it does, bundles multiple AWS services and offers on panel of administration.
To get started with EB you should install the eb cli.
Then you should:
go to your directory and run eb init application-name. You'll start a wizard from eb cli asking you in which region you want to deploy, what kind of db and so on
after that your need to run eb create envname to create a new env for your newly create application.
at this point you should head to the EB aws panel and configure the start command for your app, it usually is something like this npm run prod
because you're using TS there are a few steps you need to do before being able to deploy. You should run npm run build, or whatever command you have for transpiling from TS to JS. You'll be deploying compiled scripts and not your source code.
now you are ready to deploy, you can run eb deploy, as this is your only env it should work, when you have multiple envs you can do eb deploy envname. For getting a list of all envs you can run eb list
There are quite a few steps to take care before deploying and any of them can cause multiple issues.
If your website contains only static pages you can use Amazon S3 to deploy your website.
You can put your build files in S3 bucket directly and enable static web hosting.
This will allow anyone to access your website from a url globally, for this you have to make your bucket public also.
Instead you can also use cloudfront here to keep your bucket private but allowing access to bucket through cloudfront url.
You can refer to below links for hosting website through s3.
https://docs.aws.amazon.com/AmazonS3/latest/user-guide/static-website-hosting.html
https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serve-static-website/

How to deploy a spring boot application jar from Jenkins to an EC2 machine

I'm seeing so many different sources how to to achieve CI with Jenkins and EC2 and strangely none seem to fit my needs.
I have 2 EC2 ubuntu instances. One is empty and the other has Jenkins installed on it.
I want to perform a build on the Jenkins machine and copy the jar to the other ubuntu machine. Once the jar is there i want to run mvn spring-boot:run
That's is - a very simple flow which i can't find a good source to follow that doesn't include slaves, dockers etc..
AWS Code Deploy lets you use a Jenkins and deploy it on your EC2 instances.
Quick google search gave me this very detailed instruction on how to setup code pipeline with AWS Code Deploy.
The pipeline uses GitHub -> Jenkins -> EC2 flow, as you need it.
Set up jenkins to do a build then scp the artifact to the other machine
There's an answer here how to setup ssh keys for jenkins to publish via ssh about setting up the keys for ssh

What files are needed for the AWS EB CLI 3.x tools?

I've recently switched from old AWS EB CLI tools (2.6.4) to the current ones (3.0.10) and am wondering how to ensure that my project's configuration is migrated, and what configuration files I should keep.
I've run (the new version of) eb init and now have, in my project's .elasticbeanstalk directory, a new file
config.yml
along with several ones that were there before
config
optionsettings.sitetest-develop-env
optionsettings.sitetest-env
which of these are still needed; which can I delete; and what steps to I need to take to ensure that all of the old settings have been migrated to (and to the right place for) the 3.x AWS EB CLI tools?
#BMW's answer is very clear and good, but I thought I would provide a more condensed version.
The only file the EB CLI 3.x needs is the config.yml in the .elasticbeanstalk folder
While 3.x will attempt to read your 2.x configurations and port them over, it is not needed. 3.x will also pull down settings from any running environments. Therefore the cleanest way to upgrade to 3.x is to create a new directory and use EB init. It will sync with your existing application and environment(s).
I used the latest version (3.x) directly and didn't realise the difference between eb 2.6.x and EB CLI 3.x at beginning. Thanks to raise this question (+1) .
Here is what I got from AWS Elastic Beanstalk documents.
Old version is called eb 2.6.x, new version is called EB CLI 3.x, the configuration difference between these versions has been explained clearly by this url
EB Command Line Interface
EB is a command line interface (CLI) for AWS Elastic Beanstalk that you can use to deploy applications quickly and more easily. AWS Elastic Beanstalk supports eb 2.6.x and EB CLI 3.x. You can use EB CLI 3.x to manage environments that you launched using eb 2.6.x or earlier versions of eb. EB CLI will automatically retrieve settings from an environment created using eb if the environment is running. Unlike eb, EB CLI does not store option settings locally.
Why you have these folder/files (such as config, optionsettings.sitetest-develop-env, optionsettings.sitetest-envin) in your environment, here is the explanation Eb Operations, that's only for eb 2.6.x
You can use a configuration file in an .ebextensions/.conf* directory to configure some of the same settings that are in an .elasticbeanstalk/optionsettings file. However, the values for the settings in .elasticbeanstalk/optionsettings will take precedence over anything in .ebextensions/*.conf if the settings are configured in both. Additionally, any option setting that is specified using the API, including through eb, cannot later be changed in an environment using .ebextensions configuration files.
Finally, answer your question. If you have upgraded the version to EB CLI 3.x, then you can clean these files, but you still need keep config.yml, it is created when eb init in EB CLI 3.x.

how to restart Django server without terminating database and server instance - AWS

I am hosting a Django application on AWS Elastic Beanstalk. I recently made changes to my URLS.py and apparently (according to this thread: Django ignoring changes made to URLS.py file - Amazon AWS ) I need to 'reload the django process / restart the thread'. I figured that meant for me to run
eb stop
and then
eb start
again but when I ran
eb stop
it needed to first terminate my database as well as my EC2 instance, cloudwatch alarm etc. Is there any way for me to restart the DJango process so that it can update the URLS.py file without me having to run
eb stop
eb start
?
You do not need to stop and start your environment. From what I understand you need to update your environment with your updated source code. Did you try git commit folloed by git aws.push?
Take a look here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-reference-get-started.html
Let me know if you run into any issues with git aws.push.
You can also try restart app server on your environment using aws cli:
http://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/restart-app-server.html
But as far as I can tell, git aws.push will suffice.
I've had troubles with my Django files not updating after using:
$ eb deploy
The eb cli tool does not have a restart command, however you can login to the AWS console and restart your environment through the actions menu on the dashboard for your eb environment.
This generally fixes any issues that I have. However sometimes I've had to ssh directly into the instance and enable debugging through the settings.
The other command that Rohit referenced is from a different aws cli tool. I haven't personally tried it but here is more documentation on the command and how to install it:
http://docs.aws.amazon.com/cli/latest/userguide/installing.html