signAwsRequestHeaders
Sign an HTTP request with SigV4 headers (Authorization header style).
function signAwsRequestHeaders(options): Promise<Record<string, string>>;
Defined in: src/utils/aws/sigv4.ts:314
Sign an HTTP request with SigV4 headers (Authorization header style).
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SignAwsRequestOptions | The request, scope, and credentials to sign with. |
Returns
Promise<Record<string, string>>
Headers to send with the request, including authorization.
Remarks
Returns the caller’s headers plus x-amz-date, authorization, and — when the credentials carry a session token — x-amz-security-token. The host header is always included in the signature (derived from the URL) but is not returned, because fetch sets it automatically.
Any headers passed in options.headers are also signed, so their values must be sent on the request unchanged.
Example
const headers = await signAwsRequestHeaders({
method: 'POST',
url: 'https://polly.us-east-1.amazonaws.com/v1/speech',
service: 'polly',
region: 'us-east-1',
credentials: { accessKeyId, secretAccessKey },
body: JSON.stringify(request),
});
await fetch(url, { method: 'POST', headers, body });