Tips and Best Practices to Set Up Granular Access Control in AWS
Granular access control in AWS allows you to grant users and groups the least privilege necessary to perform their jobs. This helps to protect your AWS resources from unauthorized access.
Here are some tips and best practices for setting up granular access control in AWS:
You could create an IAM role for developers that grants them permission to read application logs and investigate CI/CD workflows.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:FilterLogEvents",
"logs:GetLogEvents",
"logs:GetLogRecord",
"logs:GetLogGroupFields",
"logs:GetQueryResults",
"logs:StartQuery"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"codepipeline:GetPipeline",
"codepipeline:GetPipelineState",
"codepipeline:GetPipelineExecution",
"codepipeline:GetPipelineState",
"codepipeline:GetPipelineExecution"
],
"Resource": "*"
}
]
}
You can then create an IAM role for operations engineers that grants them permission to create and manage EC2 instances:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:TerminateInstances",
"ec2:RebootInstances",
"ec2:GetConsoleOutput",
"ec2:CreateTags",
"ec2:ModifyInstanceAttribute",
"ec2:DescribeInstanceStatus",
"ec2:DescribeTags"
],
"Resource": "arn:aws:ec2:region:account-id:instance/*"
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeRegions",
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeKeyPairs",
"ec2:DescribeImages"
],
"Resource": "*"
}
]
}
You could use an IAM condition to restrict access to a specific S3 bucket to users in a specific AWS region.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::examplebucket/*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": "us-west-2"
}
}
}
]
}
EC2 instances can be tagged with the project they are associated with. You could then create an IAM policy that grants developers permission to create and deploy EC2 instances that are tagged with the project they are working on.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Project": "${aws:PrincipalTag/Project}"
}
}
}
}
In a multi-account AWS environment, AWS Organizations simplifies central management. By employing Service Control Policies (SCPs) at the account level, you can implement high-level restrictions.
For instance, in a production account, you may use SCPs to prevent IAM user creation and limit allowable regions. This enhances security and compliance by reducing the risk of accidental resource deployment and minimizing the attack surface.
Here's an example of SCP that prevents IAM user creation and limits allowable regions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "iam:CreateUser",
"Resource": "*"
},
{
"Effect": "Deny",
"Action": "ec2:RunInstances",
"Resource": "*",
"Condition": {
"NotStringEquals": {
"aws:RequestedRegion": [
"us-east-1",
"us-west-2"
]
}
}
}
]
}
Additional Tips
By following these tips and best practices, you can set up granular access control in AWS to help protect your resources from unauthorized access.
2x AWS Certified | Terraform Certified | Cloud Infrastructure Officer
1 年This is a must read for all the new Sysops admins out there... Following these tips will really help to setup a very secure infrastructure with granular access controls... Really excited to see what insightful articles come next ??????