The primary use case of an IAM Role is to grant access/permissions to your AWS resources. You can also access your AWS Resources through the AWS API, which uses IAM User credentials for authentication.
As a rule of thumb, you can directly attach an IAM Role to your EC2 Instances.
For on-premises servers, you cannot directly attach an IAM Role but you can associate an IAM Role to the CodeDeploy agent that’s installed on your on-premises servers or through the <b style=”font-family: inherit; font-size: inherit;”>register-on-premises-instance command.
https://docs.aws.amazon.com/codedeploy/latest/userguide/register-on-premises-instance-iam-session-arn.html
So going back to your original question –– yes, you can definitely associate an IAM Role to your on-premises servers
Cheers,
Jon Bonso