gpt4 book ai didi

python-3.x - 警告 - 部署后未设置 cfnRole 且创建了不必要的文件

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

No cfnRole warned and unnecessary files was created after deploy

Serverless: Safeguards Processing...
Serverless: Safeguards Results:

Summary --------------------------------------------------

passed - no-unsafe-wildcard-iam-permissions
passed - framework-version
warned - require-cfn-role
passed - allowed-runtimes
passed - no-secret-env-vars
passed - allowed-regions
passed - allowed-stages

Details --------------------------------------------------

1) Warned - no cfnRole set
details: http://slss.io/sg-require-cfn-role
Require the cfnRole option, which specifies a particular role for CloudFormation to assume while deploying.
  1. 我去过写得很详细的网站。详情:http://slss.io/sg-require-cfn-role无论如何,我不知道如何解决它。
  2. s_hello.py 和 s_hello2.py 始终在部署后生成。这是我的 serverless.yaml 文件
    service: myapp
app: sample-app
org: xxx
provider:
name: aws
runtime: python3.7
stage: dev
region: us-east-1

package:
individually: true
functions:
hello:
handler: src/handler/handler.hello
hello2:
handler: src/handler2/handler2.hello2

It's always happen although follow this site 。我的 Lambda 函数将创建“s_xxx.py(其中 xxx 是 handler.py 文件。

)

最佳答案

我按照以下步骤在 AWS IAM 中创建 cfn-role 解决了此问题:

角色 -> 创建角色 -> AWS 服务 -> 从列表中选择Cloud Formation

下一步:权限

您需要选择部署 lambda 函数所需的所有策略(S3FullAccess、SQSFullAccess、LambdaFullAccess...)

有一个强制AWSConfigRole允许无服务器框架获得此角色。

设置角色后,您需要复制其 arn 并在提供者级别 cfnRole 后面创建,如下所示:

provider:
name: aws
runtime: python3.7
stage: ${opt:stage, 'dev'}
profile: ${self:custom.deploy-profile.${opt:stage, 'dev'}}
region: us-west-2
environment:
TEMP: "/tmp"
cfnRole: arn:aws:iam::xxxxxxxxxx:role/cfn-Role

这对我来说是工作,我希望能有所帮助!

关于python-3.x - 警告 - 部署后未设置 cfnRole 且创建了不必要的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58760837/

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