# How assign properly a in-built AWS role to a lambda deployment serverless.yml

**URL:** <https://forum.serverless.com/t/how-assign-properly-a-in-built-aws-role-to-a-lambda-deployment-serverless-yml/8660>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [June 27, 2019, 8:08pm UTC](https://forum.serverless.com/t/how-assign-properly-a-in-built-aws-role-to-a-lambda-deployment-serverless-yml/8660 "2019-06-27T20:08:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndresUrregoAngel](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@AndresUrregoAngel](https://forum.serverless.com/u/AndresUrregoAngel)\
**Post date:** [June 27, 2019, 8:08pm UTC](https://forum.serverless.com/t/how-assign-properly-a-in-built-aws-role-to-a-lambda-deployment-serverless-yml/8660/1 "2019-06-27T20:08:34Z")

</div>

Hello guys,

I have created my serverless.yml where I try to assign a in-build role to my execution lambda function. Unfortunately the way I’m doing it is not handy. I have tried to follow the documentation but all the examples drag me into the footage of new role creating which is something I don’t need. Please check out my file content and let me know how to achieve what I attempt:

```
service: mylabs

provider:
  name: aws
  runtime: python3.6
  stage: dev
  memorySize: 512 # optional, in MB, default is 1024
  timeout: 10 # optional, in seconds, default is 6
  versionFunctions: false # optional, default is true
  tracing:
    lambda: true # optional, enables tracing for all functions (can be true (true equals 'Active') 'Active' or 'PassThrough')
  environment: # all the env variables are coming in here
    var1: 12
    var2: 32
  role: mydefaultrole     

functions:
    first-deployment:
        name: dm-my-function
        description: first function deploy by serverless
        runtime: python3.6 # this can be inherated from the provider definition
        handler: src/dm-function1.lambda_handler
        events:
            - schedule:
                rate: cron(0 9 * * ? *)
                name: ${self:functions.first-deployment.name}

resources:
    Resources:
        mydefaultrole:
            role: 'arn:aws:iam::account:role/lambdabasicrole'
```

---

<div class="post-metadata">

**Author:** ![AndresUrregoAngel](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@AndresUrregoAngel](https://forum.serverless.com/u/AndresUrregoAngel)\
**Post date:** [June 27, 2019, 8:34pm UTC](https://forum.serverless.com/t/how-assign-properly-a-in-built-aws-role-to-a-lambda-deployment-serverless-yml/8660/2 "2019-06-27T20:34:02Z")

</div>

This has been solved with the new version file:

```
service: mylabs

provider:
  name: aws
  runtime: python3.6
  stage: dev
  memorySize: 512 # optional, in MB, default is 1024
  timeout: 10 # optional, in seconds, default is 6
  versionFunctions: false # optional, default is true
  tracing:
    lambda: true # optional, enables tracing for all functions (can be true (true equals 'Active') 'Active' or 'PassThrough')
  environment: # all the env variables are coming in here
    var1: 12
    var2: 32
  role: mydefaultrole     

functions:
    first-deployment:
        name: dm-my-function
        description: first function deploy by serverless
        runtime: python3.6 # this can be inherated from the provider definition
        handler: src/dm-function1.lambda_handler
        role: 'arn:aws:iam::account:role/lambdabasicrole'
        events:
            - schedule:
                rate: cron(0 9 * * ? *)
                name: ${self:functions.first-deployment.name}
```
