aws-amplify / docs

AWS Amplify Framework Documentation
https://docs.amplify.aws
Apache License 2.0
479 stars 1.02k forks source link

Add details for AppSync IAM auth regarding `$context.indentity.cognitoIdentityId` #2898

Open JeremyJonas opened 3 years ago

JeremyJonas commented 3 years ago

Is your feature request related to a problem? Please describe. The GraphQL Auth docs does not specify any details around AUTH_TYPE.AWS_IAM being required to get $context.indentity.congnitoIdentityId during AppSync resolvers.

When using a Cognito User Pool with Federated Identity, and following the cognito s3 access docs, there is no mention that to have this value in your resolvers you must use IAM auth and would assume the use of AMAZON_COGNITO_USER_POOLS.

The reference I have found for this detail is from a forum post - https://forums.aws.amazon.com/thread.jspa?threadID=292671

Describe the solution you'd like Add doc/guide describing how to get $context.identity.cognitoIdentityId in AppSync resolvers.

Reference that material in:

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context When using the IAM policy for cognito user access to s3 buckets based on cognito identity (example) the resolvers for your AppSync API need to be able to retrieve this information from the request in order to perform actions on behalf of users.

Searching google produces confusion in this area

rafaelfaria commented 3 years ago

+1

I am also trying to get the cognitoIdentifyId using IAM but it keeps returning null despite the documentation describing as returning a string.

https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html#aws-appsync-resolver-context-reference-identity

I would love to know more about how I can get this id because my app depends heavily on me figuring this out.