2

serverless.yml这是我的相关配置的片段:

plugins:
  - serverless-offline
  - serverless-offline-ssm

custom:
  serverless-offline:
    httpPort: 3031
    host: 0.0.0.0
  serverless-offline-ssm:
    stages:
      - dev
    ssm:
      "some-name-1": "some-value-1"
      "some-name-2": "some-value-2"

我的无服务器东西似乎运行没有问题。但是,当我尝试使用 lambda 访问 SSM 参数时,从 SSM 对象aws-sdk调用时出现错误:getParameter

Error: connect EHOSTDOWN 169.254.169.254:80 - Local (192.168.86.59:60659)
    at internalConnect (net.js:923:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:364:12)
    at net.js:1011:9
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  message: 'Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1',
  errno: 'EHOSTDOWN',
  code: 'CredentialsError',
  syscall: 'connect',
  address: '169.254.169.254',
  port: 80,
  time: 2021-03-23T22:53:32.218Z,
  originalError: {
    message: 'Could not load credentials from any providers',
    errno: 'EHOSTDOWN',
    code: 'CredentialsError',
    syscall: 'connect',
    address: '169.254.169.254',
    port: 80,
    time: 2021-03-23T22:53:32.217Z,
    originalError: {
      message: 'EC2 Metadata roleName request returned error',
      errno: 'EHOSTDOWN',
      code: 'EHOSTDOWN',
      syscall: 'connect',
      address: '169.254.169.254',
      port: 80,
      time: 2021-03-23T22:53:32.217Z,
      originalError: [Object]
    }
  }

似乎我需要为 SSM 对象提供一些配置以使其连接到我的serverless-offline-ssm,但我无法在任何地方找到该信息。有人为他们的本地测试做过类似的事情吗?

4

0 回答 0