While setting up my Organization in AWS I stumbled upon a problem. We plan to use AWS Organizations to separate different departments (Dev, Operations, IT, Projects) into different AWS Accounts and AWS SSO to Manage Cross-account access. In some departments (Dev, Projects)
I want some users to be able to create own IAM Users (Called "Function Users") for use for programmatic access. These Function Users should have no right to create users themselves nor set update any access keys. Additionally these Users (or their Access keys) should be valid only for a limited time. The idea is that if a employee leaves the company the created function user stays valid only for a limited time (If not found while deactivating the employee user).
I plan to implement the time limit by calling a lambda-Function once a day to deactivate access keys of all function users that are older than a given time.
My problem is setting the Limit on the rights of the created users. I created a SSO Permissions set (Which is mapped to a Role in each account) that has the AWS managed policy "IAMReadOnlyAccess" attached. Additionally it has the following inline policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CreateUsersWithTag",
"Effect": "Allow",
"Action": [
"iam:CreateUser",
"iam:DeleteUserPolicy",
"iam:AttachUserPolicy",
"iam:DetachUserPolicy",
"iam:PutUserPermissionsBoundary"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestTag/Owner": "${aws:username}",
"iam:PermissionsBoundary": "arn:aws:iam::12356789012:policy/FunctionUserBoundary"
}
}
}
]
}
With this Policy I try to force all created users to have a Tag with the creating user (to identify function users and allow that user to update access keys). I also try to force a IAM Policy to that newly created user which deny
s any IAM access for the function user.
My Problem is the ARN of that policy. It resides in the master Account of the organization. Therefor a user can not reference it in a sub-account when creating a user.
Is there a way to allow sub-accounts access to IAM Policys of another account? Another Option would be to write a Lambda function that is triggered on account creation that creates the FunctionUserBoundary policy in each new account and change the iam:PermissionsBoundary
value to arn:aws:iam::*:policy/FunctionUserBoundary
but when I change the policy later I will end up with different policy Versions in different accounts.
Is there a way to implement my plan or is my plan fundamentally wrong?