Skip to content

Instantly share code, notes, and snippets.

@franzwong
Created January 23, 2019 14:41
Show Gist options
  • Save franzwong/e8152f88044f85ef7dc8b37ee3fe7984 to your computer and use it in GitHub Desktop.
Save franzwong/e8152f88044f85ef7dc8b37ee3fe7984 to your computer and use it in GitHub Desktop.
HowTo: Grant IAM role to Cognito authenticated user
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