Restart the CodeDeploy agent after changing IAM profiles

The CodeDeploy Agent needs to restart to see new IAM profiles

I’ve been trying to understand AWS’ CodeDeploy better and migrate a project from Heroku onto AWS. When setting up the EC2 instance I wanted to deploy to, I had forgotten to attach an IAM profile.

An IAM profile is used to pass an IAM role to an EC2 instance, which is a weird way of saying “letting the EC2 instance know what it can and cannot do”.

The deploy was failing, and the logs were suggesting it was because I didn’t have a profile;

  InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Missing credentials - please check if this instance was started with an IAM instance profile

I added a profile via the AWS console and restarted the EC2 instance.

My next deploy failed for the same reason, which I couldn’t quite understand.

Turns out, you have to restart the CodeDeploy agent for it see the changed profile.

Using SSH, connect to the EC2 instance and run sudo service codedeploy-agent restart, letting it see the new profile.


Recent posts View all

Ruby

Forcing a Rails database column to be not null

How you can force a table column to always have something in it with Rails

Writing Marketing

We've deleted an article's worth of unhelpful words

We've improved several pages across our site by removing words that add no value, and often detract from the article.