<p>The data structures involved with EC2 and IAM are almost as old as EC2 itself. I don't know the definitive answer because I didn't work at AWS when these were built, but it was most probably a kludge and maybe future-proofing.</p>
<p>Many of the newer services that are built today, for example Lambda, don't need this kludge anymore and can link IAM Roles directly to the Lambda function.</p>
<p>Since for the most part, AWS try and keep existing APIs and not break them. This EC2 IAM Profile thing is unlikely to change.</p>

CC BY-SA 4.0
2023-06-25T09:34:29.597Z
2023-06-25T09:55:01.167Z
2023-06-25T09:55:01.167Z
Evgeny Zislis
<p>In AWS EC2, a machine is assigned privileges using instance profiles. Specifically:</p>
<ul>
<li>the desired permissions are articulated as an IAM policy,</li>
<li>that policy is attached to an IAM role,</li>
<li>that role is assigned to an Instance Profile,</li>
<li>the Instance Profile is assigned to the new EC2 instance (often first via a Launch Template where it is accompanied with other configuration settings),</li>
<li>then processes running on the instance can (using AWS SDKs) obtain credentials for the role, and use those to authorise the actions (via requests to AWS API service endpoints) permitted by the policy.</li>
</ul>
<p>What is the purpose of the Instance Profile layer? For example, is it solely just a wrapper for a role? In other words, what is the intent behind exposing this indirection layer to the client? Particularly, why isn't the role assigned directly to the instance (in the Launch Template or the RunInstance API)?</p>

<amazon-web-services><amazon-ec2><aws-iam>
Why does AWS wrap roles with instance profiles?
benjimin
# Why does AWS wrap roles with instance profiles?

(Asked by: username_0 on 2023-06-25)

In AWS EC2, a machine is assigned privileges using instance profiles. Specifically:

* the desired permissions are articulated as an IAM policy,
* that policy is attached to an IAM role,
* that role is assigned to an Instance Profile,
* the Instance Profile is assigned to the new EC2 instance (often first via a Launch Template where it is accompanied with other configuration settings),
* then processes running on the instance can (using AWS SDKs) obtain credentials for the role, and use those to authorise the actions (via requests to AWS API service endpoints) permitted by the policy.

What is the purpose of the Instance Profile layer? For example, is it solely just a wrapper for a role? In other words, what is the intent behind exposing this indirection layer to the client? Particularly, why isn't the role assigned directly to the instance (in the Launch Template or the RunInstance API)?

**Tags:** amazon-web-services, amazon-ec2, aws-iam


---

## 1 answers

### Answer by username_1 on 2023-06-25. Score: 1 | Accepted answer

The data structures involved with EC2 and IAM are almost as old as EC2 itself. I don't know the definitive answer because I didn't work at AWS when these were built, but it was most probably a kludge and maybe future-proofing.

Many of the newer services that are built today, for example Lambda, don't need this kludge anymore and can link IAM Roles directly to the Lambda function.

Since for the most part, AWS try and keep existing APIs and not break them. This EC2 IAM Profile thing is unlikely to change.


---

