Cannot see events in AWS CodeDeploy - aws-code-deploy

My CodeDeploy deployment is failing. Usually I'm able to see the event list on each instances, and see which ones failed/passed.
This no longer works, and the event list is empty. What could be causing this?

As Jonathan Turpie mentions, you should probably troubleshoot if the instance is taking care of your deployment.
You could first try to troubleshoot via AWS CLI, aws deploy get-deployment --deployment-id d-USUAELQEX. It might return error codes that will help you to tweak your setting and succeed with your deployment. See http://docs.aws.amazon.com/cli/latest/reference/deploy/get-deployment.html
If your EC2 instance actually handles the deployment. Edit the /etc/codedeploy-agent/conf/codedeployagent.yml and set :verbose: to true on your EC2 instance.
Try to deploy again and open codedeploy-agent.log at /var/log/aws/codedeploy-agent and see if you are able to see anything there. Read more here: http://docs.aws.amazon.com/codedeploy/latest/userguide/host-cleanup.html

You may not be able to see events if the deployment didn't get far enough. For example, there was a problem getting the list of instances due to IAM configuration or your instance isn't responding to commands.

Check the codedeploy-agent-log.txt file. it might have some more info about the underground issue. in a windows machine you find it under
C:\ProgramData\Amazon\CodeDeploy\log

As mentioned by Jonathan, you might not have the right configuration for your IAM configurations. Check that your IAM role has the policy "AWSCodeDeployRole".

This happens when the code deploy agent is not running. Make sure the code deploy agent is running:
sudo service codedeploy-agent status

Related

Prevent appspec from running scripts (disable hooks)

I'm new to codedeploy. I managed to make a deployment to an ec2 instance successfully (and using git to manage code so everything works beautifully now).
I want some other people besides myself working in the project to be able to deploy source code to the instance but not be able to run a script (especially because codedeploy seems to be running as root). Think of it as an admin/webmaster scenario.
In other words, appspec.yml has the "hooks" section under it and you can run any scripts as part of the deployment. I want to prevent this, the instance has all the software ready for the deployment so won't be needing this.
2 questions:
1) Does this make sense or am I grossly misunderstanding something/am I overkilling by using codedeploy altogether?
2) If it makes sense, how can I achieve this?
This doesn't seem to be something that CodeDeploy is able to do at this moment. But do you want to disable the auto deploy from Github to CodeDeploy? And if anyone else push a code change, it'll exist on Github. When you are ok with the changes, you can do a manually deployment from Github on CodeDeploy console.

Writing an appspec.yml File for Deployment from S3 (and/or Bit Bucket) to AWS CodeDeploy

I'd like to make it so that a commit to our BitBucket repo (or S3 Bucket) automatically deploys code (using CodeDeploy) to our EC2 instances. I'm not clear what to use for the 'source' and 'destination' entry under the 'files' section in the appspec.yml file and also I am not cleared what to mention in BeforeInstall and AfterInstall under 'Hooks' section. I've found some examples on Google and AWs documentation but I am confused what to mention in above fields. The more I am exploring more I am getting confused.
Consider I am new to AWS Code Deploy.
Also it will be very helpful if someone can provide me step y step link how to configure and how to automate the CodeDeploy.
I was wondering if someone could help me out?
Thanks in advance for your help!
Thanks for using CodeDeploy. For new users, I'd like to recommend the following things to do:
Try to run First Run Wizard on console, it will should you the general process how the deployment goes. It also provide a default deployment bundle, also an appspec file included.
Once you want to try a deployment yourself, the Get Started doc is a great place to help you with some pre-requiste settings like IAM role
Then probably try some tutorials for a sample app too, which gives you some idea about deployment groups, deployment configuration, revision and so on.
The next step should be create a bundle for your own use cases, Appspec file doc would be a great place to refer. And for your concerns about BeforeInstall and AfterInstall, if your application doesn't need to do anything, the lifecycle events can be left as empty. BeforeInstall can be used to for for preinstall tasks, such as decrypting files and creating a backup of the current version, while AfterInstall can be used for tasks such as configuring your application or changing file permissions.
Now it comes to the fun part! This blog talks about details about how to integrate with Github(similar for Bitbucket). It's a little long, but really useful, and it also includes how to do automatically deployment once there is a new pushed commit. Currently Jenkins and CodePipline are really popular for auto-triggered deplyoments, but there are always a lot of other ways can achieve the same purpose like Lamda and so on

Can't deploy to Elastic Beanstalk: ERROR_FILE_IN_USE

My Elastic Beanstalk installation won't deploy through Visual Studio due to this error:
2016-07-01 20:45:02,627 ERROR 1 AWSBeanstalkCfnDeploy.DeploymentUtils - Exception during deployment.
Microsoft.Web.Deployment.DeploymentDetailedClientServerException: Web Deploy cannot modify the file 'msvcr100.dll' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
The link suggests that I create a pubxml file with settings to enable AppOffline, but this file only seems to be relevant for publishing through VS using the built-in Publish feature. I haven't found any documentation suggesting that this will work for AWS.
How do I enable AppOffline for an Elastic Beanstalk deployment?
Thanks!
Sorry that this is only general advice and not the code you need, but the solution is to use hooks via .ebextensions. Please see http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref-hooks.html.
You can add the execution of a powershell script to add app_offline.htm before the update is extracted and remove it once the update is deployed.
We had a similar issue, but the DLL in question (abcPDF, v9) was only blocked because we were initializing the licensing of it during application_start(), which EB did not like. So we moved applying the license elsewhere.
However, I think this approach would work.
--
Oh, maybe this container command will work for you. It recycles the IIS app pool right before the It didn't for us because of the aforementioned licensing locking the DLL.
/.ebextensions/recycleapppool.config
container_commands:
__recycle_app_pool:
____command: c:\windows\system32\inetsrv\appcmd.exe recycle apppool DefaultAppPool
After quite a lot of experimentation, the only working solution I could find for this problem was
// in Project/.ebextensions/reset.config
container_commands:
00_nuke:
command: IISReset
waitAfterCompletion: 0
The cost was about 4 seconds of downtime (on a t2.micro), during which you get a 503, which certainly isn't great.
Note there's a Github issue for this (open at the time of writing).
If you have the option, deploy your service to Azure rather than AWS and there are configuration options to work around the issue (such as an environment variable MSDEPLOY_RENAME_LOCKED_FILES) - related Azure specific question.

Permanently configure Meteor development MongoDB url

I am trying a test to move all my development to Nitrous.io IDE, but with limited space in my Nitrous box I want to permanently host my Mongo databases at MongoHQ.com. Currently each day I need to set my MONGO_URL by running:
export MONGO_URL='mongodb://<user>:<pass>#paulo.mongohq.com:12345/<db>'
If I fire up another console or logout of Nitrous my MONGO_URL needs to set again.
How can I set the development MONGO_URL for good per meteor app? I cannot find a config file anywhere.
Nitrous support helped me find a quick solution. Just wanted to answer it here for others with the same issue.
Open ~/.bash_profile and enter your DB information.
example:
export MONGO_URL='mongodb://jimmy:criket#paulo.mongohq.com:12345/mynitrobox'
Next in the console run source ~/.bash_profile to load the settings.
This sets the DB for your entire node.js box, not individual meteor apps, so you may want to structure your Mongo collections accordingly with subcollections.
you can do this in one line like so:
MONGO_URL='mongodb://<user>:<pass>#paulo.mongohq.com:12345/<db>' meteor
I don't know much about Nitrous.io but in AWS EC2 I have an upstart job that runs this for me when the server starts.
I gist'd my approach a while back, I've since changed it a bit but this still works:
https://gist.github.com/davidworkman9/6466734
I don't know that this will help you in Nitrous.io though, good luck!

Git Deployment Succeeds But No Changes

I found myself in the weirdest situation here. I have been deploying to Azure via Git for a while now with no issues. However, I just pushed a fairly large set of changes to Azure got no error but nothing changed...
Tried to push again got "Everything up to date"
So, I logged into the Azure management console and looked under deployments and sure enough the push isn't there.
Suggestions? As an aside, I am not an a Mac and I know there are issues with pushing to Azure from a Mac.
UPDATE: Fixed the issue by deleting and redeployed the Azure instance. Ok for dev not so good for prod.
Did you push to the right remote? It sounds like you have two remotes (you can check with git remote -v) and you are pushing the non-azure one.
Another thing might be the branch, are you on a branch that is not master, but azure expects the deploy to happen on the master branch?
From your comment: The deployment script might not have run. You can either create a dummy commit or force pushing by git push -f to make the remote repository receive the content again.
I just had the same issue, so I'll post my solution here in this old question in case it helps anyone.
I was posting to my GitHub repository but Azure suddenly wasn't picking it up for deployment any more.
I went into the repository on GitHub, then Settings -> Webhooks and Services, and noticed that the Azure webhook had a little red icon indicating a problem. Clicking on it showed that GitHub was getting a 401 Unauthorised response from Azure.
Then I remembered Azure had sent me an email about a week ago saying my website was going to be moved to a new scale unit and my publishing profile would change. I didn't think much of this at the time as I don't deploy with a publishing profile, but it looks like it also changed my deployment trigger URL.
I updated the GitHub Webhook with the new deployment URL (from the Configure tab of my Azure website) and it all works fine again.

Resources