Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-cdk-lib/aws-cognito: Cannot use the .addTrigger() method on an existing userpool #33350

Open
1 task
BTech-Developer opened this issue Feb 8, 2025 · 4 comments
Labels
@aws-cdk/aws-cognito Related to Amazon Cognito bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@BTech-Developer
Copy link

BTech-Developer commented Feb 8, 2025

Describe the bug

I am currently unable to use the addTrigger() method on UserPool created in CDK.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

userPool.addTrigger() should be a valid method for adding a trigger to a cognito user pool. Type hints should be available and working in any modern IDE.

Current Behavior

When attempting to call the addTrigger() method on a userpool, CDK fails to compile and states the method does not exist.

TSError: ⨯ Unable to compile TypeScript:
lib/stacks/myStack.ts:106:25 - error TS2339: Property 'addTrigger' does not exist on type 'IUserPool'.

106         cognitoUserPool.addTrigger()

Reproduction Steps

const cognitoUserPool = new UserPool(this, 'UserPool', {
                selfSignUpEnabled: true,
                accountRecovery: AccountRecovery.PHONE_AND_EMAIL,
                userVerification: {
                    emailStyle: VerificationEmailStyle.CODE,
                },
                autoVerify: {
                    email: true,
                },
                standardAttributes: {
                    email: {
                        required: true,
                        mutable: true,
                    },
                },
            });

// This does not work, even if the correct props are provided
cognitoUserPool.addTrigger()

Possible Solution

No response

Additional Information/Context

I've attempted updating version, invalidating caches, removing node_modules and reinstalling.

CDK CLI Version

2.178.1

Framework Version

No response

Node.js Version

v18.19.1

OS

Ubuntu 24

Language

TypeScript

Language Version

No response

Other information

No response

@BTech-Developer BTech-Developer added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 8, 2025
@github-actions github-actions bot added the @aws-cdk/aws-cognito Related to Amazon Cognito label Feb 8, 2025
@pahud
Copy link
Contributor

pahud commented Feb 10, 2025

I think you should use cognitoUserPool.addTrigger(), no?

const cognitoUserPool = new UserPool(this, 'UserPool', {
                selfSignUpEnabled: true,
                accountRecovery: AccountRecovery.PHONE_AND_EMAIL,
                userVerification: {
                    emailStyle: VerificationEmailStyle.CODE,
                },
                autoVerify: {
                    email: true,
                },
                standardAttributes: {
                    email: {
                        required: true,
                        mutable: true,
                    },
                },
            });

// This does not work, even if the correct props are provided
cognitoUserPool.addTrigger()

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p3 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 10, 2025
@BTech-Developer
Copy link
Author

I think you should use cognitoUserPool.addTrigger(), no?

const cognitoUserPool = new UserPool(this, 'UserPool', {
selfSignUpEnabled: true,
accountRecovery: AccountRecovery.PHONE_AND_EMAIL,
userVerification: {
emailStyle: VerificationEmailStyle.CODE,
},
autoVerify: {
email: true,
},
standardAttributes: {
email: {
required: true,
mutable: true,
},
},
});

// This does not work, even if the correct props are provided
cognitoUserPool.addTrigger()

Hey Pahud, please see the bottom of my inline code. I'm attempting to use .addTrigger() and it does not currently work.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 10, 2025
@BTech-Developer
Copy link
Author

BTech-Developer commented Feb 13, 2025

Hey Pahud, typo in my example, if you see the TypeScript error output it's showing what does not currently work. The function is missing from the interface.

TSError: ⨯ Unable to compile TypeScript:
lib/stacks/myStack.ts:106:25 - error TS2339: Property 'addTrigger' does not exist on type 'IUserPool'.

106         cognitoUserPool.addTrigger()

@BTech-Developer
Copy link
Author

Hey Pahud, we have to make a decision on whether or not to try and tackle this with L1 constructs or when this would be fixed for L2. Do you know what an approximate timeframe would be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cognito Related to Amazon Cognito bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

2 participants