attach iam role to ec2 profile code example
Example 1: attach iam role to ec2 instance cli
$aws ec2 associate-iam-instance-profile --instance-id YourInstanceId --iam-instance-profile Name=YourNewRole-Instance-Profile
Example 2: aws cli ec2 how to change IAM role
$aws ec2 replace-iam-instance-profile-association --association-id YourCurrentAssociation-id --iam-instance-profile Name=YourReplacementRole-Instance-Profile