gpt4 book ai didi

amazon-web-services - 如何在无服务器 1.0 中更改 aws 凭据?

转载 作者:行者123 更新时间:2023-12-01 09:17:20 25 4
gpt4 key购买 nike

我尝试使用带有多个 AWS 凭证的无服务器 1.0。(在我的电脑上,安装的是1.3.0)

我发现一些描述“admin.env”可以在堆栈溢出或 github 问题中更改凭据,但我找不到如何编写以及将 admin.env 放在哪里。admin.env 有什么好的文档吗?

最佳答案

首先创建不同的配置文件。使用 cli(这适用于 1.3.0,不适用于 1.0.0,不确定您使用的是哪个,因为您提到了两者):

serverless config credentials --provider aws --key 1234 --secret 5678 --profile your-profile-name

然后在您的 serverless.yml 文件中,您可以设置要使用的配置文件:

provider:
name: aws
runtime: nodejs4.3
stage: dev
profile: your-profile-name

如果您想根据阶段自动部署到不同的配置文件,您可以定义变量并在 serverless.yml 文件中引用它们。

provider:
name: aws
runtime: nodejs4.3
stage: ${opt:stage, self:custom.defaultStage}
profile: ${self:custom.profiles.${self:provider.stage}}
custom:
defaultStage: dev
profiles:
dev: your-profile-name
prod: another-profile-name

或者您可以通过任何其他方式引用您的个人资料名称。阅读无服务器框架中的变量。您可以从另一个文件、cli 或同一个文件(如我给出的示例中)获取要使用的配置文件的名称。

关于变量的更多信息: https://serverless.com/framework/docs/providers/aws/guide/variables/

关于amazon-web-services - 如何在无服务器 1.0 中更改 aws 凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41070639/

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