Skip to content

Commit b169eb9

Browse files
ShadowCat567Vieltojarviaws-amplify-bot
authored
refactor: e2es and anything else that remains (#14236)
* refactor: e2e-core * refactor: e2e tests aside from resource clean up * refactor: cleanup scripts * fix: run sequentially * fix: sequential * chore: adjust node config * refactor: remove aws.js file, update category-hosting * refactor: amplify-container-hosting * refactor: dynamodb scan * chore: remove dynamo-scan-v2 * chore: remove deps on v2 * chore: dedupe * Revert "chore: adjust node config" This reverts commit b9a0472. * Revert "fix: sequential" This reverts commit 921f45e. * Revert "fix: run sequentially" This reverts commit 65d79de. * chore: increase node space * chore: increase node space * fix: double pinpoint * chore: debug * fix: bucket endpoint * fix: run clean up sequentially, layer2, debugging custom-resource * fix: balance between squential and parallel * fix: updating cleanup script, parallelism, missing cloudformation config * fix: credentials fallback * chore: remove unused import * fix: string * fix: replace build with buildID to take up less memory * chore: final adjustments * chore: remove global-gc * chore: upgrade sdk v3 packages * fix: adjust package versions --------- Co-authored-by: Vieltojarvi <[email protected]> Co-authored-by: aws-amplify-bot <[email protected]>
1 parent faca740 commit b169eb9

File tree

63 files changed

+2178
-980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2178
-980
lines changed

packages/amplify-category-hosting/__tests__/lib/S3AndCloudFront/helpers/cloudfront-manager.test.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,19 @@ describe('cloudfront-manager', () => {
6262

6363
const mockcftInvalidationData = {};
6464

65-
const mockInvalidateMethod = jest.fn(() => {
66-
return {
67-
promise: () => Promise.resolve(mockcftInvalidationData),
68-
};
69-
});
65+
const mockSendMethod = jest.fn(() => Promise.resolve(mockcftInvalidationData));
7066

71-
class mockCloudFront {
67+
class mockCloudFrontClient {
7268
constructor() {
73-
this.createInvalidation = mockInvalidateMethod;
69+
this.send = mockSendMethod;
7470
}
7571
}
7672

7773
test('invalidateCloudFront', async () => {
78-
const mockCloudFrontClient = async (context, action) => Promise.resolve(new mockCloudFront());
79-
const result = await cloudFrontManager.invalidateCloudFront(mockContext, mockCloudFrontClient);
74+
const mockCloudFrontClientFactory = async (context, action) => Promise.resolve(new mockCloudFrontClient());
75+
const result = await cloudFrontManager.invalidateCloudFront(mockContext, mockCloudFrontClientFactory);
8076
expect(result).toBe(mockContext);
81-
expect(mockInvalidateMethod).toBeCalled();
77+
expect(mockSendMethod).toBeCalled();
8278
expect(mockContext.exeInfo.cftInvalidationData).toEqual(mockcftInvalidationData);
8379
});
8480
});

packages/amplify-category-hosting/lib/S3AndCloudFront/helpers/cloudfront-manager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const chalk = require('chalk');
22
const constants = require('../../constants');
3-
const CloudFront = require('aws-sdk/clients/cloudfront');
3+
const { CloudFrontClient, CreateInvalidationCommand } = require('@aws-sdk/client-cloudfront');
44

55
const providerName = 'awscloudformation';
66

@@ -28,7 +28,8 @@ async function invalidate(context, cloudFrontClient = getCloudFrontClient) {
2828
};
2929

3030
try {
31-
const data = await cloudFront.createInvalidation(invalidateParams).promise();
31+
const command = new CreateInvalidationCommand(invalidateParams);
32+
const data = await cloudFront.send(command);
3233
context.print.info('CloudFront invalidation request sent successfuly.');
3334
context.print.info(chalk.green(CloudFrontSecureURL));
3435
context.exeInfo.cftInvalidationData = data;
@@ -45,7 +46,7 @@ async function getCloudFrontClient(context, action) {
4546
const providerPlugins = context.amplify.getProviderPlugins(context);
4647
const provider = require(providerPlugins[providerName]);
4748
const config = await provider.getConfiguredAWSClientConfig(context, constants.CategoryName, action);
48-
return new CloudFront(config);
49+
return new CloudFrontClient(config);
4950
}
5051

5152
module.exports = {

packages/amplify-category-hosting/lib/S3AndCloudFront/helpers/file-uploader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const sequential = require('promise-sequential');
33
const fileScanner = require('./file-scanner');
44
const constants = require('../../constants');
55
const { uploadFile } = require('./upload-file');
6-
const S3 = require('aws-sdk/clients/s3');
6+
const { S3Client } = require('@aws-sdk/client-s3');
77

88
const serviceName = 'S3AndCloudFront';
99
const providerName = 'awscloudformation';
@@ -43,7 +43,7 @@ async function getS3Client(context, action) {
4343
const providerPlugins = context.amplify.getProviderPlugins(context);
4444
const provider = require(providerPlugins[providerName]);
4545
const config = await provider.getConfiguredAWSClientConfig(context, constants.CategoryName, action);
46-
return new S3(config);
46+
return new S3Client(config);
4747
}
4848

4949
function getHostingBucketName(context) {

packages/amplify-category-hosting/lib/S3AndCloudFront/helpers/upload-file.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs-extra');
22
const path = require('path');
33
const mime = require('mime-types');
4+
const { Upload } = require('@aws-sdk/lib-storage');
45

56
async function uploadFile(s3Client, hostingBucketName, distributionDirPath, filePath, hasCloudFront) {
67
let relativeFilePath = path.relative(distributionDirPath, filePath);
@@ -19,7 +20,12 @@ async function uploadFile(s3Client, hostingBucketName, distributionDirPath, file
1920
uploadParams.ACL = 'public-read';
2021
}
2122

22-
const data = await s3Client.upload(uploadParams).promise();
23+
const upload = new Upload({
24+
client: s3Client,
25+
params: uploadParams,
26+
});
27+
28+
const data = await upload.done();
2329

2430
return data;
2531
}

packages/amplify-category-hosting/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"dependencies": {
2424
"@aws-amplify/amplify-cli-core": "4.4.3",
2525
"@aws-amplify/amplify-prompts": "2.8.7",
26-
"aws-sdk": "^2.1692.0",
26+
"@aws-sdk/client-cloudfront": "^3.919.0",
27+
"@aws-sdk/client-s3": "^3.919.0",
28+
"@aws-sdk/lib-storage": "^3.919.0",
2729
"chalk": "^4.1.1",
2830
"fs-extra": "^8.1.0",
2931
"mime-types": "^2.1.26",

packages/amplify-category-notifications/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@aws-amplify/amplify-prompts": "2.8.7",
3232
"@aws-amplify/amplify-provider-awscloudformation": "8.11.14",
3333
"@aws-sdk/client-iam": "^3.919.0",
34-
"@aws-sdk/client-pinpoint": "^3.919.0",
34+
"@aws-sdk/client-pinpoint": "3.901.0",
3535
"@smithy/node-http-handler": "^4.4.3",
3636
"chalk": "^4.1.1",
3737
"fs-extra": "^8.1.0",

packages/amplify-console-hosting/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@aws-sdk/client-amplify": "^3.919.0",
1313
"@aws-sdk/client-s3": "^3.919.0",
1414
"archiver": "^7.0.1",
15-
"aws-sdk": "^2.1692.0",
1615
"chalk": "^4.1.1",
1716
"cli-table3": "^0.6.0",
1817
"execa": "^5.1.1",

packages/amplify-container-hosting/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"@aws-amplify/amplify-category-api": "^5.15.1",
3030
"@aws-amplify/amplify-cli-core": "4.4.3",
3131
"@aws-amplify/amplify-environment-parameters": "1.9.22",
32+
"@aws-sdk/client-s3": "^3.919.0",
33+
"@aws-sdk/lib-storage": "^3.919.0",
3234
"fs-extra": "^8.1.0",
3335
"inquirer": "^7.3.3",
3436
"mime-types": "^2.1.26",

packages/amplify-container-hosting/src/lib/ElasticContainer/file-uploader.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
const fs = require('fs-extra');
22
const mime = require('mime-types');
33
const constants = require('../constants');
4-
const S3 = require('aws-sdk/clients/s3');
4+
const { S3Client } = require('@aws-sdk/client-s3');
5+
const { Upload } = require('@aws-sdk/lib-storage');
56

67
export async function getS3Client(context, action) {
78
const providerPlugins = context.amplify.getProviderPlugins(context);
89
const provider = require(providerPlugins[constants.providerName]);
910
const config = await provider.getConfiguredAWSClientConfig(context, constants.CategoryName, action);
10-
return new S3(config);
11+
return new S3Client(config);
1112
}
1213

1314
export async function uploadFile(s3Client, bucketName, filePath, fileKey) {
@@ -20,7 +21,12 @@ export async function uploadFile(s3Client, bucketName, filePath, fileKey) {
2021
ContentType: contentType || 'text/plain',
2122
};
2223

23-
const data = await s3Client.upload(uploadParams).promise();
24+
const upload = new Upload({
25+
client: s3Client,
26+
params: uploadParams,
27+
});
28+
29+
const data = await upload.done();
2430

2531
return data;
2632
}

packages/amplify-e2e-core/package.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,30 @@
2323
},
2424
"dependencies": {
2525
"@aws-amplify/amplify-cli-core": "4.4.3",
26-
"@aws-sdk/client-pinpoint": "^3.919.0",
26+
"@aws-sdk/client-amplifybackend": "^3.919.0",
27+
"@aws-sdk/client-amplifyuibuilder": "^3.919.0",
28+
"@aws-sdk/client-appsync": "^3.919.0",
29+
"@aws-sdk/client-cloudformation": "^3.919.0",
30+
"@aws-sdk/client-cloudwatch-events": "^3.919.0",
31+
"@aws-sdk/client-cloudwatch-logs": "^3.919.0",
32+
"@aws-sdk/client-cognito-identity": "^3.919.0",
33+
"@aws-sdk/client-cognito-identity-provider": "^3.919.0",
34+
"@aws-sdk/client-dynamodb": "^3.919.0",
35+
"@aws-sdk/client-iam": "^3.919.0",
36+
"@aws-sdk/client-kinesis": "^3.919.0",
37+
"@aws-sdk/client-lambda": "^3.919.0",
38+
"@aws-sdk/client-lex-model-building-service": "^3.919.0",
39+
"@aws-sdk/client-location": "^3.919.0",
40+
"@aws-sdk/client-pinpoint": "3.901.0",
41+
"@aws-sdk/client-rekognition": "^3.919.0",
42+
"@aws-sdk/client-s3": "^3.919.0",
43+
"@aws-sdk/client-ssm": "^3.919.0",
2744
"@aws-sdk/client-sts": "^3.919.0",
2845
"@aws-sdk/credential-providers": "^3.919.0",
46+
"@aws-sdk/lib-dynamodb": "^3.919.0",
2947
"amplify-headless-interface": "1.17.8",
3048
"aws-amplify": "^5.3.16",
3149
"aws-appsync": "^4.1.1",
32-
"aws-sdk": "^2.1464.0",
3350
"chalk": "^4.1.1",
3451
"dotenv": "^8.2.0",
3552
"execa": "^5.1.1",

0 commit comments

Comments
 (0)