Kanji
・Cloud Engineer / Freelance ・Geboren 1993 ・Aus Ehime / Wohnhaft in Shibuya, Tokio ・5 Jahre AWS-Erfahrung Profildetails
Inhaltsverzeichnis
One of the main challenges in designing IAM permissions is determining how strictly to apply the principle of least privilege.
As a best practice, it is recommended to grant IAM users and IAM roles only the minimum permissions necessary.
However, restricting permissions for IAM users and roles may increase the operational burden on system administrators.
Therefore, it is important to assess the business risks associated with the granted IAM permissions in advance and grant permissions within an acceptable risk range.
In addition to IAM permission controls, using AWS Organizations’ SCP (Service Control Policy) can help reduce the burden of IAM permission design.
Properly segmenting AWS accounts is also important. By dividing AWS accounts, even if IAM permissions are inappropriately granted, the impact can be limited.
There are three types of policies you can use to grant IAM permissions:
Inline policies
AWS managed policies
Customer managed policies
Of these, “AWS managed policies” are provided by AWS and are offered after AWS has properly evaluated the permissions. By using these policies, you can grant write and read permissions for each AWS service.
Basically, it is recommended to use AWS managed policies. However, since AWS managed policies may grant excessive permissions, consider using “customer managed policies” or “inline policies” to further restrict permissions as needed.
For example, in the following patterns, consider using “customer managed policies” or “inline policies” to restrict permissions.
To grant management permissions for KMS keys using AWS managed policies, you can use the AWS managed policy “AWSKeyManagementServicePowerUser.”
Reference: AWSKeyManagementServicePowerUser - AWS Managed Policy
However, using this policy grants powerful permissions for KMS keys, such as creating or deleting keys and changing IAM policies.
Therefore, consider using IAM policies to grant permissions only for specific KMS keys.
For example, the following IAM policy grants permission to decrypt data encrypted with KMS keys that have a specific tag:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kms:Decrypt", "kms:GenerateDataKey" ], "Resource": "*", "Condition": { "StringEquals": { "aws:ResourceTag/System": "SystemA" } } } ] }
When granting execution permissions for AWS resources such as Lambda or Step Functions, you are granting the permissions that are exercised when those resources are executed.
If executing these resources poses a business risk, consider restricting execution permissions using IAM policies.
For example, by using the following IAM policy, you can grant permission to execute Lambda functions that follow a specific naming convention.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "lambda:InvokeFunction" ], "Resource": [ "arn:aws:lambda:ap-northeast-1:123456789012:function:SystemA-*" ] } ] }
When you need to assume an IAM role in an external account, you can grant the AssumeRole permission using an IAM policy.
This cannot be granted using AWS managed policies, so you must use a custom IAM policy to grant the permission.
For example, the following IAM policy grants permission to assume specific IAM roles.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sts:AssumeRole" ], "Resource": [ "arn:aws:iam::123456789012:role/SystemA-*" ] } ] }
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::systema-bucket", "arn:aws:s3:::systema-bucket/*" ] } ] }