- Newest
- Most votes
- Most comments
In AWS IAM Identity Center, when you create permission sets and assign them to accounts, IAM roles are automatically created in each target account. However, there is currently no direct API method to retrieve these role ARNs from the aws_ssoadmin_account_assignment resource.
The role names are generated using a specific pattern: AWSReservedSSO_[permission-set-name]_[unique-id] and are placed under the path /aws-reserved/sso.amazonaws.com/. The unique ID portion is not deterministically derivable from the permission set information alone, which is why you're currently using the regex approach to find these roles.
When IAM Identity Center creates these roles in target accounts, it uses role chaining behind the scenes, but the API doesn't expose a method to directly map from a permission set assignment to the resulting role ARN.
Your current approach of using a name regex pattern to find the roles is the recommended way to handle this situation. While not ideal from an automation perspective, it's the most reliable method available since the unique identifier in the role name is generated by IAM Identity Center and not exposed through the assignment APIs.
If you need to work with these roles programmatically across accounts, you would need to:
- Continue using the regex pattern matching in each account
- Or maintain a mapping of permission sets to their corresponding role ARNs in each account
This is a known limitation when working with IAM Identity Center permission sets and their corresponding IAM roles across accounts.
Sources
Delegate permission set administration - AWS IAM Identity Center
API for creating permission sets in Identity store | AWS re:Post
Export CloudWatch log data to Amazon S3 using the console | AWS re:Post
Relevant content
asked 2 years ago
