Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage): add x-id query to applicable s3 apis #14251

Draft
wants to merge 3 commits into
base: feat/monitoring-instrument/main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/push-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
on:
push:
branches:
- replace-with-your-branch
- feat/monitoring-instrument/x-id

jobs:
e2e:
Expand Down
10 changes: 5 additions & 5 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@
"name": "[Storage] copy (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ copy }",
"limit": "16.76 kB"
"limit": "16.79 kB"
},
{
"name": "[Storage] downloadData (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ downloadData }",
"limit": "17.12 kB"
"limit": "17.14 kB"
},
{
"name": "[Storage] getProperties (S3)",
Expand All @@ -514,7 +514,7 @@
"name": "[Storage] getUrl (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ getUrl }",
"limit": "17.61 kB"
"limit": "17.65 kB"
},
{
"name": "[Storage] list (S3)",
Expand All @@ -526,13 +526,13 @@
"name": "[Storage] remove (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ remove }",
"limit": "16.23 kB"
"limit": "16.27 kB"
},
{
"name": "[Storage] uploadData (S3)",
"path": "./dist/esm/storage/index.mjs",
"import": "{ uploadData }",
"limit": "23.46 kB"
"limit": "23.49 kB"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const abortMultipartUploadHappyCase: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?uploadId=uploadId',
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?x-id=AbortMultipartUpload&uploadId=uploadId',
}),
method: 'DELETE',
}),
Expand Down Expand Up @@ -60,7 +60,7 @@ const abortMultipartUploadHappyCaseCustomEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key?uploadId=uploadId',
href: 'https://custom.endpoint.com/bucket/key?x-id=AbortMultipartUpload&uploadId=uploadId',
}),
}),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const copyObjectHappyCase: ApiFunctionalTestCase<typeof copyObject> = [
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3.us-east-1.amazonaws.com/key',
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?x-id=CopyObject',
}),
method: 'PUT',
headers: expect.objectContaining({
Expand Down Expand Up @@ -76,7 +76,7 @@ const copyObjectHappyCaseCustomEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key',
href: 'https://custom.endpoint.com/bucket/key?x-id=CopyObject',
}),
}),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const deleteObjectHappyCase: ApiFunctionalTestCase<typeof deleteObject> = [
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3.us-east-1.amazonaws.com/key',
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?x-id=DeleteObject',
}),
method: 'DELETE',
}),
Expand Down Expand Up @@ -53,7 +53,7 @@ const deleteObjectHappyCaseCustomEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key',
href: 'https://custom.endpoint.com/bucket/key?x-id=DeleteObject',
}),
}),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const getObjectResponseHeaders = {
} as const;

export const expectedGetObjectUrl =
'https://bucket.s3.us-east-1.amazonaws.com/key';
'https://bucket.s3.us-east-1.amazonaws.com/key?x-id=GetObject';

// API Reference: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
const getObjectHappyCase: ApiFunctionalTestCase<typeof getObject> = [
Expand Down Expand Up @@ -159,7 +159,7 @@ const getObjectHappyCaseAccelerateEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3-accelerate.amazonaws.com/key',
href: 'https://bucket.s3-accelerate.amazonaws.com/key?x-id=GetObject',
}),
}),
{
Expand Down Expand Up @@ -189,7 +189,7 @@ const getObjectHappyCaseCustomEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key',
href: 'https://custom.endpoint.com/bucket/key?x-id=GetObject',
}),
}),
{
Expand Down Expand Up @@ -219,7 +219,7 @@ const getObjectErrorCaseAccelerateEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3-accelerate.amazonaws.com/key',
href: 'https://bucket.s3-accelerate.amazonaws.com/key?x-id=GetObject',
}),
}),
{
Expand Down Expand Up @@ -250,7 +250,7 @@ const getObjectErrorCaseInvalidCustomEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key',
href: 'https://custom.endpoint.com/bucket/key?x-id=GetObject',
}),
}),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const listPartsHappyCase: ApiFunctionalTestCase<typeof listParts> = [
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?uploadId=uploadId',
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?x-id=ListParts&uploadId=uploadId',
}),
method: 'GET',
}),
Expand Down Expand Up @@ -84,7 +84,7 @@ const listPartsHappyCaseCustomEndpoint: ApiFunctionalTestCase<
},
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key?uploadId=uploadId',
href: 'https://custom.endpoint.com/bucket/key?x-id=ListParts&uploadId=uploadId',
}),
}),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const putObjectHappyCase: ApiFunctionalTestCase<typeof putObject> = [
putObjectRequest,
expect.objectContaining({
url: expect.objectContaining({
href: 'https://bucket.s3.us-east-1.amazonaws.com/key',
href: 'https://bucket.s3.us-east-1.amazonaws.com/key?x-id=PutObject',
}),
headers: expect.objectContaining(expectedPutObjectRequestHeaders),
body: 'body',
Expand All @@ -82,7 +82,7 @@ const putObjectHappyCaseCustomEndpoint: ApiFunctionalTestCase<
putObjectRequest,
expect.objectContaining({
url: expect.objectContaining({
href: 'https://custom.endpoint.com/bucket/key',
href: 'https://custom.endpoint.com/bucket/key?x-id=PutObject',
}),
}),
putObjectSuccessResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const abortMultipartUploadSerializer = (
url.pathname = serializePathnameObjectKey(url, input.Key);
validateS3RequiredParameter(!!input.UploadId, 'UploadId');
url.search = new AmplifyUrlSearchParams({
'x-id': 'AbortMultipartUpload',
uploadId: input.UploadId,
}).toString();
validateObjectUrl({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
HttpResponse,
parseMetadata,
} from '@aws-amplify/core/internals/aws-client-utils';
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
import {
AmplifyUrl,
AmplifyUrlSearchParams,
} from '@aws-amplify/core/internals/utils';
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import {
Expand Down Expand Up @@ -68,6 +71,9 @@ const copyObjectSerializer = async (
const url = new AmplifyUrl(endpoint.url.toString());
validateS3RequiredParameter(!!input.Key, 'Key');
url.pathname = serializePathnameObjectKey(url, input.Key);
url.search = new AmplifyUrlSearchParams({
'x-id': 'CopyObject',
}).toString();
validateObjectUrl({
bucketName: input.Bucket,
key: input.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
HttpResponse,
parseMetadata,
} from '@aws-amplify/core/internals/aws-client-utils';
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
import {
AmplifyUrl,
AmplifyUrlSearchParams,
} from '@aws-amplify/core/internals/utils';
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import {
Expand Down Expand Up @@ -41,6 +44,9 @@ const deleteObjectSerializer = (
const url = new AmplifyUrl(endpoint.url.toString());
validateS3RequiredParameter(!!input.Key, 'Key');
url.pathname = serializePathnameObjectKey(url, input.Key);
url.search = new AmplifyUrlSearchParams({
'x-id': 'DeleteObject',
}).toString();
validateObjectUrl({
bucketName: input.Bucket,
key: input.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
presignUrl,
} from '@aws-amplify/core/internals/aws-client-utils';
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
import {
AmplifyUrl,
AmplifyUrlSearchParams,
} from '@aws-amplify/core/internals/utils';

import {
CONTENT_SHA256_HEADER,
Expand Down Expand Up @@ -61,6 +64,9 @@ const getObjectSerializer = async (
const url = new AmplifyUrl(endpoint.url.toString());
validateS3RequiredParameter(!!input.Key, 'Key');
url.pathname = serializePathnameObjectKey(url, input.Key);
url.search = new AmplifyUrlSearchParams({
'x-id': 'GetObject',
}).toString();
validateObjectUrl({
bucketName: input.Bucket,
key: input.Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const listPartsSerializer = async (
url.pathname = serializePathnameObjectKey(url, input.Key);
validateS3RequiredParameter(!!input.UploadId, 'UploadId');
url.search = new AmplifyUrlSearchParams({
'x-id': 'ListParts',
uploadId: input.UploadId,
}).toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
HttpResponse,
parseMetadata,
} from '@aws-amplify/core/internals/aws-client-utils';
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
import {
AmplifyUrl,
AmplifyUrlSearchParams,
} from '@aws-amplify/core/internals/utils';
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';

import {
Expand Down Expand Up @@ -69,6 +72,9 @@ const putObjectSerializer = async (
const url = new AmplifyUrl(endpoint.url.toString());
validateS3RequiredParameter(!!input.Key, 'Key');
url.pathname = serializePathnameObjectKey(url, input.Key);
url.search = new AmplifyUrlSearchParams({
'x-id': 'PutObject',
}).toString();
validateObjectUrl({
bucketName: input.Bucket,
key: input.Key,
Expand Down
Loading