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

JavaScript

Setting a more specific database type in Prisma

Prisma sets a default of TEXT for all String fields, here is how you can override that.

Ruby

Override database attribute types

Sometimes you don't have control over how your database handles information, so you need Rails to set it