lemon-core
Version:
Lemon Serverless Micro-Service Platform
53 lines (52 loc) • 1.79 kB
TypeScript
import { CrendentialForAWS } from '../environ';
import { RuntimeConfigAwsCredentialIdentityProvider } from '@aws-sdk/types/dist-types/identity/AwsCredentialIdentity';
import { LemonEngine } from '../engine/types';
/**
* Check if the current environment is AWS Lambda
* @returns {boolean} - true if running in AWS Lambda environment
*/
export declare const isLambda: () => boolean;
/** returns only defined */
export declare const onlyDefined: <T extends object>(N: T, $def?: T) => T;
/**
* load json in sync.
*/
export declare const loadJsonSync: <T extends object = any>(name: string, def?: {}) => T;
/**
* load yml data via './data/<file>.yml'
*/
export declare const loadDataYml: <T extends object = any>(file: string, folder?: string) => T;
/**
* dynamic loading credentials by profile. (search PROFILE -> NAME)
*
* @returns {Promise<CrendentialForAWS>} - AWS credentials
*/
export declare const asyncCredentials: (profile?: string) => Promise<CrendentialForAWS>;
/**
* type: `AwsConfigParams`
* - parameters for AWS config.
* - used for `awsConfig()`
*/
export interface AwsConfigParams {
/** AWS region */
region?: string;
/** AWS profile */
profile?: string;
/** AWS credentials provider */
credentials?: RuntimeConfigAwsCredentialIdentityProvider;
}
/**
* load config for aws sdk
* - if `profile` is not defined, use `AWS_PROFILE` or `default`
* - if `region` is not defined, use `AWS_REGION` or `ap-northeast-2`
*
* ```
* # run with default profile
* $ npm run test:watch
*
* # run with `lemon` profile
* #npm run test:watch.lemon
*/
export declare const awsConfig: <T extends AwsConfigParams>($engine: LemonEngine, params?: string | T | (() => string)) => T & {
credentials?: RuntimeConfigAwsCredentialIdentityProvider;
};