Closed nkhine closed 1 year ago
Hi @nkhine
The Passwordless solution needs to be in the same stack as the User Pool (have a read of #118 for more info on why this is). If I read your code and diagram right, they are in different stacks, and that won't work.
You could tweak your code e.g. like so:
interface Props {
readonly stage: string;
readonly userPool: cdk.aws_cognito.UserPool;
}
// Custom class that is not a stack but rather adds to an existing stack
export class PasswordlessAddition {
passwordless: Passwordless;
public readonly fido2Api: RestApi;
constructor(scope: Construct, id: string, props: Props) {
super(scope, id, props);
const userPoolStack = cdk.Stack.of(props.userPool);
// Use existing stack as the `scope` argument to the Passwordless component
this.passwordless = new Passwordless(userPoolStack, "Passwordless", {
userPool: props.userPool,
// etc.
});
}
Hi @ottokruse Thanks for the reply, I got it working.
Hello, I would like to add the amazon-cognito-passwordless-auth to an existing AWS-CDK stack that already has an API Gateway and AWS Cognito Pool.
When I try to synthesise my stack, I get the following error, as I have tried to add my functions to the fido2Api that was created by the PasswordlessStack.
Here is my setup:
And my passwordless.ts stack is just from the example with a slight change
Removing the
fido2Api: passwordlessStack.fido2Api,
everything builds correctly.So it seems I will have two Api Gateway and two CognitoPools
How do I expose the RestApi so that I can add my functions?
Any advice is much appreciated