You can create an IAM role and attach it to an instance during or after launch. You can also replace or detach IAM roles.
To attach an IAM role to an instance at launch using the Amazon EC2 console, expand Advanced details. For IAM instance profile, select the IAM role.
Note
If you created your IAM role using the IAM console, the instance profile was created for you and given the same name as the role. If you created your IAM role using the AWS CLI, API, or an AWS SDK, you might have given your instance profile a different name than the role.
You can attach an IAM role to an instance that is running or stopped. If the instance already has an IAM role attached, you must replace it with the new IAM role.
To attach an IAM role to an instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
In the navigation pane, choose Instances.
-
Select the instance.
-
Choose Actions, Security, Modify IAM role.
-
For IAM role, select the IAM instance profile.
-
Choose Update IAM role.
To replace the IAM role on an instance that already has an attached IAM role, the instance must be running. You can do this if you want to change the IAM role for an instance without detaching the existing one first. For example, you can do this to ensure that API actions performed by applications running on the instance are not interrupted.
To replace an IAM role for an instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
In the navigation pane, choose Instances.
-
Select the instance.
-
Choose Actions, Security, Modify IAM role.
-
For IAM role, select the IAM instance profile.
-
Choose Update IAM role.
You can detach an IAM role from an instance that is running or stopped.
To detach an IAM role from an instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
In the navigation pane, choose Instances.
-
Select the instance.
-
Choose Actions, Security, Modify IAM role.
-
For IAM role, choose No IAM Role.
-
Choose Update IAM role.
-
When promoted for confirmation, enter Detach, and then choose Detach.