# Policy to describe ec2 instances

**URL:** <https://forum.serverless.com/t/policy-to-describe-ec2-instances/2338>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [July 20, 2017, 10:52pm UTC](https://forum.serverless.com/t/policy-to-describe-ec2-instances/2338 "2017-07-20T22:52:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![khinester](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/khinester/32/315_2.png) [@khinester](https://forum.serverless.com/u/khinester)\
**Post date:** [July 20, 2017, 10:52pm UTC](https://forum.serverless.com/t/policy-to-describe-ec2-instances/2338/1 "2017-07-20T22:52:38Z")

</div>

Hello, I have the following serverless.yaml

```
service: ebs
provider:
  name: aws
  runtime: python2.7

iamRoleStatements:
  - Effect: "Allow"
    Action:
      - "logs:*"
    Resource: "arn:aws:logs:*:*:*"
  - Effect: "Allow"
    Action:
      - "ec2:Describe*"
    Resource: "*"
  - Effect: "Allow"
    Action:
      - "ec2:CreateSnapshot"
      - "ec2:ModifySnapshotAttribute"
      - "ec2:ResetSnapshotAttribute"
    Resource: ["*"]

```

when I try to invoke it, i get the following error:

```
"errorType": "ClientError",
"errorMessage": "An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation."

```

looking at the lambda role being created, these policies are not being added. if i manually modify the Role policy, the function executes.

what am i missing?

any advice is much appreciated

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [July 21, 2017, 5:55am UTC](https://forum.serverless.com/t/policy-to-describe-ec2-instances/2338/2 "2017-07-21T05:55:18Z")

</div>

The `iamRoleStatements` property (and its children) need to be indented another level i.e. they need to be under the `provider` property:

```auto
service: ebs
provider:
  name: aws
  runtime: python2.7

  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - ["logs:*"]
      Resource: "arn:aws:logs:*:*:*"
    - Effect: "Allow"
      Action:
        - "ec2:Describe*"
      Resource: "*"
    - Effect: "Allow"
      Action:
        - "ec2:CreateSnapshot"
        - "ec2:ModifySnapshotAttribute"
        - "ec2:ResetSnapshotAttribute"
      Resource: ["*"]

```

---

<div class="post-metadata">

**Author:** ![khinester](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/khinester/32/315_2.png) [@khinester](https://forum.serverless.com/u/khinester)\
**Post date:** [July 21, 2017, 7:58am UTC](https://forum.serverless.com/t/policy-to-describe-ec2-instances/2338/3 "2017-07-21T07:58:42Z")

</div>

thanks @rowanu, this fixed it

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [July 22, 2017, 9:07am UTC](https://forum.serverless.com/t/policy-to-describe-ec2-instances/2338/4 "2017-07-22T09:07:13Z")

</div>

No worries! I did exactly the same thing 4 days ago… 😃
