AWS 尝试从文件系统读取配置

问题描述 投票:0回答:1

我正在尝试使用 AWS SES 从 Supabase 云功能发送电子邮件。我已经设置了 AWS 环境变量,但它仍然尝试从文件系统读取配置,但失败了,因为边缘运行时中没有文件系统?

我设置的环境变量是:

AWS_ACCESS_KEY_ID=key
AWS_SECRET_ACCESS_KEY=secret
AWS_REGION=us-east-2
AWS_DEFAULT_REGION=us-east-2
AWS_DEFAULT_PROFILE=default
AWS_SDK_LOAD_CONFIG=

我知道其中一些变量是多余的,但是,我现在正在尝试一切。

我不断收到的错误是:

runtime has escaped from the event loop unexpectedly: event loop error: TypeError [ERR_INVALID_ARG_TYPE]" argument must be of type string. Received null
    at assertPath (ext:deno_node/path/_util.ts:10:11)
    at join (ext:deno_node/path/_posix.ts:77:5)
    at getCredentialsFilepath (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@smithy/shared-ini-file-loader/2.3.1/dist-cjs/index.js:75:117)
    at loadSharedConfigFiles (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@smithy/shared-ini-file-loader/2.3.1/dist-cjs/index.js:132:22)
    at file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@smithy/node-config-provider/2.2.1/dist-cjs/index.js:51:105
    at file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@smithy/property-provider/2.1.1/dist-cjs/index.js:79:33
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async coalesceProvider (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@smithy/property-provider/2.1.1/dist-cjs/index.js:106:18)
    at async file:///tmp/sb-compile-edge-runtime/node_modules/localhost/@smithy/property-provider/2.1.1/dist-cjs/index.js:117:20

看起来它忘记了秘密在 env 中。

最后,也许是最重要的,当我运行这个时:

import {
  SESClient,
} from "npm:@aws-sdk/client-ses";
client = new SESClient();
console.log(await client.config.credentialDefaultProvider()());

它实际上记录了访问密钥和秘密,所以,为什么它仍然抛出运行时错误让我感到困惑

当然,直接传递凭据也行不通。

amazon-ses supabase deno aws-sdk-js
1个回答
0
投票

好吧,似乎在“类似节点”的环境中加载

@aws-sdk/client-ses
包时,它会沿着加载
node-config-provider
的路径前进,然后导致加载
shared-ini-file-loader

顾名思义,这个

shared-ini-file-loader
依赖于文件系统的功能。给定的堆栈跟踪指向这行代码

var getCredentialsFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CREDENTIALS_PATH] || (0, import_path.join)((0, import_getHomeDir2.getHomeDir)(), ".aws", "credentials"), "getCredentialsFilepath");

它试图确定主目录,如果没有文件系统,主目录当然不存在。您可以通过将

getHomeDir()
设置为某个虚拟值来阻止对
ENV_CREDENTIALS_PATH
的调用。这可能足以绕过该错误。但它也可能只是允许您在尝试访问文件系统的下一个函数在其他地方失败之前再迈出一步。我没有可以重现此内容的环境,因此这可能有效也可能无效,但似乎值得一试......

© www.soinside.com 2019 - 2024. All rights reserved.