I'm trying to load a JSON config file to protect my AWS keys
a.FileSystemCredentials is not a constructor
at constructor.loadFromPath(aws - sdk.min.js: 46)
This error is preventing me from using AWS.config.loadFromPath('../../s3.config.json');
It works fine when i use the unprotected AWS.config.update([json]);
where json
is the actual jsonData
app.js:
AWS.config.loadFromPath('../../s3.config.json');
var hub = new AWS.S3({ params: {Bucket: 'mybucket'} });
s3.config.json
{ "accessKeyId": "keyid", "secretAccessKey": "secretkey", "region": "us-east-1" }
I have the same issue. You are probably loading the aws js sdk for browser.
As you can see: https://sdk.amazonaws.com/builder/js/, AWS.FileSystemCredentials
is not included, that is why FileSystemCredentials
is not a constructor (to be more specific it is undefined). It looks like you can only use AWS.config.loadFromPath
on server side (with something like node.js).
Loading credentials from a JSON document is not supported in browser scripts.You have to create an identity pool and give permission for the required access
const AWS = require('aws-sdk')
AWS.config.update({region: 'us-east-1'});
AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'ur pool id'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With