Bobcares

wesupport

CLIENT AREACall Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193

Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Assign an Existing IAM Role to an EC2 Instance – AWS

by | Jul 16, 2021

Wondering how to assign an existing IAM Role to an EC2 Instance? We can help you.

Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.

Today, let us see how to assign IAM Role to an EC2 Instance.

 

Assign an Existing IAM Role to an EC2 Instance

In order to assign, our Support Techs recommend ensuring the following:

  • We need to wait for AWS Systems Manager Agent to detect the new IAM role or restart SSM Agent if we use AWS Systems Manager.
  • If the AWS CLI commands result in errors, check if we have the most recent version of the AWS CLI.

To attach an IAM role to an instance that has no role, the instance can be running or not.

Moving ahead, let us see how to attach an IAM role to an instance in the new & old console.

New console:

  1. Initially, we open the Amazon EC2 console.
  2. In the navigation pane, we select Instances.
  3. Then we select the instance > Actions > Security > Modify IAM role.
  4. After that, we select the IAM role to attach to the instance
  5. Eventually, we hit the Save button.

Old console:

  1. First, we open the Amazon EC2 console.
  2. Then we go to Instance in the navigation pane.
  3. We select the instance > Actions > Instance Settings > Attach/Replace IAM role.
  4. Finally, we select the IAM role to attach to the instance and choose Apply.

Attach an IAM role to an instance (AWS CLI):

If necessary, we describe the instances to get the ID of the instance to which we attach the role.

aws ec2 describe-instances

We need to attach the IAM role to the instance by specifying the instance profile.

To do so, we use the associate-iam-instance-profile command.

aws ec2 associate-iam-instance-profile \
--instance-id i-1234567890abcdef0 \ --iam-instance-profile Name="TestRole-1"

{
"IamInstanceProfileAssociation": {
"InstanceId": "i-1234567890abcdef0", 
"State": "associating", 
"AssociationId": "iip-assoc-0dbd8529a48294120", 
"IamInstanceProfile": {
"Id": "AIPAJLNLDX3AMYZNWYYAY", 
"Arn": "arn:aws:iam::123456789012:instance-profile/TestRole-1"
}
}
}

[Need help with the procedures? We’d be happy to assist you]

 

Conclusion

In short, we saw how our Support Techs go ahead to assign IAM Role to an EC2 Instance.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Reviews

Categories

Tags