Issue with Inline Policy

0

Hi AWS, I have created an AWS IAM inline policy. When I attached it to the IAM user it works fine whereas when I attached it to the IAM role under the attached entities it is showing 0 instead of 1. Attaching the screenshot below for your reference:

AWS Inline policy issue

Can someone from the IAM team confirm whether it is a console issue or something else.

3 Answers
1
Accepted Answer

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.

profile picture
EXPERT
answered a month ago
1

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 ;)

profile picture
EXPERT
answered a month 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 :-

    1. 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.

    2. 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.

    3. 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.

    4. 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.

0

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: Policies attached to IAM role

As per Gary, the Inline policies count can never be greater than 0 which satisfies the requirement.

profile picture
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions