var*_*nit 2 amazon-web-services aws-cloudformation amazon-cognito
我收到这个奇怪的错误访问角色“认知角色”被禁止。
在创建云形成堆栈时,这里是我的 yaml 格式的云形成文件。
我基本上是在创建一个 s3 存储桶和一个认知身份来促进客户端对我的存储桶的访问,整个工作正常,除了这个错误 Access to Role 'phototest-cognitoRole-1AMKUVXUXAJ5H' 被禁止。(服务:AmazonCognitoIdentity;状态代码:400;错误代码:NotAuthorizedException
AWSTemplateFormatVersion: 2010-09-09
Run Code Online (Sandbox Code Playgroud)
资源:
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
Run Code Online (Sandbox Code Playgroud)
小智 6
我遇到了同样的问题,并发现未经身份验证的角色需要 Arn 而不是逻辑 ID。这应该可以解决问题:
cognitoIdentityPoolRoleAttachment:
Type: AWS::Cognito::IdentityPoolRoleAttachment
Properties:
IdentityPoolId: !Ref cognitoIdentityPool
Roles:
unauthenticated: !GetAtt cognitoRole.Arn
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
446 次 |
| 最近记录: |