Amazon EC2 logo
Amazon EC2 logo

The other day I stumbled upon a string of similar events logged from some of my Windows EC2 instances in regards to the SSM Agent. It simply refused to start up, and examining the log files, I could see the following:

2022-09-23 08:09:39 ERROR Agent failed to assume any identity
2022-09-23 08:09:39 ERROR failed to find identity, retrying: failed to find agent identity

After a little digging, the likely culprit was a corrupt EC2Launch installation and missing routes for it to communicate with the AWS backbone. Fixing this was quite easy once I knew what the issue was.

First we need to update EC2Launch

mkdir $env:USERPROFILE\Desktop\EC2Launch
$Url = "https://s3.amazonaws.com/ec2-downloads-windows/EC2Launch/latest/EC2-Windows-Launch.zip"
$DownloadZipFile = "$env:USERPROFILE\Desktop\EC2Launch\" + $(Split-Path -Path $Url -Leaf)
Invoke-WebRequest -Uri $Url -OutFile $DownloadZipFile
$Url = "https://s3.amazonaws.com/ec2-downloads-windows/EC2Launch/latest/install.ps1"
$DownloadZipFile = "$env:USERPROFILE\Desktop\EC2Launch\" + $(Split-Path -Path $Url -Leaf)
Invoke-WebRequest -Uri $Url -OutFile $DownloadZipFile
& $env:USERPROFILE\Desktop\EC2Launch\install.ps1

Then once EC2Launch has been updated, we need to add the default routes required.

Import-Module "C:\ProgramData\Amazon\EC2-Windows\Launch\Module\Ec2Launch.psd1"
Add-Routes

Now go back to services.msc and perform a stop and start of the SSM Agent. It should now be able to start up again without any issues.

By Jostein Elvaker Haande

"A free society is a society where it is safe to be unpopular" - Adlai Stevenson

One thought on “[HOWTO] EC2Launch – agent failed to assume identity”
  1. THANK YOU!!! I’m on Linux, but your article helped me fix my issue by uninstalling and reinstalling the SSM agent.

    For anyone else who winds up here in a similar situation:

    sudo yum remove amazon-ssm-agent
    sudo yum install amazon-ssm-agent
    sudo reboot

Leave a Reply

Your email address will not be published. Required fields are marked *