AWS 检索参数存储值,CredentialsError:配置中缺少凭证

问题描述

在 Angular/Typescript 上尝试根据名称从 AWS 上的 Parameter Store 检索值。

错误信息:

 ERROR Error: Uncaught (in promise): CredentialsError: Missing credentials in config,if using AWS_CONfig_FILE,set AWS_SDK_LOAD_CONfig=1
    CredentialsError: Missing credentials in config,set AWS_SDK_LOAD_CONfig=1

代码实现:

import { SSM } from "aws-sdk";


const getParameterWorker = async (name:string,decrypt:boolean) : Promise<string> => {
  const ssm = new SSM();
  const result = await ssm
  .getParameter({ Name: name,WithDecryption: decrypt })
  .promise();
  return result.Parameter.Value;
}

export const getParameter = async (name:string) : Promise<string> => {
   return getParameterWorker(name,false);
}

async ngOnInit() {
  const records = await getParameter("parameter_path_name");
   .
   .
   .
}

但是,AWS_SDK_LOAD_CONfig=1 已经设置好了,还有什么原因会导致这个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)