File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ export type BasicAuthConfiguration = { type: 'basic' } & (
1818export type AuthConfiguration = { type : 'none' } | BasicAuthConfiguration ;
1919
2020export interface S3StoreConfiguration {
21- accessKey : string ;
22- secretKey : string ;
21+ detectCredentials : boolean ;
22+ accessKey ?: string ;
23+ secretKey ?: string ;
2324 bucket : string ;
2425 endpoint : string ;
2526 region : string ;
@@ -96,16 +97,17 @@ export function loadConfig() {
9697 }
9798 // for now, this works
9899 {
100+ store . detectCredentials ??= true ;
99101 store . accessKey = getEnv < string > (
100102 'STORE_ACCESS_KEY' ,
101103 store . accessKey ,
102- ! store . accessKey
103- ) . toString ( ) ;
104+ ! store . detectCredentials
105+ ) ? .toString ( ) ;
104106 store . secretKey = getEnv < string > (
105107 'STORE_SECRET_KEY' ,
106108 store . secretKey ,
107- ! store . secretKey
108- ) . toString ( ) ;
109+ ! store . detectCredentials
110+ ) ? .toString ( ) ;
109111 store . bucket = getEnv < string > (
110112 'STORE_BUCKET' ,
111113 store . bucket ?? 'notea' ,
Original file line number Diff line number Diff line change @@ -40,11 +40,14 @@ export class StoreS3 extends StoreProvider {
4040 forcePathStyle : config . pathStyle ,
4141 region : config . region ,
4242 endpoint : config . endPoint ,
43- credentials : {
43+ credentials : ( ( config . accessKey && config . secretKey ) ? {
4444 accessKeyId : config . accessKey ,
4545 secretAccessKey : config . secretKey ,
46- } ,
46+ } : undefined ) ,
4747 } ) ;
48+ if ( ! config . accessKey || ! config . secretKey ) {
49+ console . log ( '[Notea] Environment variables STORE_ACCESS_KEY or STORE_SECRET_KEY is missing. Trying to use IAM role credentials instead ...' ) ;
50+ }
4851 this . config = config ;
4952 }
5053
You can’t perform that action at this time.
0 commit comments