gpt4 book ai didi

javascript - 从 AWS Lambda JS SDK 访问 EC2 资源

转载 作者:搜寻专家 更新时间:2023-11-01 00:31:01 26 4
gpt4 key购买 nike

我正在编写一个函数,它需要向 EC2 发出一些请求以创建和删除快照。但是,目前 Lambda 中没有直接使用 EC2 资源发出请求的功能。我正在尝试使用 Class: AWS.TemporaryCredentials但是有一个通知写道:

Note: In order to create temporary credentials, you first need to have "master" credentials configured in AWS.Config.credentials. These master credentials are necessary to retrieve the temporary credentials, as well as refresh the credentials when they expire.

所以我不确定如何存储凭证,因为这个 Lambda 只是一个函数。

最佳答案

为了让您的 Lambda 函数发出 EC2 请求,您必须创建一个具有必要权限的 IAM Angular 色,然后将该 Angular 色与您的 IAM 函数相关联。 AWS Lambda CreateFunction API 请求有一个名为 Role 的必需参数,它是您创建的新 Angular 色的 ARN。这样,每次运行您的 Lambda 函数时,Lambda 都会创建临时 AWS 凭证供其使用,这些凭证具有 Angular 色中定义的权限。

关于javascript - 从 AWS Lambda JS SDK 访问 EC2 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34078055/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com