- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 NestJS 应用程序中使用 aws 加密 sdk,下一个代码源显示了实现。
import { Controller, Get } from '@nestjs/common';
import {KmsKeyringNode, encrypt} from '@aws-crypto/client-node'
@Controller('encryption')
export class EncryptionController {
// constructor() {}
@Get()
async crypt() {
const generatorKeyId = "generatior key";
const masterKeyId = "master key id";
const keyring = new KmsKeyringNode({keyIds:[masterKeyId], generatorKeyId: generatorKeyId});
const plainText = "My passwords for senstive data";
const context = {
accountId: "100",
purpose: "youtube demo",
country: "Sri Lanka"
};
const { result } = await encrypt(keyring, plainText, { encryptionContext: context });
console.log(result)
}
}
Error: connect EHOSTUNREACH 169.254.169.254:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
message: 'Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1',
errno: 'EHOSTUNREACH',
code: 'CredentialsError',
syscall: 'connect',
address: '169.254.169.254',
port: 80,
time: 2020-06-09T11:41:47.638Z,
originalError: {
message: 'Could not load credentials from any providers',
errno: 'EHOSTUNREACH',
code: 'CredentialsError',
syscall: 'connect',
address: '169.254.169.254',
port: 80,
time: 2020-06-09T11:41:47.638Z,
originalError: {
message: 'EC2 Metadata roleName request returned error',
errno: 'EHOSTUNREACH',
code: 'EHOSTUNREACH',
syscall: 'connect',
address: '169.254.169.254',
port: 80,
time: 2020-06-09T11:41:47.637Z,
originalError: [Object]
}
}
}
AWS_SDK_LOAD_CONFIG=1
可变我在其他类似错误中的看法。
最佳答案
我有同样的问题。这让我很头疼,因为我在 AWS Fargate 中运行了它,并且在那里调试并不容易。
该错误意味着 Javascript SDK 找不到 AWS 凭证。
在这里,您可以看到 SDK 尝试从以下位置加载凭据的顺序:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html
我的错误很尴尬,我只是在我的环境变量中有一个错字。我的变量是 AWS_ACCESSS_KEY_ID
而不是 AWS_ACCESS_KEY_ID
. (很难看出区别,对吧?)
所以可能要仔细检查你的环境变量(或配置文件)的名称
关于node.js - "EC2 Metadata roleName request returned error"使用带有 NestJS 的 aws 加密库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62282013/
默认情况下,Ansible 在 main.yml 中查找角色的任务。我有太多 main.yml 文件,我想将其重命名为 rolename.yml 或更独特的名称。如何更改 Ansible 的默认行为以
使用 Cloudformation 创建新的 IAM 角色资源时,AWS::IAM::Role。 有一个可选的 RoleName 参数,我不确定何时包含 RoleName 参数或排除它是否是更好的做法
我正在努力向 ASP.NET MVC 应用程序添加授权,但遇到了障碍。我终于能够连接我们的自定义成员(member)资格提供商并为该应用程序进行身份验证。现在,正如预期的那样,如果我将 [Author
当我在 liferay 6.1.2 上部署 portlet 时,出现以下错误: 01:57:10,382 ERROR [pool-2-thread-1][PortletImpl:2253] Unabl
我正在尝试在 NestJS 应用程序中使用 aws 加密 sdk,下一个代码源显示了实现。 import { Controller, Get } from '@nestjs/common'; impo
问题如下:通读以了解您需要帮助回答什么... 我有 对比 2013 带有 Razor View 的 MVC 5 Dapper DAL 自定义 UserManager 和 UserStore/User
我是一名优秀的程序员,十分优秀!