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

SEO

Google follows URLs in text

Today I learned that Google follows URLs even when they are plain text

Web Dev

Check in with your database

It pays to take a step back and look at how your database is set up every so often. You will often find quick wins and hidden tech debt.