Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Missing credentials in config" with aws-amplify Storage

I recently upgraded from an older version of aws-amplify to version

"aws-amplify": "^1.0.2"

and when doing so I immediately started getting errors when trying to upload to my bucket. [WARN] 38:42.445 StorageClass - error uploading": CredentialsError: "Missing credentials in config"

After some digging I discovered that some new keys were added to the Storage configuration in the most recent version of aws-amplify; "credentials" and "level". The documentation does not mentioned these in any way, and I am unable to find exactly what value this "credentials" key needs in order to work properly (with a manual configuration of Auth and Storage). Anyone have any ideas of what this credentials object should look like?

like image 408
Cauliflower Avatar asked Jul 25 '18 19:07

Cauliflower


1 Answers

You do not need to set the credentials key manually, the Amplify is setting the credentials for the Storage class automatically. Since your environment was working prior the update the issue maybe related with aws-sdk packages. The issue is related with multiple aws-sdk packages in your node_modules folder. As a rule simple removing an aws-sdk folder is not working since your project files are cached. Below are steps how to fix the issue for a react-native project but you can adjust them according to your environment:

  1. Make sure you do not have aws-sdk under dependencies in your package.json file since aws-amplify already has AWS SDK included. If there is an aws-sdk in the package.json file run the command to remove it:

    $ npm uninstall aws-sdk --save
    
  2. Make sure you are using the latest version of aws-amplify package.

  3. Remove the package-lock.json file from your project folder (do not forget to create a copy of the file).

  4. Run

    $ rm -rf node_modules && npm install
    

    This command will remove your node_modules folder and reinstall all the packages according to the package.json file.

  5. Optionally you can clear your local caches by entering one-by-one the following commands:

    $ watchman watch-del-all
    $ rm -rf /tmp/haste-map-react-native-packager-*
    $ rm -rf /tmp/metro-bundler-cache-*
    
like image 144
Gramatton Avatar answered Oct 14 '22 20:10

Gramatton