A developer is building a mobile application that needs to upload user-generated files directly to a private Amazon S3 bucket. The developer has configured an Amazon Cognito User Pool to handle user registration and sign-in. After successfully logging in, users receive JSON Web Tokens (JWTs), but the application receives an Access Denied error (HTTP 403) when attempting to upload files using the AWS SDK. Which two actions should the developer take to resolve this authorization failure? (Select TWO.)
- Create and configure an Amazon Cognito Identity Pool, specifying the Cognito User Pool as the authentication provider.Cevap
- Attach an IAM policy to the Cognito Identity Pool's authenticated IAM role that allows the s3:PutObject action on the target S3 bucket.Cevap
- CAttach an IAM policy granting the s3:PutObject action directly to the Cognito User Pool client app configuration.
- DConfigure an Amazon API Gateway REST API with a custom Lambda authorizer to validate the JWT and proxy the upload requests to S3.
- EEmbed an IAM User's long-term access key and secret access key in the mobile application code to initialize the AWS SDK client.
Cevap
Create and configure an Amazon Cognito Identity Pool with the User Pool as the authentication provider, and attach an IAM policy allowing the s3:PutObject action to the authenticated IAM role associated with the Identity Pool.
To resolve the authorization failure for direct S3 uploads, the application needs to use an Amazon Cognito Identity Pool to exchange Cognito User Pool tokens for temporary AWS credentials, and the authenticated IAM role associated with the Identity Pool must have an IAM policy attached that grants the s3:PutObject permission.
Adım Adım Çözüm
Anahtar Kavram
Federated identities in Cognito require both a User Pool for authentication and an Identity Pool for authorizing direct access to AWS resources using IAM roles.
Tahmini Süre:2m 0s