We are now going to attach the IAM Role created on the previous step in one of our EC2 Instances, to do that let’s go to the Amazon EC2 Dashboard.
On the left bar, click on Instances.
Click on Launch Instance and select Linux 2 AMI (HVM) and t2.micro (free tier eligible) on the following screens. Click Review and launch:
Select Proceed without a key pair
Complete this step by launching this testing t2.micro EC2 instance. In order to install the CloudWatch agent We will need to access this instance using the browser-based SSH native AWS connection tool so make sure that the port 22 is not blocked in the Security Group attached to this instance.
After the instance is launched and runnning, select the instance you want to start collecting Memory data by going to Actions on the top bar, select Instance Settings»Attach/Replace IAM Role.
Look for the created IAM role CloudWatchAgentServerRole under the IAM role box, select it and apply.
Confirm that the CloudWatchAgentServerRole was sucessfully attached to your EC2 instance
Validade if the IAM role CloudWatchAgentServerRole is attached to the desired instance