1

在 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, if using AWS_CONFIG_FILE, 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 已经设置好了,还有什么其他原因会导致这个问题?

4

0 回答 0