aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
188 stars 64 forks source link

Look Up Cognito Identity Pool ID, from Cognito User Pool Identity #1599

Open concavegit opened 6 months ago

concavegit commented 6 months ago

Environment information

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M2
  Memory: 154.33 MB / 24.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 22.2.0 - /opt/homebrew/bin/node
  Yarn: undefined - undefined
  npm: 10.7.0 - /opt/homebrew/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.2
  @aws-amplify/backend-cli: 1.0.3
  aws-amplify: 6.3.2
  aws-cdk: 2.142.0
  aws-cdk-lib: 2.142.0
  typescript: 5.4.5
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

I am looking for a way to look up Cognito identity pool id from Cognito user pool identity.

My used case is that I have a workflow that runs for a user every time they create a record in the dynamo DB table. I want my workflow to write to a storage location that is readable by the user.

The record contains an owner field because I have followed this guide to restrict access by owner. This owner field is the Cognito User Pool ID.

My workflow needs to write to a s3 key that is specific to the customer. I configured storage to grant per-user access following this guide. That guide grants per-user access following the user's Identity Pool ID. However, the workflow has no direct way of figuring out what that S3 key is because my mutations only contain the user pool id. A solution would be to give the workflow a way to deduce identity pool ID from user pool ID.

ykethan commented 5 months ago

Hey, thank you for reaching out. Marking this as feature request.