@aws-sdk/middleware-sdk-ec2
Advanced tools
Comparing version 3.290.0 to 3.291.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.credentials = exports.endpoint = exports.region = exports.MockSha256 = void 0; | ||
exports.credentials = exports.region = exports.MockSha256 = void 0; | ||
class MockSha256 { | ||
@@ -14,8 +14,2 @@ constructor(secret) { } | ||
exports.region = region; | ||
const endpoint = () => Promise.resolve({ | ||
protocol: "https:", | ||
path: "/", | ||
hostname: "ec2.mock-region.amazonaws.com", | ||
}); | ||
exports.endpoint = endpoint; | ||
const credentials = () => Promise.resolve({ | ||
@@ -22,0 +16,0 @@ accessKeyId: "akid", |
@@ -13,11 +13,17 @@ "use strict"; | ||
if (!input.PresignedUrl) { | ||
const region = await options.region(); | ||
const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(context.endpointV2); | ||
if (typeof options.regionInfoProvider === "function") { | ||
const regionInfo = await options.regionInfoProvider(input.SourceRegion); | ||
resolvedEndpoint.hostname = (regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.hostname) || `ec2.${input.SourceRegion}.amazonaws.com`; | ||
} | ||
else { | ||
resolvedEndpoint.hostname = `ec2.${input.SourceRegion}.amazonaws.com`; | ||
} | ||
const destinationRegion = await options.region(); | ||
const endpoint = await (0, middleware_endpoint_1.getEndpointFromInstructions)(input, { | ||
getEndpointParameterInstructions() { | ||
return { | ||
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, | ||
Endpoint: { type: "builtInParams", name: "endpoint" }, | ||
Region: { type: "builtInParams", name: "region" }, | ||
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, | ||
}; | ||
}, | ||
}, { | ||
...options, | ||
region: input.SourceRegion, | ||
}); | ||
const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : (0, middleware_endpoint_1.toEndpointV1)(endpoint); | ||
const request = new protocol_http_1.HttpRequest({ | ||
@@ -34,3 +40,3 @@ ...resolvedEndpoint, | ||
SourceSnapshotId: input.SourceSnapshotId, | ||
DestinationRegion: region, | ||
DestinationRegion: destinationRegion, | ||
}, | ||
@@ -52,3 +58,3 @@ }); | ||
...args.input, | ||
DestinationRegion: region, | ||
DestinationRegion: destinationRegion, | ||
PresignedUrl: (0, util_format_url_1.formatUrl)(presignedRequest), | ||
@@ -55,0 +61,0 @@ }, |
@@ -9,7 +9,2 @@ export class MockSha256 { | ||
export const region = () => Promise.resolve("mock-region"); | ||
export const endpoint = () => Promise.resolve({ | ||
protocol: "https:", | ||
path: "/", | ||
hostname: "ec2.mock-region.amazonaws.com", | ||
}); | ||
export const credentials = () => Promise.resolve({ | ||
@@ -16,0 +11,0 @@ accessKeyId: "akid", |
@@ -1,2 +0,2 @@ | ||
import { toEndpointV1 } from "@aws-sdk/middleware-endpoint"; | ||
import { getEndpointFromInstructions, toEndpointV1 } from "@aws-sdk/middleware-endpoint"; | ||
import { HttpRequest } from "@aws-sdk/protocol-http"; | ||
@@ -10,11 +10,17 @@ import { SignatureV4 } from "@aws-sdk/signature-v4"; | ||
if (!input.PresignedUrl) { | ||
const region = await options.region(); | ||
const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : toEndpointV1(context.endpointV2); | ||
if (typeof options.regionInfoProvider === "function") { | ||
const regionInfo = await options.regionInfoProvider(input.SourceRegion); | ||
resolvedEndpoint.hostname = regionInfo?.hostname || `ec2.${input.SourceRegion}.amazonaws.com`; | ||
} | ||
else { | ||
resolvedEndpoint.hostname = `ec2.${input.SourceRegion}.amazonaws.com`; | ||
} | ||
const destinationRegion = await options.region(); | ||
const endpoint = await getEndpointFromInstructions(input, { | ||
getEndpointParameterInstructions() { | ||
return { | ||
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, | ||
Endpoint: { type: "builtInParams", name: "endpoint" }, | ||
Region: { type: "builtInParams", name: "region" }, | ||
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, | ||
}; | ||
}, | ||
}, { | ||
...options, | ||
region: input.SourceRegion, | ||
}); | ||
const resolvedEndpoint = typeof options.endpoint === "function" ? await options.endpoint() : toEndpointV1(endpoint); | ||
const request = new HttpRequest({ | ||
@@ -31,3 +37,3 @@ ...resolvedEndpoint, | ||
SourceSnapshotId: input.SourceSnapshotId, | ||
DestinationRegion: region, | ||
DestinationRegion: destinationRegion, | ||
}, | ||
@@ -49,3 +55,3 @@ }); | ||
...args.input, | ||
DestinationRegion: region, | ||
DestinationRegion: destinationRegion, | ||
PresignedUrl: formatUrl(presignedRequest), | ||
@@ -52,0 +58,0 @@ }, |
@@ -8,7 +8,2 @@ import { SourceData } from "@aws-sdk/types"; | ||
export declare const region: () => Promise<string>; | ||
export declare const endpoint: () => Promise<{ | ||
protocol: string; | ||
path: string; | ||
hostname: string; | ||
}>; | ||
export declare const credentials: () => Promise<{ | ||
@@ -15,0 +10,0 @@ accessKeyId: string; |
@@ -8,7 +8,2 @@ import { SourceData } from "@aws-sdk/types"; | ||
export declare const region: () => Promise<string>; | ||
export declare const endpoint: () => Promise<{ | ||
protocol: string; | ||
path: string; | ||
hostname: string; | ||
}>; | ||
export declare const credentials: () => Promise<{ | ||
@@ -15,0 +10,0 @@ accessKeyId: string; |
{ | ||
"name": "@aws-sdk/middleware-sdk-ec2", | ||
"version": "3.290.0", | ||
"version": "3.291.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", |
23328
250