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개 답변
1
수락된 답변

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
전문가
답변함 2달 전
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
전문가
답변함 2달 전
  • 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
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠