首页 > 解决方案 > CloudFormation AWS::Cognito::IdentityPoolRoleAttachment RoleMappings 语法错误

问题描述

在我的 AWS CloudFormation 堆栈中,我想将角色附加到 Cognito 身份池(有效),对于身份验证提供程序 > Cognito > 已验证角色选择,使用 CloudFormation 语法选择“从令牌中选择角色”(无效),如下:

    wzjCognitoIdentityPoolRoles:
      Type: AWS::Cognito::IdentityPoolRoleAttachment
      Properties:
        IdentityPoolId:
          Ref: wzjCognitoIdentityPool
        Roles:
          authenticated:
            Fn::GetAtt: [cognitoAuthRoleWithIdentity, Arn]
          unauthenticated:
            Fn::GetAtt: [cognitoAuthRoleNoIdentity, Arn]
        RoleMappings:
          Type: Token
          AmbiguousRoleResolution: AuthenticatedRole

部署时,出现以下错误:

An error occurred: wzjCognitoIdentityPoolRoles - Property validation failure: [Value of property {/RoleMappings/Type} does not match type {Object}, Value of property {/RoleMappings/AmbiguousRoleResolution} does not match type {Object}].

但据我了解AWS CloudFormation 文档,我认为我使用了正确的语法。

我该如何解决?

谢谢你的帮助。

标签: amazon-web-servicesamazon-cloudformationamazon-cognito

解决方案


我认为你应该关注AWS::Cognito::IdentityPoolRoleAttachment但不是的语法RoleMappings

AWS::Cognito::IdentityPoolRoleAttachment,我们可以进入RoleMappings

这是 RoleMapping 对象映射的字符串

所以我觉得你可以试试:

RoleMappings:
  'graph.facebook.com':
      Type: Token
      AmbiguousRoleResolution: AuthenticatedRole

这里'graph.facebook.com'只是一个例子。


推荐阅读