Files
n8n/packages/nodes-base/nodes/Aws/IAM/transport/index.ts
T
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

55 lines
1.3 KiB
TypeScript

import type {
IExecuteSingleFunctions,
IDataObject,
IHttpRequestOptions,
ILoadOptionsFunctions,
IPollFunctions,
JsonObject,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
import { BASE_URL } from '../helpers/constants';
const errorMapping: IDataObject = {
403: 'The AWS credentials are not valid!',
};
export async function awsApiRequest(
this: ILoadOptionsFunctions | IPollFunctions | IExecuteSingleFunctions,
opts: IHttpRequestOptions,
): Promise<IDataObject> {
const requestOptions: IHttpRequestOptions = {
baseURL: BASE_URL,
json: true,
...opts,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
...(opts.headers ?? {}),
},
};
if (opts.body) {
requestOptions.body = new URLSearchParams(opts.body as Record<string, string>).toString();
}
try {
const response = (await this.helpers.requestWithAuthentication.call(
this,
'aws',
requestOptions,
)) as IDataObject;
return response;
} catch (error) {
const statusCode = (error?.statusCode || error?.cause?.statusCode) as string;
if (statusCode && errorMapping[statusCode]) {
throw new NodeApiError(this.getNode(), {
message: `AWS error response [${statusCode}]: ${errorMapping[statusCode] as string}`,
});
} else {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
}