我正在尝试使用 CognitoUserPool 作为一个身份验证提供程序创建一个 Cognito FederatedIdentityPool。创建 UserPool 很简单:
const userPool = new cognito.CfnUserPool(this, 'MyCognitoUserPool')
const userPoolClient = new cognito.CfnUserPoolClient(this, 'RandomQuoteUserPoolClient', {
generateSecret: false,
userPoolId: userPool.userPoolId
});
但是我不确定如何将其连接到身份池:
const identityPool = new cognito.CfnIdentityPool(this, 'MyIdentityPool', {
allowUnauthenticatedIdentities: false,
cognitoIdentityProviders: ?????
});
根据IdentityProvider API Documentation,它看起来有一个属性cognitoIdentityProviders
,但是它接受一个cdk.Token/CognitoIdentityProviderProperty
.
现在我尝试创建一个CognitoIdentityProviderProperty对象并传递它cognitoIdentityProviders: [{ clientId: userPoolClient.userPoolClientId }]
,但我得到以下异常:
1/2 | 09:48:35 | CREATE_FAILED | AWS::Cognito::IdentityPool | RandomQuoteIdentityPool Invalid Cognito Identity Provider (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: InvalidParameterException; Request ID: 4d6d579a-6455-11e9-99a9-85159bc87779)
new CdkWorkshopStack (/Users/cdk/lib/cdk-workshop-stack.ts:46:26)
\_ Object.<anonymous> (/Users/cdk/bin/cdk-workshop.ts:7:1)
\_ Module._compile (module.js:653:30)
\_ Object.Module._extensions..js (module.js:664:10)
\_ Module.load (module.js:566:32)
\_ tryModuleLoad (module.js:506:12)
\_ Function.Module._load (module.js:498:3)
\_ Function.Module.runMain (module.js:694:10)
\_ startup (bootstrap_node.js:204:16)
\_ bootstrap_node.js:625:3
我什至尝试从 AWS 控制台复制 id 并在此处对其进行硬编码,仍然是同样的错误。
- 有人可以帮我解释如何在
CfnIdentityPool
. - 为什么会有UserPool和CfnUserPool?它们之间有什么区别,应该使用哪一个?