【发布时间】:2020-08-12 02:30:03
【问题描述】:
我通过 aws-cdk 将 AWS Cognito 用户池部署为 CognitoStack。
现在,我想自动测试使用上述 AWS Cognito UserPool 进行身份验证的 GraphQL API。
如何以编程方式从CogntioStack 获取身份验证所需的UserPoolId?
我的CognitoStack 是:
export class CognitoStack extends Stack {
public readonly userPool: UserPool;
constructor(scope: App, id: string, props?: StackProps) {
super(scope, id, props);
this.userPool = new UserPool(this, 'UserPool', {
signInAliases: {
email: true,
phone: false,
username: false,
preferredUsername: false,
},
autoVerify: {
phone: false,
email: false,
},
selfSignUpEnabled: true,
});
this.userPool.addClient('web', {
authFlows: {
refreshToken: true,
userSrp: true,
},
});
new CfnOutput(this, 'UserPoolId', {
value: this.userPool.userPoolId,
})
}
}
当我cdk deploy CognitoStack 时,我得到:
Outputs:
CognitoStack.UserPoolId = eu-central-1_xafasds
CognitoStack.ExportsOutputRefUserPool6BA7E5F296FD7236 = eu-central-1_xasdfdd
但是,当我检查 cdk.out/CognitoStack.template.json(在我的测试中我很容易可以 require)时,没有出现 eu-central-1_xasdfdd。
【问题讨论】:
标签: amazon-web-services aws-cdk