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

Web Dev

What does --no-owner mean in Postgres?

You have read a guide to doing Postgres exports or imports and seen --no-owner, this is what it means

Web Dev

What does --no-acl mean in Postgres?

You have read a guide to doing Postgres exports or imports and seen --no-acl, this is what it means