【问题标题】:Access to Role 'cognito role' is forbidden禁止访问角色“认知角色”
【发布时间】:2019-03-28 00:15:44
【问题描述】:

我收到了这个奇怪的错误 禁止访问角色“认知角色”。

在创建云形成堆栈时,这里是我的 yaml 格式的云形成文件。

我基本上是在创建一个 s3 存储桶和一个 cognito 身份,以方便客户端访问我的存储桶,除了这个错误,整个事情都运行良好 禁止访问角色“phototest-cognitoRole-1AMKUVXUXAJ5H”。 (服务:AmazonCognitoIdentity;状态代码:400;错误代码:NotAuthorizedException

AWSTemplateFormatVersion: 2010-09-09

资源:

photoBucket:
    Type: AWS::S3::Bucket 
    Properties:
        BucketName: it-academy-photos-bucket 
        CorsConfiguration: 
            CorsRules:
                - AllowedHeaders: ['*']
                  AllowedMethods: [GET,POST,PUT]
                  AllowedOrigins: ['*']
                  Id: myrules   


cognitoRole:
    Type: AWS::IAM::Role
    Properties:
         AssumeRolePolicyDocument: 
            Version: "2012-10-17"
            Statement:
                - 
                    Effect: Allow
                    Principal:
                     Federated:
                       - "cognito-identity.amazonaws.com"

                    Action:
                       - sts:AssumeRoleWithWebIdentity 


         Policies:
            -
                PolicyName: "photo_client_policy"
                PolicyDocument:
                    Version: '2012-10-17'
                    Statement:

                        - 
                         Sid: VisualEditor1
                         Effect: Allow
                         Action:
                           - s3:PutObject
                           - s3:GetObjectAcl
                           - s3:GetObject
                           - s3:GetObjectTorrent
                           - s3:GetObjectVersionAcl
                           - s3:PutObjectVersionTagging
                           - s3:GetObjectTagging
                           - s3:PutObjectTagging
                           - s3:PutBucketCORS
                           - s3:PutObjectAcl
                           - s3:GetObjectVersion
                         Resource: "*"


cognitoIdentityPool:
    Type: AWS::Cognito::IdentityPool
    Properties:
        IdentityPoolName: "photo_bucket"
        AllowUnauthenticatedIdentities: true

cognitoIdentityPoolRoleAttachment:
    Type: AWS::Cognito::IdentityPoolRoleAttachment
    Properties:
        IdentityPoolId: !Ref cognitoIdentityPool
        Roles:
            unauthenticated: !Ref cognitoRole                               

【问题讨论】:

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


    【解决方案1】:

    我遇到了同样的问题,发现未经身份验证的角色需要 Arn 而不是逻辑 ID。这应该可以解决问题:

    cognitoIdentityPoolRoleAttachment:
        Type: AWS::Cognito::IdentityPoolRoleAttachment
        Properties:
            IdentityPoolId: !Ref cognitoIdentityPool
            Roles:
                unauthenticated: !GetAtt cognitoRole.Arn
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-05
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-30
      • 2019-05-31
      相关资源
      最近更新 更多