service: edge-rewrite
provider:
  name: aws
  runtime: nodejs6.10
  stage: ${opt:stage, self:custom.defaultStage}
  profile: ${self:custom.profiles.${self:provider.stage}}   
  
custom:
  defaultStage: dev
  profiles:
    dev: foo

functions:
  redirects:
    handler: handler.handler
    role: edgeRewriteRole0
    memorySize: 128
    timeout: 1

plugins:
  - serverless-plugin-optimize
  - serverless-offline

package:
  individually: true

resources:
  Resources:
    edgeRewriteRole0:
      Type: AWS::IAM::Role
      Properties:
        RoleName: edgeRewriteRole0
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Principal:
                Service:
                  - lambda.amazonaws.com
                  - edgelambda.amazonaws.com
              Action: sts:AssumeRole
        Policies:
          - PolicyName: edgeRewriteRolePolicy0
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Action:
                    - logs:CreateLogGroup
                    - logs:CreateLogStream
                    - logs:PutLogEvents
                  Resource: arn:aws:logs:${opt:region, self:provider.region}::log-group:/aws/lambda/*:*:*
service: edge-rewrite
provider:
  name: aws
  runtime: nodejs6.10
  stage: ${opt:stage, self:custom.defaultStage}
  profile: ${self:custom.profiles.${self:provider.stage}}

custom:
  defaultStage: dev
  profiles:
    dev: foo

functions:
  redirects:
    handler: handler.handler
    role: edgeRewriteRole0
    memorySize: 128
    timeout: 1

plugins:
  - serverless-plugin-optimize
  - serverless-offline

package:
  individually: true

resources:
  Resources:
    edgeRewriteRole0:
      Type: AWS::IAM::Role
      Properties:
        RoleName: edgeRewriteRole-${self:provider.stage}
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Principal:
                Service:
                  - lambda.amazonaws.com
                  - edgelambda.amazonaws.com
              Action: sts:AssumeRole
        Policies:
          - PolicyName: edgeRewriteRolePolicy-${self:provider.stage}
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Action:
                    - logs:CreateLogGroup
                    - logs:CreateLogStream
                    - logs:PutLogEvents
                  Resource: arn:aws:logs:${opt:region, self:provider.region}::log-group:/aws/lambda/*:*:*

Use stage to differentiate the role and policy
Use stage to differentiate the role and policy
