Improve code readability Aws node

This commit is contained in:
Matheus Cansian
2019-10-05 10:27:19 -03:00
parent ec9d65b2e0
commit edb81ef259
2 changed files with 37 additions and 41 deletions

View File

@@ -0,0 +1,23 @@
import {
IExecuteFunctions,
IHookFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import { config } from 'aws-sdk';
import { OptionsWithUri } from 'request';
export async function awsConfigCredentials(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions): Promise<void> {
const credentials = this.getCredentials('aws');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
}
config.update({
region: `${credentials.region}`,
accessKeyId: `${credentials.accessKeyId}`,
secretAccessKey: `${credentials.secretAccessKey}`,
});
}