Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warned - no cfnRole set and unnecessary files was created after deploy

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. I had been go to the site that write in details. details: http://slss.io/sg-require-cfn-role Anyway, I don't know how to fix it.
  2. s_hello.py & s_hello2.py always generated after deploy. This is my serverless.yaml file
    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 . My Lambda-function will create "s_xxx.py (Where xxx is handler.py file.

like image 944
SoSadTT Avatar asked Mar 04 '23 05:03

SoSadTT


1 Answers

I solved this issue creating a cfn-role in AWS IAM following these steps:

Roles -> Create Role -> AWS Service -> Select Cloud Formation from the list

Next: Permisions

You need to choose all the policies you need to deploy your lambda function (S3FullAccess, SQSFullAccess, LambdaFullAccess...)

There's one that it's mandatory AWSConfigRole who allows to serverless framework to get this role.

After setting the role, you need to copy its arn and create behind provider level cfnRole like this:

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

That's work for me, I hope to help!

like image 57
Eduardo Gelvis Avatar answered May 05 '23 11:05

Eduardo Gelvis