@aws-sdk/middleware-sdk-ec2 3.290.0 → 3.291.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.credentials = exports.endpoint = exports.region = exports.MockSha256 = void 0;
3
+ exports.credentials = exports.region = exports.MockSha256 = void 0;
4
4
  class MockSha256 {
5
5
  constructor(secret) { }
6
6
  update(data) { }
@@ -11,12 +11,6 @@ class MockSha256 {
11
11
  exports.MockSha256 = MockSha256;
12
12
  const region = () => Promise.resolve("mock-region");
13
13
  exports.region = region;
14
- const endpoint = () => Promise.resolve({
15
- protocol: "https:",
16
- path: "/",
17
- hostname: "ec2.mock-region.amazonaws.com",
18
- });
19
- exports.endpoint = endpoint;
20
14
  const credentials = () => Promise.resolve({
21
15
  accessKeyId: "akid",
22
16
  secretAccessKey: "secret",
package/dist-cjs/index.js CHANGED
@@ -10,15 +10,21 @@ function copySnapshotPresignedUrlMiddleware(options) {
10
10
  return (next, context) => async (args) => {
11
11
  const { input } = args;
12
12
  if (!input.PresignedUrl) {
13
- const region = await options.region();
14
- const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(context.endpointV2);
15
- if (typeof options.regionInfoProvider === "function") {
16
- const regionInfo = await options.regionInfoProvider(input.SourceRegion);
17
- resolvedEndpoint.hostname = (regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.hostname) || `ec2.${input.SourceRegion}.amazonaws.com`;
18
- }
19
- else {
20
- resolvedEndpoint.hostname = `ec2.${input.SourceRegion}.amazonaws.com`;
21
- }
13
+ const destinationRegion = await options.region();
14
+ const endpoint = await (0, middleware_endpoint_1.getEndpointFromInstructions)(input, {
15
+ getEndpointParameterInstructions() {
16
+ return {
17
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
18
+ Endpoint: { type: "builtInParams", name: "endpoint" },
19
+ Region: { type: "builtInParams", name: "region" },
20
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
21
+ };
22
+ },
23
+ }, {
24
+ ...options,
25
+ region: input.SourceRegion,
26
+ });
27
+ const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(endpoint);
22
28
  const request = new protocol_http_1.HttpRequest({
23
29
  ...resolvedEndpoint,
24
30
  protocol: "https",
@@ -30,7 +36,7 @@ function copySnapshotPresignedUrlMiddleware(options) {
30
36
  Version: version,
31
37
  SourceRegion: input.SourceRegion,
32
38
  SourceSnapshotId: input.SourceSnapshotId,
33
- DestinationRegion: region,
39
+ DestinationRegion: destinationRegion,
34
40
  },
35
41
  });
36
42
  const signer = new signature_v4_1.SignatureV4({
@@ -47,7 +53,7 @@ function copySnapshotPresignedUrlMiddleware(options) {
47
53
  ...args,
48
54
  input: {
49
55
  ...args.input,
50
- DestinationRegion: region,
56
+ DestinationRegion: destinationRegion,
51
57
  PresignedUrl: (0, util_format_url_1.formatUrl)(presignedRequest),
52
58
  },
53
59
  };
@@ -6,11 +6,6 @@ export class MockSha256 {
6
6
  }
7
7
  }
8
8
  export const region = () => Promise.resolve("mock-region");
9
- export const endpoint = () => Promise.resolve({
10
- protocol: "https:",
11
- path: "/",
12
- hostname: "ec2.mock-region.amazonaws.com",
13
- });
14
9
  export const credentials = () => Promise.resolve({
15
10
  accessKeyId: "akid",
16
11
  secretAccessKey: "secret",
package/dist-es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { toEndpointV1 } from "@aws-sdk/middleware-endpoint";
1
+ import { getEndpointFromInstructions, toEndpointV1 } from "@aws-sdk/middleware-endpoint";
2
2
  import { HttpRequest } from "@aws-sdk/protocol-http";
3
3
  import { SignatureV4 } from "@aws-sdk/signature-v4";
4
4
  import { formatUrl } from "@aws-sdk/util-format-url";
@@ -7,15 +7,21 @@ export function copySnapshotPresignedUrlMiddleware(options) {
7
7
  return (next, context) => async (args) => {
8
8
  const { input } = args;
9
9
  if (!input.PresignedUrl) {
10
- const region = await options.region();
11
- const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : toEndpointV1(context.endpointV2);
12
- if (typeof options.regionInfoProvider === "function") {
13
- const regionInfo = await options.regionInfoProvider(input.SourceRegion);
14
- resolvedEndpoint.hostname = regionInfo?.hostname || `ec2.${input.SourceRegion}.amazonaws.com`;
15
- }
16
- else {
17
- resolvedEndpoint.hostname = `ec2.${input.SourceRegion}.amazonaws.com`;
18
- }
10
+ const destinationRegion = await options.region();
11
+ const endpoint = await getEndpointFromInstructions(input, {
12
+ getEndpointParameterInstructions() {
13
+ return {
14
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
15
+ Endpoint: { type: "builtInParams", name: "endpoint" },
16
+ Region: { type: "builtInParams", name: "region" },
17
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
18
+ };
19
+ },
20
+ }, {
21
+ ...options,
22
+ region: input.SourceRegion,
23
+ });
24
+ const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : toEndpointV1(endpoint);
19
25
  const request = new HttpRequest({
20
26
  ...resolvedEndpoint,
21
27
  protocol: "https",
@@ -27,7 +33,7 @@ export function copySnapshotPresignedUrlMiddleware(options) {
27
33
  Version: version,
28
34
  SourceRegion: input.SourceRegion,
29
35
  SourceSnapshotId: input.SourceSnapshotId,
30
- DestinationRegion: region,
36
+ DestinationRegion: destinationRegion,
31
37
  },
32
38
  });
33
39
  const signer = new SignatureV4({
@@ -44,7 +50,7 @@ export function copySnapshotPresignedUrlMiddleware(options) {
44
50
  ...args,
45
51
  input: {
46
52
  ...args.input,
47
- DestinationRegion: region,
53
+ DestinationRegion: destinationRegion,
48
54
  PresignedUrl: formatUrl(presignedRequest),
49
55
  },
50
56
  };
@@ -5,11 +5,6 @@ export declare class MockSha256 {
5
5
  digest(): Promise<Uint8Array>;
6
6
  }
7
7
  export declare const region: () => Promise<string>;
8
- export declare const endpoint: () => Promise<{
9
- protocol: string;
10
- path: string;
11
- hostname: string;
12
- }>;
13
8
  export declare const credentials: () => Promise<{
14
9
  accessKeyId: string;
15
10
  secretAccessKey: string;
@@ -5,11 +5,6 @@ export declare class MockSha256 {
5
5
  digest(): Promise<Uint8Array>;
6
6
  }
7
7
  export declare const region: () => Promise<string>;
8
- export declare const endpoint: () => Promise<{
9
- protocol: string;
10
- path: string;
11
- hostname: string;
12
- }>;
13
8
  export declare const credentials: () => Promise<{
14
9
  accessKeyId: string;
15
10
  secretAccessKey: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-ec2",
3
- "version": "3.290.0",
3
+ "version": "3.291.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",