Created
January 23, 2019 14:41
-
-
Save franzwong/e8152f88044f85ef7dc8b37ee3fe7984 to your computer and use it in GitHub Desktop.
HowTo: Grant IAM role to Cognito authenticated user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let response = await login(email, password) | |
const idToken = response.AuthenticationResult.IdToken | |
const { identityId, credentials } = await getUserCredentials(idToken) | |
const s3 = new AWS.S3({ credentials }) | |
response = await s3.putObject({ | |
Body: 'Hello world', | |
Bucket: process.env.S3_BUCKET, | |
Key: `${identityId}/foo.txt`, | |
ContentType: 'text/plain' | |
}).promise() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment