I'm getting the following error when running my react app locally which make an api request to AWS via the AWS-SDK:
CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
I've tried:
- I've tried exporting my aws credentials directly
- I already have my aws credentials set up in ~/.aws/credentials and I use the CLI everyday with no issue
- I've tried copying the ~/.aws directory to my project root
- I've tried using dotenv and a config file as suggested in these replies
This is how I'm making the request:
import AWS from 'aws-sdk';
import { useState, useEffect } from 'react';
const ssm = new AWS.SSM({ region: 'eu-west-1' });
export const useFetchParams = (initialValue) => {
    const [result, setResult] = useState(initialValue);
    useEffect(() => {
        const params = {
            Path: '/',
            MaxResults: '2',
            Recursive: true,
            WithDecryption: true
        };
        ssm.getParametersByPath(params, function (err, data) {
            if (err) console.log(err, err.stack);
            else setResult(data);
        });
    }, []);
    return result;
};
export default useFetchParams;
Any help would be massively appreciated. Thanks.
 
    