我正在开发 React/Node.js 应用程序,并尝试从 ~/.aws/credentials 文件读取我的 IAM 用户凭证。我正在尝试使用 @aws-sdk/credential-providers 节点包中的 fromIni 。根据AWS SDK v3文档,我可以执行以下操作:
\nimport { fromIni } from "@aws-sdk/credential-providers"; // ES6 import\n// const { fromIni } = require("@aws-sdk/credential-providers"); // CommonJS import\n\nconst client = new FooClient({\n credentials: fromIni({\n // Optional. The configuration profile to use. If not specified, the provider will use the value\n // in the `AWS_PROFILE` environment variable or a default of `default`.\n profile: "profile",\n // Optional. The path to the shared credentials file. If not …Run Code Online (Sandbox Code Playgroud)