为什么我可以访问DynamoDB,但不能访问SSM?

Why can I access DynamoDB, but not SSM?

我目前正在访问 DynamoDB 和 SSM 的 AWS 基础设施上开发节点应用程序 运行。

我对 Node 的精通程度不足以创建 MVCE,但这些似乎与我相关:

const AWS = require('aws-sdk')
AWS.config.update({ region: 'eu-west-1' })
const ddb = new AWS.DynamoDB.DocumentClient()
const ssm = new AWS.SSM()

const ssmQueryParams = {
  Name: '/foo/bar/tablename',
  WithDecryption: true
}

let ssmQueryResult
ssmQueryResult = (await ssm.getParameter(ssmQueryParams).promise())

const tableName = ssmQueryResult.Parameter.Value

const ddbParams = {
  TableName: tableName,
  Key: {
    'foo_id': fooId
  }
}
const ddbQueryResult = (await ddb.get(ddbParams).promise())

所以我想从 SSM 获取 DynamoDB table 名称。如果我删除 SSM 部分,代码就可以工作。但是有了它,我得到

{ Error: connect EHOSTUNREACH 169.123.123.123:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
  message: 'Missing credentials in config',
  errno: 'EHOSTUNREACH',
  code: 'CredentialsError',
  syscall: 'connect',
  address: '169.123.123.123',
  port: 80,
  time: 2019-06-25T12:34:02.909Z,
  originalError:
   { message: 'Could not load credentials from any providers',
     errno: 'EHOSTUNREACH',
     code: 'CredentialsError',
     syscall: 'connect',
     address: '169.123.123.123',
     port: 80,
     time: 2019-06-25T12:34:02.909Z,
     originalError:
      { errno: 'EHOSTUNREACH',
        code: 'EHOSTUNREACH',
        syscall: 'connect',
        address: '169.123.123.123',
        port: 80,
        message: 'connect EHOSTUNREACH 169.123.123.123:80' } } }

那么,为什么我可以访问 DynamoDB 上的数据,但是当我想从 SSM 读取时,出现凭据错误?

编辑:将 accessKeyIdsecretAccessKey 添加到 AWS.config.update 不是一个选项。

我忘记提供 ARN

arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess

我给了

arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess