How to handle elastic beanstalk deployment so it u

2019-07-18 23:42发布

问题:

I am having issue with elastic beanstalk as I am new to AWS. I setup everything and deployed first app, so far so good. But when I pushed another bunch of changes, it just replaced whole files rather than just changed ones. During the development there are different configs at localhost and server so there will be different files, but in this case what you have in local is in server, which is a bit strange.

Can you suggest what to do ?

回答1:

If I understand correctly, you are asking two questions:

  1. Can you push only changed files? From my understanding, I do not think you can. The entire source bundle is uploaded and could be pushed to the same or different servers. Every time you deploy it is essentially a fresh environment (depending on strategy i.e. blue-green).

  2. Local vs Production config files: In order to use different files, you either need to only provide them in the source bundle, or alter them during the deployment process by adding scripts to a .config file in .ebextensions. Take a look at customizing elastic beanstalk containers



回答2:

I don't know since when, but now you can push only changed files by using Git deployment in the AWS.

Q: How quickly will my application get updated?

Deploying new application versions to existing resources (e.g. environments) happens much faster (typically under a minute) and is mostly dependent on the size of the new application version. With Git deployment, only the modified files are transmitted to AWS Elastic Beanstalk and updates typically take a few seconds.

Source: https://aws.amazon.com/elasticbeanstalk/faqs/



回答3:

I think the reference means that only the changed files get uploaded for the new bundle creation, but the bundle still has all of the server applications in it for each new bundle created. I think you may be confusing the applications pushed with the source bundle.

This is a great source that I used to setup my deployment process. http://www.deplication.net/2013/11/java-war-deployment-options-on-aws.html

Basically in elastic beanstalk you have applications that have environments. Environments run ec2 server instances (scalable if chosen) of any different type of code server chosen whether java, .net, etc. Your environments deploy and run something called an application version tied to a source bundle.

Application versions are only available for any environments of that application, but will fail to work if the environment is a different type than the applications in that version. Application versions for application1 would not be available for an application called application2. You probably can have multiple application versions for any source bundle. So you could have an application version for application2 that points to a source bundle used for an application version in application1.

This source bundle mentioned can be your single application. In java you can have .war applications. You could upload a single .war file. This would run at your root or index and not need the application name.

In the case of multiple application deployment you would upload a zip containing .war files (each bundle cannot be larger than 512 mbs). If a .war were called test.war you would access this java service by giving the ebs (elastic beanstalk) url w/ test. E.g. ebsurl/test. To have an index .war file you would call it ROOT.war. This zip file or single .war file you upload is called your source bundle

There are 3 ways to push up your files to deploy. Upload through the ebs gui, use git as your mentioning, or upload the app/zip to s3- create a source bundle- then deploy that source bundle to an environment in ebs. The guide from that link I gave shows how to do this with java.

It is worth mentioning that all source bundles are stored in the s3 bucket tied to the ebs application I believe. This means when you upload a zip to ebs, to s3, or push through git it gets saved in s3.

Every source bundle or application can have an application version created from it. These are what are deployed to the ec2 instances. You can to this through command line, w/ git, or upload to ebs these are created automatically with each source bundle.

In the case of git you add your changes, push the changes, it then may generate a new source bundle with all the changes what was pushed may only be the changed, but the whole bundle is new. It may then deploy that application version generated from the source bundle created. Now I don't know if all the apps are then redeployed or only those changed. Like say you updated ROOT.war and create a new zip with the same test.war and upload or git push that. Would it redeploy both or just ROOT.war. In a scalable environment it would have to roll out these changes to all the ec2 instances that exist.

This is my understanding of how ebs deployment from a high level works. Hope this helps clarify.