0 votes
1 view
in AWS by (19.2k points)

In order to run AWS monitoring scripts (http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/mon-scripts-perl.html) on one of my ec2 existing instances, I need an IAM role associated with the instance.

I found a lot of documentation to launch an instance with a role... But nothing to link a role to an existing instance.

Is it possible?

If not, what can I do? Launch a new instance with a role and transfer the volumes to it?

1 Answer

0 votes
by (44.6k points)

Use this:

aws ec2 associate-iam-instance-profile --instance-id YourInstanceId --iam-instance-profile Name=YourNewRole-Instance-Profile

Where associate-iam-instance-profile can use to associate an IAM instance profile with running and stopped instance.

Official Documentation 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !