- Newest
- Most votes
- Most comments
This Attached Entity count is not applicable to inline polices.
Only AWS or Customer Managed policies have a count >=1 when attached to a role. In line policies count will never be greater than 0.
If you're comfortable using the AWS CLI, you can use the attach-role-policy command to attach the inline policy to the IAM role programmatically. This can sometimes resolve issues related to the console interface.
aws iam put-role-policy --role-name <IAM_ROLE_NAME> --policy-name <POLICY_NAME> --policy-document <POLICY_DOCUMENT_JSON>
Replace <IAM_ROLE_NAME> with the name of your IAM role, <POLICY_NAME> with the name you want to give to your inline policy, and <POLICY_DOCUMENT_JSON> with the JSON document representing your inline policy.
aws iam put-role-policy --role-name MyRole --policy-name MyInlinePolicy --policy-document file://path/to/policy.json
In this example:
MyRole is the name of the IAM role to which you want to attach the inline policy. MyInlinePolicy is the name you want to give to the inline policy. file://path/to/policy.json is the file path to the JSON document containing your inline policy. Make sure to replace the placeholders with your actual values and provide the correct file path to your policy document.
After running this command, verify in the AWS Management Console that the inline policy is properly attached to the IAM role.
Hope it clarifies and if does I would appreciate answer to be accepted so that community can benefit for clarity, thanks ;)
Hi Gary Mclean and Adeleke Adebowale J, I have created a new IAM role and then attached a customer managed policy. Post that I have attached an Inline policy lambda-access-policy
to the role but the Attached entities count was showing 0. Then I have created one more inline policy MyInlinePolicy
and attached it to the same role again using the AWS CLI command
aws iam put-role-policy --role-name iam-role --policy-name MyInlinePolicy --policy-document file://policy.json
, and it shows the count as 0 for the Attached entities.
Below is the screenshot attached:
As per Gary, the Inline policies count can never be greater than 0 which satisfies the requirement.
Relevant content
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
I will do that as that's the only way to troubleshoot but this is happening with every role where I am attaching the inline policy to the role.
These are few checks you could also do :-
Double-check that the inline policy is properly attached to the IAM role. Sometimes, a simple refresh of the console page can resolve display issues. Ensure that you are viewing the correct IAM role and that the inline policy is listed under the "Attached Entities" section.
Ensure that the inline policy has the correct JSON syntax. Even a small syntax error can prevent the policy from being attached properly. Use the IAM Policy Simulator or a JSON validator tool to check the syntax of your policy.
Review the permissions in the inline policy to ensure that they are correct and sufficient for the IAM role's requirements. Make sure that the policy grants the necessary permissions for the IAM role to perform its intended actions.
AWS service or another IAM user) to assume the role. If the trust relationship is not properly configured, the IAM role may not be able to use the permissions from the inline policy.