- Newest
- Most votes
- Most comments
Hi There, You can implement the principle of least privilege for cross-account access.
In your AWS Organization's management account, you can create a IAM role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::MEMBER-ACCOUNT-ID-1:root",
"arn:aws:iam::MEMBER-ACCOUNT-ID-2:root"
]
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"aws:PrincipalOrgID": "YOUR-ORGANIZATION-ID"
}
}
}
]
}
Then you can create a custom policy for the specific task (example for accessing a specific Secret):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": "arn:aws:secretsmanager:REGION:ACCOUNT-ID:secret:SPECIFIC-SECRET-NAME"
}
]
}
And in the member accounts, create an IAM policy to allow specific users/roles to assume the organization account role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::ORGANIZATION-ACCOUNT-ID:role/ROLE-NAME"
}
]
}
Then your users can then assume the role using AWS CLI:
aws sts assume-role --role-arn arn:aws:iam::ORGANIZATION-ACCOUNT-ID:role/ROLE-NAME --role-session-name MySession
This way only member accounts within your organization can assume the role and you can sope the role, so it only has permissions for the specific task needed. The users can't view/modify the actual credentials All the role assumptions are logged in CloudTrail
Additional Best Practices: Use session duration limits in the role trust policy
Regularly review CloudTrail logs for role usage
Use AWS Organizations SCPs for additional restrictions
HTH
Relevant content
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago