-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cognito-identitypool-alpha): cannot configure roleMappings with i…
…mported userPool and client (#30421) ### Issue # (if applicable) Closes #30304 ### Reason for this change Currently, we cannot use imported user pools and clients for role mapping in an identity pool. This is because the `IdentityPoolProviderUrl.userPool` method takes an L2 construct as its argument type instead of Interface (`IUserPool`, `IUserPoolClient`). ```ts const userPool = cognito.UserPool.fromUserPoolArn(this, 'CognitoUserPool', 'arn'); const userPoolClient = cognito.UserPoolClient.fromUserPoolClientId(this, 'UserPoolClientId', 'client-id'); const identityPool = new cognitoidp.IdentityPool(this, 'IdentityPool', { // ~ roleMappings: [ { mappingKey: 'cognito', providerUrl: cognitoidp.IdentityPoolProviderUrl.userPool(userPool, userPoolClient), // ! type error here ! useToken: true } ], allowUnauthenticatedIdentities: false }); ``` ### Description of changes The argument types of the `IdentityPoolProviderUrl.userPool` method are changed to `IUserPool` and `IUserPoolClient`. This method requires the `userPoolProviderName` of the userPool, but since it does not exist for `IUserPool`, a property was added. Since this property is required in the `UserPool` construct, it is also required in `IUserPool`. https://github.com/aws/aws-cdk/blob/c3003ab41f0efc763f39eb2cab490c8a005e146b/packages/aws-cdk-lib/aws-cognito/lib/user-pool.ts#L902 I add a required attribute to the Interface of the aws-cognito module(stable), but I do not think this to be a breaking change. Please let me know if it is not. ### Description of how you validated changes Unit tests and integ tests are added to verify that the imported userPool and clinet can be used. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
1581190
commit 0fdd6a9
Showing
11 changed files
with
583 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/@aws-cdk/aws-cognito-identitypool-alpha/test/integ.identitypool.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...ito-identitypool-alpha/test/integ.identitypool.js.snapshot/integ-identitypool.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/@aws-cdk/aws-cognito-identitypool-alpha/test/integ.identitypool.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.