简体   繁体   中英

Getting error while deploying lambda function using serverless framework

I am trying to deploy a hello world lambda function using serverless framework.

But I get below error, even i am not trying to create any role from my code, I am just using an existing role which has all the required permissions.

  An error occurred: EnterpriseLogAccessIamRole - API: iam:CreateRole User: arn:
aws:iam::id:user/userid is not authorized to perform: iam:Create
Role on resource: arn:aws:iam::id:role/lambdatest-dev-EnterpriseLogAcc
essIamRole-5M5Q3LBFTAP4.

Below is my yml file.

service: lambdatest
# app and org for use with dashboard.serverless.com
app: lambdatest-app
org: orgname

provider:
  name: aws
  role: arn:aws:iam::id:role/rolename
  runtime: python3.8

# you can overwrite defaults here
  stage: dev
  region: eu-west-1

# you can add statements to the Lambda function's IAM Role here
  # iamRoleStatements:
    # - Effect: "Allow"
      # Action:
        # - "s3:ListBucket"
      # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ]  }
    # - Effect: "Allow"
      # Action:
        # - "s3:PutObject"

      # Resource:
        # rolename:
          # Type: AWS::IAM::arn:aws:iam::id:role/rolename
          #etc etc
        # functions:
          # hello:
            # role: arn:aws:iam::id:role/rolename
        # Fn::Join:
          # - ""
          # - - "arn:aws:s3:::"
            # - "Ref" : "ServerlessDeploymentBucket"
            # - "/*"


functions:
  hello:
    handler: handler.hello

This means the user credentials you are using to run the framework (the one you configured with the $ serverless config credentials ) don't have the proper IAM permissions.

Make sure the user you are using has the IAMFullAccess resource policy.

You have role: arn:aws:iam::id:role/rolename. Maybe you need to replace this with a real role name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM