Skip to content

Commit 371ea4f

Browse files
authored
Merge pull request #462 from Hacking-the-Cloud/update_iam_role_recreation_article
Update why_recreating_an_iam_role_doesnt_restore_trust_a_gotcha_in_ro…
2 parents 9e2b180 + 40c6a12 commit 371ea4f

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

content/aws/general-knowledge/why_recreating_an_iam_role_doesnt_restore_trust_a_gotcha_in_role_arns.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ description: "In AWS, deleting and recreating an IAM role results in a new ident
88

99
This subtle behavior can disrupt cross-account access, third-party integrations, and automation workflows.
1010

11+
!!! info
12+
While this article is primarily focused on IAM roles and avoiding making this mistake in a SaaS context, it is important to know that the same idea applies to IAM users as well. In addition, IAM principals can be referenced in resource-based policies of a variety of resources, not just role trust policies.
13+
1114
## The Scenario
1215

1316
Imagine you have a trust policy attached to a role named `Bobby` and that this trust policy permits the role named `Megan` to assume it as shown below.
@@ -82,14 +85,38 @@ By locking trust relationships to unique principal IDs, AWS ensures that trust m
8285

8386
While tying trust relationships to immutable principal IDs is a sound security decision, this behavior can introduce operational risk, especially in SaaS integrations.
8487

85-
Many SaaS platforms, especially in the security, observability, or data pipeline space, allow customers to establish integrations by trusting a specific IAM role via an ARN. The SaaS provider configures their side to call sts:AssumeRole on a role in a customer’s AWS account and uses that role to perform whatever their service needs to do.
88+
Many SaaS platforms, especially in the security, observability, or data pipeline space, allow customers to establish integrations by trusting a specific IAM role via an ARN. The SaaS provider configures their side to call `sts:AssumeRole` on a role in a customer’s AWS account and uses that role to perform whatever their service needs to do.
8689

8790
Say that SaaS provider makes a mistake and deletes the trusted IAM Role and recreates it (intentionally or not), that new IAM role will have a different principal ID. While the ARN may be the same, from AWS' perspective that is not the same IAM role. The result?
8891

8992
The SaaS provider will not be able to assume any of their customer roles.
9093

9194
To make matters worse, the only solution in this situation is for every single customer to modify the trust policy of their SaaS roles in every single AWS account to trust the new IAM role in the SaaS account. This can introduce downtime, addition support requests, and other issues.
9295

96+
## How to Avoid This
97+
98+
The simplest method for avoiding this operational risk is to have your SaaS customer trust an entire AWS account, and not a specific IAM role. Below is an example of such a trust policy.
99+
100+
```json
101+
{
102+
"Version": "2012-10-17",
103+
"Statement": [
104+
{
105+
"Effect": "Allow",
106+
"Principal": {
107+
"AWS": "arn:aws:iam::111111111111:root"
108+
},
109+
"Action": "sts:AssumeRole"
110+
}
111+
]
112+
}
113+
```
114+
115+
This trust policy will permit any AWS principal in the account `111111111111` to assume the role in the customer account.
116+
117+
!!! warning
118+
It is important that you restrict who has access to the trusted account and limit what principals have `sts:AssumeRole` privileges.
119+
93120
## Conclusion
94121

95122
IAM roles may look simple on the surface, but the way AWS handles trust relationships is complex: identity resources are more than their name. When you delete and recreate a role, even with the same ARN, AWS treats it as a completely different entity. That distinction can lead to subtle, hard-to-debug failures, especially in SaaS integrations.

0 commit comments

Comments
 (0)