An error occurred PolicyLengthExceededException when calling the AddPermission operation The final policy size 20861 is bigger than the limit 20480
The error message indicates that the policy you are trying to add exceeds the maximum allowed size. AWS Identity and Access Management (IAM) has a limit of 20,480 bytes for the size of a policy.
Policies in IAM are sets of permissions that define what actions are allowed or denied on AWS resources. These policies can be attached to IAM users, groups, roles, or resources.
To resolve this error, you need to reduce the size of the policy you are trying to add. Here are a few suggestions:
-
Remove unnecessary or unused permissions from the policy: Review the policy and remove any permissions that are not required for the intended functionality. This will help reduce the overall size of the policy.
-
Use policy variables: If you have repetitive or similar permissions, you can use policy variables to reduce the size of the policy. Policy variables allow you to define common sets of permissions and reuse them throughout your policies.
-
Split the policy into multiple policies: If the policy is still too large after removing unnecessary permissions and using variables, consider splitting it into multiple smaller policies. You can then attach these smaller policies individually to the relevant IAM entities.
-
Use IAM roles: Instead of directly attaching policies to IAM users or groups, consider using IAM roles. Roles allow you to define a set of permissions and then assign them to different users or services as needed. This can help reduce the size of individual policies since you can reuse the same role across multiple entities.
By following these suggestions, you should be able to reduce the size of your policy and successfully add it without exceeding the size limit
原文地址: http://www.cveoy.top/t/topic/hMp5 著作权归作者所有。请勿转载和采集!