【问题标题】:CloudFormation AWS::Cognito::IdentityPoolRoleAttachment RoleMappings syntax errorCloudFormation AWS::Cognito::IdentityPoolRoleAttachment RoleMappings 语法错误
【发布时间】:2019-12-30 00:29:25
【问题描述】:

在我的 AWS CloudFormation 堆栈中,我想将角色附加到 Cognito 身份池(有效),对于身份验证提供程序 > Cognito > Authenticated 角色选择,使用 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 documentation,我认为我使用了正确的语法。

我该如何解决这个问题?

感谢您的帮助。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-cognito


    【解决方案1】:

    我认为您应该关注AWS::Cognito::IdentityPoolRoleAttachment 的语法,而不是RoleMappings

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

    这是 RoleMapping 对象映射的字符串

    所以我觉得你可以试试:

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

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

    【讨论】:

    • 谢谢,我只是注意到了。就我而言,Cognito 是身份验证提供程序,因此根据文档,我需要使用该语法:cognito-idp-east-1.amazonaws.com/us-east-1_abcdefghi:app_client_id。但我不知道如何使用 CloudFormation 语法创建该字符串...
    • 也许您可以尝试将'graph.facebook.com' 替换为'cognito-idp-east-1.amazonaws.com/us-east-1_abcdefghi:app_client_id'AWS::Cognito::IdentityPoolRoleAttachment 提到了你的情况。
    • 是的,这就是我所说的,但我不知道如何使用 CloudFormation 或无服务器框架语法动态构建它,因为它是键而不是值。这让事情变得更加复杂......
    【解决方案2】:

    你可以这样生成:

    !Join [ "", [ "cognito-idp.us-west-2.amazonaws.com" , "/", !Ref CognitoUserPool, ":", !Ref CognitoUserPoolAppClient], ]
    

    其中CognitoUserPoolAppClient 的类型为AWS::Cognito::UserPoolClient

    我能够成功地将规则添加到身份提供者。

    【讨论】:

      猜你喜欢
      • 2019-04-07
      • 2017-10-15
      • 2020-04-25
      • 2021-11-26
      • 2019-06-06
      • 1970-01-01
      • 2018-02-11
      • 2021-05-05
      • 2015-11-09
      相关资源
      最近更新 更多