MCPcopy Create free account
hub / github.com/lightdash/lightdash / parseBaseS3Config

Function parseBaseS3Config

packages/backend/src/config/parseConfig.ts:804–849  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

802};
803
804export const parseBaseS3Config = (): LightdashConfig['s3'] => {
805 const endpoint = process.env.S3_ENDPOINT;
806 const bucket = process.env.S3_BUCKET;
807 const region = process.env.S3_REGION;
808 const accessKey = process.env.S3_ACCESS_KEY;
809 const secretKey = process.env.S3_SECRET_KEY;
810 // Browser-facing S3 endpoint used when minting presigned URLs that the
811 // browser will fetch directly (e.g. PUT uploads for app images). In local
812 // dev the internal Docker hostname (http://minio:9000) is unreachable from
813 // the browser, so set this to http://localhost:9000. In production with
814 // real S3 this is typically unnecessary — omit it and the internal endpoint
815 // is used for signing, which already resolves publicly.
816 const publicEndpoint = process.env.S3_PUBLIC_ENDPOINT || undefined;
817 const forcePathStyle = process.env.S3_FORCE_PATH_STYLE === 'true';
818 const expirationTime = parseInt(
819 process.env.S3_EXPIRATION_TIME || '259200', // 3 days in seconds
820 10,
821 );
822 const useCredentialsFromRaw = getArrayFromCommaSeparatedList(
823 'S3_USE_CREDENTIALS_FROM',
824 );
825 const useCredentialsFrom = useCredentialsFromRaw
826 .map((v) => v.trim().toLowerCase())
827 .filter((v) => v.length > 0);
828
829 if (!endpoint || !bucket || !region) {
830 throw new ParseError(
831 'S3-compatible storage is required. Set S3_ENDPOINT, S3_BUCKET and S3_REGION (AWS S3, GCS, MinIO, etc.) - https://docs.lightdash.com/self-host/customize-deployment/environment-variables#s3',
832 {},
833 );
834 }
835
836 return {
837 endpoint,
838 publicEndpoint,
839 bucket,
840 region,
841 accessKey,
842 secretKey,
843 expirationTime,
844 forcePathStyle,
845 useCredentialsFrom: useCredentialsFrom.length
846 ? useCredentialsFrom
847 : undefined,
848 };
849};
850
851export const parseResultsS3Config = (): LightdashConfig['results']['s3'] => {
852 const baseS3Config = parseBaseS3Config();

Callers 5

parseResultsS3ConfigFunction · 0.85
parseUsageEventsS3ConfigFunction · 0.85
parseAppRuntimeConfigFunction · 0.85
parseConfigFunction · 0.85

Calls 1

Tested by

no test coverage detected