amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

feat(auth): Add identityPoolEndpoint config to allow using a custom CognitoIdentity endpoint

Open whummer opened this issue 1 year ago • 13 comments

Add identityPoolEndpoint config to allow using a custom CognitoIdentity endpoint.

Motivation

We already have the ability to specify a custom endpoint for CognitoIdentityProvider, which was added by @jimblanc in this PR: https://github.com/aws-amplify/amplify-js/pull/12236 (and then later renamed to userPoolEndpoint in this PR)

In addition to specifying a custom endpoint for user pools (CognitoIdentityProvider), it would be awesome if we can do the same thing for identity pools (CognitoIdentity) as well.

Description of changes

This PR introduces a userPoolEndpoint field for the Amplify configuration. The field is optional, and if specified, then the endpointResolver in cognitoIdentity/base.ts uses its value as the endpoint for the CognitoIdentity SDK client.

The implementation of the new endpointResolver function is analogous to the existing function for CognitoIdentityProvider here: https://github.com/aws-amplify/amplify-js/blob/b6de5f9127f5382bb880becbcbc29748d8cf9d60/packages/auth/src/providers/cognito/utils/clients/CognitoIdentityProvider/base.ts#L32-L42

Description of how you validated changes

Local testing of various Amplify sample apps (including the Lambda Powertools workshop repo /cc @heitorlessa ).

Checklist

  • [x] PR description included
  • [x] yarn test passes
  • [ ] Unit Tests are changed or added. <-- would be grateful for some inputs here 🙌 - are tests required for this change, and what would be a good place to add them?
  • [ ] Relevant documentation is changed or added (and PR referenced) <-- Would be happy for some pointers here as well - tried generating the API docs via yarn docs, but that seems to have generated lots of changes that are unrelated to this PR. 🤔

Checklist for repo maintainers

  • [ ] Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • [ ] New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

whummer avatar Jun 30 '24 15:06 whummer