Had the same error message despite having the right IAM role attached to the instance (AmazonSSMManagedInstanceCore).
Stoping the instance and rebooting solve the issue for me.