You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/aws/general-knowledge/why_recreating_an_iam_role_doesnt_restore_trust_a_gotcha_in_role_arns.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,9 @@ description: "In AWS, deleting and recreating an IAM role results in a new ident
8
8
9
9
This subtle behavior can disrupt cross-account access, third-party integrations, and automation workflows.
10
10
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
+
11
14
## The Scenario
12
15
13
16
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
82
85
83
86
While tying trust relationships to immutable principal IDs is a sound security decision, this behavior can introduce operational risk, especially in SaaS integrations.
84
87
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.
86
89
87
90
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?
88
91
89
92
The SaaS provider will not be able to assume any of their customer roles.
90
93
91
94
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.
92
95
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
+
93
120
## Conclusion
94
121
95
122
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