'Why I can't access SSM parameter from Node application deployed to CloudFront in AWS?

I have a react frontend which is deployed in Cloudfront. In the Code when i run it locally and try to access SSM parameter, it was giving me an error.

import AWS from 'aws-sdk';
import config from "../internal/config";

const ssm = new AWS.SSM();
const paramList = {Names: [config.authPoolClientId, config.encodedAuthPoolClientSecret]}
const params = (await ssm.getParameters(paramList).promise()).Parameters;

It throws below error:

CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

Again I tried to pass the AWS credential as environment variable. But it still the same. Suggest a solution pls



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source