AWS – Attach/Replace IAM role of running instance

From the above articles from AWS we can now attach/replace IAM role of running instances.

The below example is simple scenario to test the same using CF..

  • Provision EC2 Instance, Create S3 bucket, Create S3 Bucket Policy, Role and Instance Profile. But I am not attaching the instance profile to the EC2 Instance provisioned.

CF Template –

Lets provide the stack with CF template..


Successfully created stack..


Uploaded a document into the created S3 bucket..


Now lets take a look at EC2 Instance provisioned.. No IAM Role assigned to it.


Try accessing the document that we uploaded to S3 Bucket..


Updated the CF Template –

Attached the Instance Profile created to the EC2 Instance..


Update CF completed successfully..


We can see IAM role now attached to the instance..


We will try the same commands to access the document uploaded to S3 bucket..



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s