Skip to content

Commit 55f186d

Browse files
ShadowCat567aws-amplify-botVieltojarvi
authored
refactor: category-auth, category-geo, and category-predictions to SDK V3 (#14221)
* refactor: upgrade category auth * fix: update function * refactor: geo * fix: identityPool test * fix: remove region * fix: region stuff * fix: identityPool test * fix: dedupe and api * refactor: update clients * fix: api and proxy * refactor: e2e-core and some e2e-test files * refactor: e2e-tests and ui-builder * fix: e2e cleanup * fix: dedupe * fix: toString * fix: some e2e tests * fix: trying something with some function tests * fix: part of the attempt * fix: function tests * fix: e2e tests * fix: some e2e tests and gaining info * fix: adding to if statement * fix: attempt for api * fix: updates to hosted-ui * fix: api e2es * chore: gathering info * fix: cleanup resources * fix: bucket problems * fix: update memory for cleanup_resources * chore: adjustments * fix: possible fix for special cases * chore: remove sdk migrations for e2e-core * refactor: yarnlock and some e2e test reverts * refactor: revert some e2e tests changes * chore: reverting some more files * chore: revert e2e test changes * chore: yarn lock * chore: collecting info * chore: node version * chore: node version linux * fix: clean up * chore: minor adjustments --------- Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: Vieltojarvi <lvielto@amazon.com>
1 parent a007ec7 commit 55f186d

File tree

23 files changed

+1544
-286
lines changed

23 files changed

+1544
-286
lines changed

.circleci/local_publish_helpers_codebuild.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ function verifyPkgCli {
139139
fi
140140
}
141141

142-
# TODO: After V3 migrations are done, decrease 995 back to 930 and 825 back to 750
143-
verifySinglePkg "amplify-pkg-linux-x64" "amplify-pkg-linux-x64.tgz" $((995 * 1024 * 1024))
144-
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((995 * 1024 * 1024))
145-
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((995 * 1024 * 1024))
142+
# TODO: After V3 migrations are done, decrease 1020 back to 930 and 825 back to 750
143+
verifySinglePkg "amplify-pkg-linux-x64" "amplify-pkg-linux-x64.tgz" $((1020 * 1024 * 1024))
144+
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((1020 * 1024 * 1024))
145+
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((1020 * 1024 * 1024))
146146
verifySinglePkg "amplify-pkg-linux-arm64" "amplify-pkg-linux-arm64.tgz" $((825 * 1024 * 1024))
147147
}
148148

packages/amplify-category-auth/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
"@aws-amplify/amplify-prompts": "2.8.7",
3535
"@aws-amplify/amplify-util-import": "2.8.3",
3636
"@aws-amplify/cli-extensibility-helper": "3.0.39",
37+
"@aws-sdk/client-cognito-identity": "^3.624.0",
38+
"@aws-sdk/client-cognito-identity-provider": "^3.624.0",
39+
"@aws-sdk/client-s3": "^3.624.0",
3740
"amplify-headless-interface": "1.17.8",
3841
"amplify-util-headless-input": "1.9.19",
3942
"aws-cdk-lib": "~2.189.1",
40-
"aws-sdk": "^2.1464.0",
4143
"axios": "^1.6.7",
4244
"chalk": "^4.1.1",
4345
"change-case": "^4.1.1",
@@ -52,7 +54,6 @@
5254
"uuid": "^8.3.2"
5355
},
5456
"devDependencies": {
55-
"@aws-sdk/client-cognito-identity-provider": "3.624.0",
5657
"@aws-sdk/client-iam": "3.624.0",
5758
"@types/mime-types": "^2.1.1",
5859
"cloudform-types": "^4.2.0",

packages/amplify-category-auth/src/provider-utils/awscloudformation/import/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { ICognitoUserPoolService, IIdentityPoolService } from '@aws-amplify/amplify-util-import';
22
import { $TSAny, $TSContext, ServiceSelection, stateManager, AmplifyError, AmplifyFrontend } from '@aws-amplify/amplify-cli-core';
3-
import { CognitoIdentityProvider, IdentityPool } from 'aws-sdk/clients/cognitoidentity';
4-
import {
5-
IdentityProviderType,
6-
UserPoolClientType,
7-
UserPoolDescriptionType,
8-
UserPoolType,
9-
} from 'aws-sdk/clients/cognitoidentityserviceprovider';
3+
import { CognitoIdentityProvider, IdentityPool } from '@aws-sdk/client-cognito-identity';
4+
import { IdentityProviderType, UserPoolClientType, UserPoolDescriptionType, UserPoolType } from '@aws-sdk/client-cognito-identity-provider';
105
import { printer } from '@aws-amplify/amplify-prompts';
116
import { ensureEnvParamManager } from '@aws-amplify/amplify-environment-parameters';
127
import Enquirer from 'enquirer';
@@ -82,7 +77,7 @@ const printSuccess = (context: $TSContext, authSelections: AuthSelections, userP
8277
if (authSelections === 'userPoolOnly') {
8378
printer.info(importMessages.UserPoolOnlySuccess(userPool.Name!));
8479
} else {
85-
printer.info(importMessages.UserPoolAndIdentityPoolSuccess(userPool.Name!, identityPool!.IdentityPoolName));
80+
printer.info(importMessages.UserPoolAndIdentityPoolSuccess(userPool.Name!, identityPool!.IdentityPoolName!));
8681
}
8782
printer.blankLine();
8883
printer.info('Next steps:');
@@ -294,7 +289,7 @@ const importServiceWalkthrough = async (
294289
if (questionParameters.validatedIdentityPools!.length === 1) {
295290
const { identityPool } = questionParameters.validatedIdentityPools![0];
296291

297-
printer.info(importMessages.OneIdentityPoolValid(identityPool.IdentityPoolName, identityPool.IdentityPoolId));
292+
printer.info(importMessages.OneIdentityPoolValid(identityPool.IdentityPoolName!, identityPool.IdentityPoolId!));
298293

299294
answers.identityPoolId = identityPool.IdentityPoolId;
300295
answers.identityPool = identityPool;

packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
IdentityProviderType,
55
UserPoolClientType,
66
UserPoolType,
7-
} from 'aws-sdk/clients/cognitoidentityserviceprovider';
8-
import { CognitoIdentityProvider, IdentityPool } from 'aws-sdk/clients/cognitoidentity';
7+
} from '@aws-sdk/client-cognito-identity-provider';
8+
import { CognitoIdentityProvider, IdentityPool } from '@aws-sdk/client-cognito-identity';
99
import { ICognitoUserPoolService, IIdentityPoolService } from '@aws-amplify/amplify-util-import';
1010

1111
export type AuthSelections = 'userPoolOnly' | 'identityPoolAndUserPool';

packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/get-app-client-secret-sdk.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { $TSContext, AmplifyFault } from '@aws-amplify/amplify-cli-core';
2-
import { CognitoIdentityServiceProvider } from 'aws-sdk';
2+
import { CognitoIdentityProviderClient, DescribeUserPoolClientCommand } from '@aws-sdk/client-cognito-identity-provider';
33

44
export const getAppClientSecret = async (context: $TSContext, userpoolId: string, clientId: string): Promise<string | undefined> => {
55
try {
@@ -8,7 +8,8 @@ export const getAppClientSecret = async (context: $TSContext, userpoolId: string
88
ClientId: clientId,
99
UserPoolId: userpoolId,
1010
};
11-
const result = await identity.describeUserPoolClient(params).promise();
11+
const command = new DescribeUserPoolClientCommand(params);
12+
const result = await identity.send(command);
1213
return result.UserPoolClient?.ClientSecret;
1314
} catch (error) {
1415
throw new AmplifyFault(
@@ -21,8 +22,8 @@ export const getAppClientSecret = async (context: $TSContext, userpoolId: string
2122
}
2223
};
2324

24-
const getCognitoIdentityProviderClient = async (context: $TSContext): Promise<CognitoIdentityServiceProvider> => {
25-
const { client } = await context.amplify.invokePluginMethod<{ client: CognitoIdentityServiceProvider }>(
25+
const getCognitoIdentityProviderClient = async (context: $TSContext): Promise<CognitoIdentityProviderClient> => {
26+
const { client } = await context.amplify.invokePluginMethod<{ client: CognitoIdentityProviderClient }>(
2627
context,
2728
'awscloudformation',
2829
undefined,

packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/get-oauth-secrets-from-cognito.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ICognitoUserPoolService } from '@aws-amplify/amplify-util-import';
22
import { $TSContext, stateManager, JSONUtilities } from '@aws-amplify/amplify-cli-core';
3-
import { IdentityProviderType } from 'aws-sdk/clients/cognitoidentityserviceprovider';
3+
import { IdentityProviderType } from '@aws-sdk/client-cognito-identity-provider';
44
import { createOAuthCredentials } from '../import';
55

66
/**

packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/trigger-file-uploader.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { $TSContext, pathManager, stateManager, AmplifyCategories, spinner, AmplifyFault } from '@aws-amplify/amplify-cli-core';
2-
import type { S3 } from 'aws-sdk';
2+
import { S3Client, PutObjectCommand, PutObjectCommandInput, PutObjectCommandOutput } from '@aws-sdk/client-s3';
33
import { createReadStream, readdirSync, existsSync } from 'fs-extra';
44
import mime from 'mime-types';
55
import * as path from 'path';
66
import { getAuthResourceName } from '../../../utils/getAuthResourceName';
7-
import s3 from 'aws-sdk/clients/s3';
87

98
const providerName = 'awscloudformation';
109

11-
const getS3Client = async (context: $TSContext, action: string): Promise<S3> => {
10+
const getS3Client = async (context: $TSContext, action: string): Promise<S3Client> => {
1211
const providerPlugins = context.amplify.getProviderPlugins(context);
1312
const provider = await import(providerPlugins[providerName]);
1413
const config = await provider.getConfiguredAWSClientConfig(context, AmplifyCategories.AUTH, action);
15-
return new s3(config);
14+
return new S3Client(config);
1615
};
1716

1817
/**
@@ -36,7 +35,7 @@ export const uploadFiles = async (context: $TSContext): Promise<void> => {
3635
return;
3736
}
3837
const fileList = readdirSync(assetPath);
39-
const uploadFileTasks: (() => Promise<S3.ManagedUpload.SendData>)[] = [];
38+
const uploadFileTasks: (() => Promise<PutObjectCommandOutput>)[] = [];
4039
fileList.forEach((file) => {
4140
uploadFileTasks.push(async () => uploadFile(s3Client, bucketName, path.join(assetPath, file), file));
4241
});
@@ -54,16 +53,22 @@ export const uploadFiles = async (context: $TSContext): Promise<void> => {
5453
}
5554
};
5655

57-
const uploadFile = async (s3Client: S3, hostingBucketName: string, filePath: string, file: string): Promise<S3.ManagedUpload.SendData> => {
56+
const uploadFile = async (
57+
s3Client: S3Client,
58+
hostingBucketName: string,
59+
filePath: string,
60+
file: string,
61+
): Promise<PutObjectCommandOutput> => {
5862
const fileStream = createReadStream(filePath);
5963
const contentType = mime.lookup(filePath);
60-
const uploadParams = {
64+
const uploadParams: PutObjectCommandInput = {
6165
Bucket: hostingBucketName,
6266
Key: file,
6367
Body: fileStream,
6468
ContentType: contentType || 'text/plain',
6569
ACL: 'public-read',
6670
};
6771

68-
return s3Client.upload(uploadParams).promise();
72+
const command = new PutObjectCommand(uploadParams);
73+
return await s3Client.send(command);
6974
};

packages/amplify-category-geo/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@
2828
"dependencies": {
2929
"@aws-amplify/amplify-cli-core": "4.4.2",
3030
"@aws-amplify/amplify-prompts": "2.8.7",
31+
"@aws-sdk/client-location": "^3.624.0",
3132
"ajv": "^6.12.6",
3233
"amplify-headless-interface": "1.17.8",
3334
"amplify-util-headless-input": "1.9.19",
3435
"aws-cdk-lib": "~2.189.1",
35-
"aws-sdk": "^2.1464.0",
3636
"constructs": "^10.0.5",
3737
"fs-extra": "^8.1.0",
3838
"lodash": "^4.17.21",
3939
"uuid": "^8.3.2"
4040
},
41-
"devDependencies": {
42-
"@aws-sdk/client-location": "3.624.0"
43-
},
4441
"jest": {
4542
"collectCoverage": true,
4643
"collectCoverageFrom": [

packages/amplify-category-geo/src/provider-controllers/import.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { $TSContext } from '@aws-amplify/amplify-cli-core';
33
import { prompter, printer } from '@aws-amplify/amplify-prompts';
44
import { existsSync, writeFileSync } from 'fs-extra';
55
import { join } from 'path';
6-
import Location from 'aws-sdk/clients/location';
6+
import { LocationClient, BatchPutGeofenceCommand } from '@aws-sdk/client-location';
77
import { ServiceName } from '../service-utils/constants';
88
import { validateGeoJSONObj } from '../service-utils/validateGeoJSONObj';
99
import {
@@ -112,7 +112,7 @@ export const importResource = async (context: $TSContext) => {
112112
const bulkUploadGeofence = async (context: $TSContext, params: ImportParams, region: string) => {
113113
printer.info('Updating your Geofences in the collection...');
114114
try {
115-
const { client } = await context.amplify.invokePluginMethod<{ client: Location }>(
115+
const { client } = await context.amplify.invokePluginMethod<{ client: LocationClient }>(
116116
context,
117117
'awscloudformation',
118118
undefined,
@@ -127,7 +127,8 @@ const bulkUploadGeofence = async (context: $TSContext, params: ImportParams, reg
127127
CollectionName: params.collectionToImport,
128128
Entries: geofenceEntries.splice(0, MAX_ENTRIES_PER_BATCH),
129129
};
130-
uploadTasks.push(client.batchPutGeofence(geofenceCollectionPerBatch).promise());
130+
const command = new BatchPutGeofenceCommand(geofenceCollectionPerBatch);
131+
uploadTasks.push(client.send(command));
131132
}
132133
await Promise.all(uploadTasks);
133134
printer.success(`Successfully added/updated ${totalGeofenceCount} Geofences in your "${params.collectionToImport}" collection`);

packages/amplify-category-predictions/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"dependencies": {
2828
"@aws-amplify/amplify-cli-core": "4.4.2",
2929
"@aws-amplify/amplify-prompts": "2.8.7",
30-
"aws-sdk": "^2.1464.0",
3130
"chalk": "^4.1.1",
3231
"fs-extra": "^8.1.0",
3332
"uuid": "^8.3.2"

0 commit comments

Comments
 (0)