Using a Cognito custom attribute as a principal tag in an IAM policy condition is not working

1

Here's the setup:

  • User Pool custom attribute: custom:journalSubscription
  • User Pool app client: has read/write permission for the custom attribute
  • Example user: has custom attribute custom:journalSubscription set to true
  • Identity Pool ABAC custom mapping: "Attribute name" of custom:journalSubscription ---maps to---> "Tag key for principal" of journalSubscription
  • IAM policy: uses a condition for "StringEquals" where "aws:PrincipalTag/journalSubscription" must equal "true"

Problem: the SDK call fails with this error:

User: <<AUTH_ROLE>> is not authorized to perform: dynamodb:GetItem on resource: <<ARN_FOR_MY_DynamoDB_TABLE>> because no identity-based policy allows the dynamodb:GetItem action

Note: the SDK call works fine with an IAM policy that uses a condition for a non-custom attribute such as "aws:PrincipalTag/email". It's just that for custom attributes, the call fails.

How can I make this work?

2개 답변
2
수락된 답변

In the app client settings, for the OpenID Connect scopes, add profile. This allows the app client to retrieve "profile" attributes which seems to include custom attributes.

profile picture
답변함 2년 전
profile pictureAWS
전문가
Chris_G
검토됨 2년 전
0

seems to be

답변함 일 년 전

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

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

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

관련 콘텐츠