【问题标题】:Warned - no cfnRole set and unnecessary files was created after deploy警告 - 部署后未设置 cfnRole 和不必要的文件
【发布时间】:2020-03-04 17:57:57
【问题描述】:

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 文件。

【问题讨论】:

    标签: python-3.x amazon-web-services aws-lambda amazon-cloudformation serverless


    【解决方案1】:

    我按照以下步骤在 AWS IAM 中创建 cfn 角色解决了这个问题:

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

    下一步:权限

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

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

    设置角色后,需要复制其arn并在provider level 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
    

    这对我有用,我希望能有所帮助!

    【讨论】:

      猜你喜欢
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      • 2019-07-13
      • 1970-01-01
      相关资源
      最近更新 更多