Skip to content

Commit

Permalink
fix: that
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolk committed Jul 10, 2023
1 parent 6100289 commit ebadf5f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/amplify-provider-awscloudformation/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export type DownloadHandler = (keys: string[]) => Promise<PrimitiveRecord>;
// @public (undocumented)
export function formUserAgentParam(context: any, userAgentAction: any): string;

// Warning: (ae-forgotten-export) The symbol "CognitoUserPoolClientProvider" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function getConfiguredCognitoIdentityProviderClient(context: any): Promise<CognitoUserPoolClientProvider>;

// Warning: (ae-forgotten-export) The symbol "LocationService" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { $TSContext } from '@aws-amplify/amplify-cli-core';
import aws from './aws.js';
import * as AWS from 'aws-sdk';
import { AwsSecrets, loadConfiguration } from '../configuration-manager';

export class CognitoUserPoolClientProvider {
private static instance: CognitoUserPoolClientProvider;
readonly client: AWS.CognitoIdentityServiceProvider;

static async getInstance(context: $TSContext, options = {}): Promise<CognitoUserPoolClientProvider> {
if (!CognitoUserPoolClientProvider.instance) {
const cred: AwsSecrets = await loadConfiguration(context);

CognitoUserPoolClientProvider.instance = new CognitoUserPoolClientProvider(cred, options);
}
return CognitoUserPoolClientProvider.instance;
}

constructor(creds: AwsSecrets, options = {}) {
this.client = new aws.CognitoIdentityServiceProvider({ ...creds, ...options });
}
}
6 changes: 6 additions & 0 deletions packages/amplify-provider-awscloudformation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { loadConfigurationForEnv, loadConfiguration, resolveRegion } from './con
export { loadConfigurationForEnv, loadConfiguration, resolveRegion } from './configuration-manager';
import { getLocationSupportedRegion, getLocationRegionMapping } from './aws-utils/aws-location';
import { SSM } from './aws-utils/aws-ssm';
import { CognitoUserPoolClientProvider } from './aws-utils/aws-cognito-client';
import { Lambda } from './aws-utils/aws-lambda';
import CloudFormation from './aws-utils/aws-cfn';
import { $TSContext, ApiCategoryFacade } from '@aws-amplify/amplify-cli-core';
Expand Down Expand Up @@ -131,6 +132,10 @@ export async function getConfiguredSSMClient(context) {
return await SSM.getInstance(context);
}

export async function getConfiguredCognitoIdentityProviderClient(context) {
return await CognitoUserPoolClientProvider.getInstance(context);
}

export async function getConfiguredLocationServiceClient(context: $TSContext, options?: Record<string, unknown>) {
return await LocationService.getInstance(context, options);
}
Expand Down Expand Up @@ -182,6 +187,7 @@ module.exports = {
createDynamoDBService,
resolveAppId,
loadConfigurationForEnv,
getConfiguredCognitoIdentityProviderClient,
getConfiguredSSMClient,
updateEnv,
getLocationSupportedRegion,
Expand Down

0 comments on commit ebadf5f

Please sign in to comment.