8000 bug: Cognito PostConfirmation Event does not pass clientMetadata to the Lambda trigger · Issue #11849 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content
bug: Cognito PostConfirmation Event does not pass clientMetadata to the Lambda trigger #11849
@silenceisgolden

Description

@silenceisgolden

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

With the following configuration

  • Localstack Pro running in a Docker container on port 4566
  • A Cognito User Pool (id: us-east-1_userpool)
    • Lambda PostConfirmation trigger configured
    • Username attributes includes email
    • AutoVerifiedAttributes includes email
  • A Cognito User Pool App Client (id: userpoolclient)
  • A Lambda (arn: arn:aws:lambda:us-east-1:000000000000:function:local-cognito)
    • This lambda should log out the event and then return with a successful response
  • An email - aj@email.test
  • A password - abcdefg987

Run these commands

aws cognito-idp sign-up --client-id userpoolclient --username aj@email.test --password abcdefg987 --region us-east-1 --endpoint-url http://localhost:4566

# Get the UserSub value from the prior command's output and replace ##UserSub## in the next command
# From the localstack container, get the confirmation code from the logs and replace ##ConfirmationCode## in the next command

aws cognito-idp confirm-sign-up --client-id userpoolclient --username ##UserSub## --confirmation-code ##ConfirmationCode## --client-metadata '{"testing":"true"}' --region us-east-1 --endpoint-url http://localhost:4566

Look at the lambda logs and observe that the event log includes clientMetadata: {}:

{
  "version": "$LATEST",
  "triggerSource": "PostConfirmation_ConfirmSignUp",
  "userName": "##UserSub##",
  "region": "us-east-1",
  "userPoolId": "us-east-1_userpool",
  "callerContext": {
    "awsSdkVersion": "aws-sdk-unknown-unknown",
    "clientId": "userpoolclient"
  },
  "request": {
    "validationData": {},
    "clientMetadata": {},
    "session": [],
    "userAttributes": {
      "email": "aj@email.test",
      "sub": "##UserSub##",
      "email_verified": "false",
      "cognito:user_status": "CONFIRMED"
    }
  },
  "response": {}
}

Expected Behavior

clientMetadata should be {"testing":"true"}

{
  "version": "$LATEST",
  "triggerSource": "PostConfirmation_ConfirmSignUp",
  "userName": "##UserSub##",
  "region": "us-east-1",
  "userPoolId": "us-east-1_userpool",
  "callerContext": {
    "awsSdkVersion": "aws-sdk-unknown-unknown",
    "clientId": "userpoolclient"
  },
  "request": {
    "validationData": {},
    "clientMetadata": {
      "testing": "true"
    },
    "session": [],
    "userAttributes": {
      "email": "aj@email.test",
      "sub": "##UserSub##",
      "email_verified": "false",
      "cognito:user_status": "CONFIRMED"
    }
  },
  "response": {}
}

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run localstack/localstack-pro:3.8.1

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

aws cognito-idp sign-up --client-id userpoolclient --username aj@email.test --password abcdefg987 --region us-east-1 --endpoint-url http://localhost:4566

# Get the UserSub value from the prior command's output and replace ##UserSub## in the next command
# From the localstack container, get the confirmation code from the logs and replace ##ConfirmationCode## in the next command

aws cognito-idp confirm-sign-up --client-id userpoolclient --username ##UserSub## --confirmation-code ##ConfirmationCode## --client-metadata '{"testing":"true"}' --region us-east-1 --endpoint-url http://localhost:4566

See "Current Behavior" for more details

Environment

- OS: Localstack Container base OS
- LocalStack:
  LocalStack version: 3.8.1
  LocalStack Docker image sha: sha256:6caa495b79f3b51428a4bb81a0952e9ccf4d79fbbb1b2031cbd0a10057ffc60e
  LocalStack build date: 2024-10-08
  LocalStack build git hash: 307c4c26

Anything else?

I tried this with the latest Docker image tag a few days ago and got the same result.

I have confirmed that this setup works as expected in AWS.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0