AWS elastic beanstalk configuration for rolling updates - amazon-web-services

Currently I'm trying to solve some mystery changing settings in an Elastic Beanstalk environment. I will try to explain the situation and what is happening.
We have a Jenkins server which we can command to create a build (artifact) to upload to an S3 bucket. The S3 bucket is watched by a cloudwatch event what will trigger a codepipeline and deploys the artifact to multiple ec2 instances.
Now on the EBS environment there are some settings, for example the rolling updates part. It seems that sometimes the DeploymentPolicy is 'magically' updated from rolling to allAtOnce. Me and my colleagues don't understand how this setting is changed, because no-one touches this part of the gui.
I've tried putting these settings into config files, but that didn't work out so well. I tried adding a env.yaml in the project root. The EBS is reading this file, but I get errors that the syntax is incorrect. I tried following this document, but I can't get it to work.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-manifest.html
Also I tried adding a file in .ebextensions/rolling_updates.config with the following content:
option_settings:
aws:elasticbeanstalk:command:
BatchSizeType: Percentage
DeploymentPolicy: Immutable
But that also didn't work. (I tried some other values just to check if the update worked)
Is there somebody who has done this before and can help me explain what I should do to fix this?
One thought that has crossed my mind is putting a config file in an S3 bucket and install AWS-cli on the Jenkins server. Then every deployment we can update the EBS config before uploading the artifact to S3. But I'm not sure that's a correct approach as well.
Thanks all!

Related

Creating a simple pipeline (CodeCommit repository

I have created a simple deploy pipeline using jenkins, I have created the codedeploy, the S3 Bucket, the Autoscalable group, the ami. Everything listed in the docs. But it needs a appspec.yml. I have looked at the documentation for appspec.yml. And it’s very confusing.
Is there any way to generate a appspec.yml. I am not even sure what its role is. I thought the code deploy would take the zip file out of the S3 Bucket and deploy it to the scaleble group.
Any help?
appspec.yml is the file that tells codedeploy service about what tasks it should do with the code on your EC2 servers. So it needs to be built according to your workflow. This documentation and the examples will help you what you want to achieve.
Is there any way to generate a appspec.yml
You can't auto-generate the file. It must be custom designed for your specific application, and only you know what your application is, how it works, how it is configured, what are its dependencies, and so on.

How to automate the code from Bitbucket to Amazon Ec2 Instance

I want to automate the process by which when I push my code to my private repository on Bitbucket, it will directly update on my EC2 Instances. For that I gained some knowledge which was like:
AWS CodeDeploy is used for that. What I have learned is:
Go to IAM Role and create the role and attach the policy i.e AmazonEC2RoleForCodeDeploy & AWSCodeDeployRole
Edit Trust Relationship -> "service": "codedeploy.amazonaws.com"
At the time of the creation of EC2 Instance use the IAM Role to the role which we just created.
But I am confused about the YML code which will be paste on Advance Details (at the time of Instance Creation).
I attended many Blogs and youtube tutorials but getting confused about the right implementation.
On some tutorial, used S3 for code deploy. I am a little confused about this problem regarding the automation process.
My simple requirement is When I update/push the code on my personal branch, it will update on my directory which is under my EC2 instance.
Any AWS expert or DevOps will help me with that, Kindly share the best efficient manner to achieve this task. I am Mentioning "expert" because I need the best and optimum solution not the solution to achieve the goal.
Any help or suggestion is really appreciated for that. Pardon me if there is some typo error or any grammatical error on mine query.
The basic steps would be:
Add the CodeDeploy addon from from Bitbucket's App Marketplace and
configure it.
To add an IAM role that allows Bitbucket to first push code to an
intermediate S3 bucket in your account.
Once you've configured the CodeDeploy settings from the Settings
page of the Bitbucket console, you can perform a deployment to the
Deployment group from your branch and monitor this in the Codedeploy
console.
The blog below has clear and detailed steps for this:
https://aws.amazon.com/blogs/apn/announcing-atlassian-bitbucket-support-for-aws-codedeploy/
The Yaml file you are confused about is the Appspec file that tells CodeDeploy what actions to perform during a Deployment.
The bare minimum appspec.yml file you can have to deploy all the files from the source package:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html
This file is placed in the root of your source code.
Appspec file example:
https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-example.html#appspec-file-example-server

AWS Elastic-Beanstalk: ECS task stopped due to: Task failed to start. (nginx-proxy: php-app: )

I'm trying to move my Laravel website to Elastic beanstalk using this github script:
https://github.com/peec/laravel-aws
Everything should work out of the box, including RDS db, SQS for queues, elastic cache etc..
I did as requested, but, from some reason, I have this error (even though I have nothing on my website folder, Just make elastic beanstalk work with the docker):
Any idea how can I make it run? or, how should I remove the errors above?
you can find the "Dockerrun.aws.json" file on the github library above, didnt change anything except the AWS Keys on the .ebextensions -> options.config
Thank you!
Eran.

`eb config save`: The specified key does not exist

Why is it saving configuration is giving me S3 error?
The configuration is actually saved. I can see it in aws console:
and in the S3 bucket:
But not locally in .elasticbeanstalk/. What am I missing?
Double which application eb cli is using. The eb cli allows you to operate on Environment which are not part of the Application which is currently selected by the EB CLI. To fix it you can eb init again or change directory to a dir which has been initialized with the right application.
I realize I'm answer far too late to help with the original question, but I arrived here by google search, so I'm hoping to help someone further down the timestream.

How to Publish Docpad Website to AWS S3

I've seen the documentation on how to deploy to AWS S3 but am at a bit of a loss still (I also used this unfinished tutorial.
Do I need to setup an EC2 account? Where do I put the package.json file? Do only the out files (and package.json) need to be uploaded to Amazon? Does all of this go into the bucket MyWebsite.com?
Note - I'm new to web programming.
As you pointed out my tutorial is unfinished, but I hope it helped a little. Hopefully I can clarify a few things:
You're spot on with --env static. You need to add that to everything you do with DocPad so that what you see locally is the same as what you plan to deploy. I.e. you need to use DocPad run --env static too.
My 'tutorial' was on how to point AWS CloudFront at a root domain. This can be a frustrating experience particularly if you're just starting out with static sites. If you're using CloudFront, consider switching to just use S3. You can do this easily by changing the configuration in Route 53.
My tutorial misses an important step; You need to create another bucket with the name of your domain with www. in front of it if you would like to use www as well as your root domain. You then configure that bucket as a website and redirect it to the bucket with your website. This is all configuration.
You only need to upload everything in the out folder. package.json is not needed once the site has been generated.
Check out the source to my site and copy what you need. My whole deployment to S3 is automated through Grunt.
Have fun!
I finally found the answer to my question.
Basically what I needed to do was install the Docpad plugin cleanurls. I then needed to use the command line:
docpad generate --env static
And then upload to the AWS S3 bucket.
Here's the stack overflow answer where I gathered this information from.