Best practices with OpsWorks Setup Failure - amazon-web-services

yesterday I setup our AWS OpsWorks Bench. We are using a custom cookbook which we are hosting on GitHub. I saw that the setup process failed and had a look in the logs. I saw that the custom cookbook could not be fetched from GitHub because they had server problems. Therefor the setup on the server failed and the process stopped.
Does anyone know if I could handle that sort of failures and restart the setup process till it is done?

One way to avoid issues like this is to host your assets on S3. Alternatively you can poll the deployment status to determine if it succeeds or fails and then have some retry logic.

Related

Which is the best way on AWS to set up a CI/CD of a Django app from GitHub?

I have a Django Web Application which is not too large and uses the default database that comes with Django. It doesn't have a large volume of requests either. Just may not be more than 100 requests per second.
I wanted to figure out a method of continuous deployment on AWS from my source code residing in GitHub. I don't want to use EBCLI to deploy to Elastic Beanstalk coz it needs commands in the command line and is not automated deployment. I had tried setting up workflows for my app in GitHub Actions and had set up a web server environment in EB too. But it ddn't seem to work. Also, I couldn't figure out the final url to see my app from that EB environment. I am working on a Windows machine.
Please suggest the least expensive way of doing this or share any videos/ articles you may hae which will get me to my app being finally visible on the browser after deployment.
You will use AWS CodePipeline, a service that builds, tests, and deploys your code every time there is a code change, based on the release process models you define. Use CodePipeline to orchestrate each step in your release process. As part of your setup, you will plug other AWS services into CodePipeline to complete your software delivery pipeline.
https://docs.aws.amazon.com/whitepapers/latest/cicd_for_5g_networks_on_aws/cicd-on-aws.html

AWS Elastic Beanstalk logs? Access more detailed logs?

I currently deploying a couple of apps with Elastic Beanstalk and have some open questions. One thing that bugs me about EB is the logs. I can run eb logs or request the logs from the GUI. But the result is kind of confusing to me since I can't find a way to access the normal stdout for a running process. I'm running a Django app and it seems like the logs automatically show every log that is explicitly set to a Warning priority.
In Django, there are a lot of errors that seem to slip through the log system (e. g. failed migrations, failed custom commands, etc.)
Is there any way to access more detailed logs, or access the stdout of my main process? It would also be ok, if they would stream to my terminal, or if I had to ssh on the machine.
I suggest using the cli to enable the cloudwatch logs with eb logs --cloudwatch-logs enable --cloudwatch-log-source all. This will allow you to see the streaming output of web.stdout.log along with all of your other logs individually.

S3 to EC2 problems

I´m trying to transfer a project from TeamCity to my EC2 server using CodeDeploy. In the process we had a problem and the file isn´t being transfered from the S3 service to our EC2 instance. The error message is :
The overall deployment failed because too many individual instances
failed deployment, too few healthy instances are available for
deployment, or some instances in your deployment group are
experiencing problems. (Error code: HEALTH_CONSTRAINTS)
The team decided that the best way to solve this problem was reading the server log, but in the process we noticed that the server keeps shutting down alone and that was a huge problem, we tought that can be solved with the logs, so we tried to get them using CodeWatch ( our team created the correct IAM and with a run command installed the agent on the server). Sadly this work only managed to get shutting down or turning information on logs.
At this moment we don´t know how to solve this problem but our plain was to get all the logs and then see what is wrong.
I´m stucked at this part since setember, can someone help me ?

Using Cloudformation with a Chef Server

I'm exploring some disaster recovery scenarios and how to comeback from them quickly. Disasters like our root AWS account being hacked, or all of Oregon going down. Basically situations where we need to recreate our entire infrastructure in another region or account.
Obviously Cloudformation is the best way to tackle this, but I have some questions on how to integrate it with Chef. My plan is to have a CF script create a new Chef server as well as all the other servers, then the Chef server pulls all it's cookbooks from a repository and configures all the servers. Is this a reasonable process or is there a better way to handle it?
I figured this was better than maintaining AMIs specific to applications and copying those over.
Thanks for the help in advance!
Chef has a chef-server cookbook that will provision a stand-alone instance. I'm actually writing a wrapper for it now as I'm dealing with the same situation.
Our plan is similar to yours but we're using Terraform to orchestrate the environments.
Have a repository of cookbooks gzipped and ready for deployment. After provisioning and configuring the Chef server, deploy said cookbooks to it. The Chef server would need to be fully bootstrapped with all cookbooks, environment configs, and data bags before attempting to create any other nodes. Once complete, bootstrapping the rest of the environment would look like any other deployment.

How do I kill a deployment in AWS Opsworks?

How do I kill a long running deployment in Amazon Opsworks?
We run deployments to an integration environment everytime we commit to our code repo. Our current deployments are taking a long time, which causes deployments to stack on top of each other in Opsworks. We're working on making our deployment process for the application more efficient, but until we get that sorted out, is there an easy way to kill a deployment so we can just run the latest one in the queue?
Unfortunately there is no easy way.
There is no API call to cancel them.
So the only possible approach would be checking on the instance if it's necessary to run the deployment or skip it. You can achieve this with a custom cookbook.