This error occurs when you try to disassociate and associate back an instance profile (IAM role attached to the instance) to your EC2 instance in quick succession. The error can be resolved using AWS CLI as shown in the below example –
1 2 3 4 5 6 7 8 9 10 11 12 |
## Get the current instance profile association status for your EC2 instance aws ec2 describe-iam-instance-profile-associations \ --filters "Name=instance-id,Values= ## Note down the AssociationId from the output ## if you have multiple AssociationId, run the below command multiple times for each AssociationId. ## Disassociate instance profile from your EC2 instance aws ec2 disassociate-iam-instance-profile \ --association-id ## Now try to associate back the desired instance profile to your EC2 instance. |