Articles → AWS → Permission Boundary In AWS
Permission Boundary In AWS
Scenario
Click to Enlarge
Steps
- Create a user IAMOnlyUser with IAMFullAccess permission
- Create a user AdminAccess with AdministratorAccess permission by login using the credentials of IAMOnlyUser user
- Launch an EC2 instance using the AdminAccess user
- Create a new policy.
- Apply permission boundary to IAMOnlyUser user
- Delete the AdminAccess user and create a user with AdministratorAccess permission
- Launch an EC2 instance with AdminAccess user
Create A User “Iamonlyuser” With “Iamfullaccess” Permission
Click to Enlarge
Create A User “Adminaccess” With “Administratoraccess” Permission By Login Using The Credentials Of “Iamonlyuser” User
Click to Enlarge
Launch An EC2 Instance Using The “Adminaccess” User
Click to Enlarge
Create A New Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "IAMAccess",
"Effect": "Allow",
"Action": "iam:*",
"Resource": "*"
},
{
"Sid": "DenyPermBoundaryIAMPolicyAlteration",
"Effect": "Deny",
"Action": [
"iam:DeletePolicy",
"iam:DeletePolicyVersion",
"iam:CreatePolicyVersion",
"iam:SetDefaultPolicyVersion"
],
"Resource": [
"arn:aws:iam::YourAccount_ID:policy/PermissionsBoundary"
]
},
{
"Sid": "DenyRemovalOfPermBoundaryFromAnyUserOrRole",
"Effect": "Deny",
"Action": [
"iam:DeleteUserPermissionsBoundary",
"iam:DeleteRolePermissionsBoundary"
],
"Resource": [
"arn:aws:iam::YourAccount_ID:user/*",
"arn:aws:iam::YourAccount_ID:role/*"
],
"Condition": {
"StringEquals": {
"iam:PermissionsBoundary": "arn:aws:iam::YourAccount_ID:policy/PermissionsBoundary"
}
}
},
{
"Sid": "DenyAccessIfRequiredPermBoundaryIsNotBeingApplied",
"Effect": "Deny",
"Action": [
"iam:PutUserPermissionsBoundary",
"iam:PutRolePermissionsBoundary"
],
"Resource": [
"arn:aws:iam::YourAccount_ID:user/*",
"arn:aws:iam::YourAccount_ID:role/*"
],
"Condition": {
"StringNotEquals": {
"iam:PermissionsBoundary": "arn:aws:iam::YourAccount_ID:policy/PermissionsBoundary"
}
}
},
{
"Sid": "DenyUserAndRoleCreationWithOutPermBoundary",
"Effect": "Deny",
"Action": [
"iam:CreateUser",
"iam:CreateRole"
],
"Resource": [
"arn:aws:iam::YourAccount_ID:user/*",
"arn:aws:iam::YourAccount_ID:role/*"
],
"Condition": {
"StringNotEquals": {
"iam:PermissionsBoundary": "arn:aws:iam::YourAccount_ID:policy/PermissionsBoundary"
}
}
}
]
}
Click to Enlarge
Apply Permission Boundary To “Iamonlyuser” User
Click to Enlarge
Click to Enlarge
Click to Enlarge
Delete The “Adminaccess” User And Create A User With “Administratoraccess” Permission
Click to Enlarge
Click to Enlarge
Launch An EC2 Instance With “Adminaccess” User
Click to Enlarge