How to attach instance profile on EC2 with cli

This is a quick note to remind me on how to attach or associate an instance profile (IAM role) to an EC2 instance using AWS CLI. In this example, I already have a running EC2 instance i-0357ecc1111111111 running. I want to attach a new instance profile called SSMInstanceProfile to this instance. But as we all know, only one instance profile can be associated with an EC2 instance at one time. So, let’s check to see if our instance already has one attached:...

March 5, 2024 · 2 min · 391 words · kenno