tweedegolf / storage-abstraction

Provides an abstraction layer for interacting with a storage; the storage can be local or in the cloud.
MIT License
107 stars 18 forks source link

S3 failure to initialise #48

Closed Pezmc closed 11 months ago

Pezmc commented 11 months ago

Being thrown by S3: CredentialsProviderError: Could not load credentials from any providers

Example:

const storageUrl = "s3://ACCESS_ID:ACCESS_SECRET@eu-north-1/bucket-name"
const storage = new Storage(storageUrl)

storage.init().catch((error) => {
  log.error('Error initializing storage:', error)
})
Pezmc commented 11 months ago

Possible cause is this line (introduced in https://github.com/tweedegolf/storage-abstraction/pull/43)

https://github.com/tweedegolf/storage-abstraction/blob/bc5ba791c1ee34bad6981b7d66b914f90e05056f/src/AdapterAmazonS3.ts#L58-L60

If endpoint ends up undefined, which it is for S3 normal, no credentials are passed to S3 client.

Config object being passed into the adapter is:

{
  type: 's3',
  accessKeyId: 'KEY_HERE',
  secretAccessKey: 'SECRET_HERE',
  region: 'eu-north-1',
  bucketName: 'bucker-name'
}
abudaan commented 11 months ago

Thanks, your fix has been merged and published to npm!