I am trying to use AWS SSM in my project by the following way:
const AWS = require('aws-sdk')
const ssmClient = new AWS.SSM({
apiVersion: 'latest',
region: 'REGION'
});
export const localEnvironment = () => {
ssmClient.getParameter({
Name: `SSM-PATH`,
WithDecryption: true,
}, (err, data) => {
if (data?.Parameter) {
return data.Parameter
}
});}
In my ~/.aws/credentials, I have added the following:
[default]
aws_access_key_id = <YOUR_ACCESS_KEY_ID>
aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>
and can query the parameters using the AWS CLI. However, when I run it in my Reach APP, I get the following error:
"Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1"
Things that I have tried:
- I exported the access key ID and secret access key in my terminal as well as WS_SDK_LOAD_CONFIG=1 and no difference was obtained.
- I hardcoded the values in the code by the following way:
const SESConfig = { apiVersion: "VERSION", accessKeyId: process.env.AWS_ACCESS_KEY, accessSecretKey: process.env.AWS_SECRET_KEY, region: "REGION" } AWS.config.update(SESConfig);
The above worked as expected and I was able to retrieve the parameters. However, I want to keep it through the AWS credentials and I am not sure what I can do different to make it work. In addition, is it best practice to use a local environment variable files for storing these credentials?