# Difference between resourcePolicy and events in serverless.yaml

**URL:** https://forum.serverless.com/t/difference-between-resourcepolicy-and-events-in-serverless-yaml/15162
**Category:** Serverless Framework
**Tags:** aws, lambda, cloudformation
**Created:** [May 29, 2021, 5:48am UTC](https://forum.serverless.com/t/difference-between-resourcepolicy-and-events-in-serverless-yaml/15162 "2021-05-29T05:48:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Egalitarian](https://avatars.discourse-cdn.com/v4/letter/e/f14d63/32.png) [@Egalitarian](https://forum.serverless.com/u/Egalitarian)
#### Post date: [May 29, 2021, 5:48am UTC](https://forum.serverless.com/t/difference-between-resourcepolicy-and-events-in-serverless-yaml/15162/1 "2021-05-29T05:48:26Z")

</div>

I have a lambda which I have created using serverless framework. I want it to be invoked through cloudwatch logs. For this, I need to create a resource based policy in my AWS lambda. Since the cloudwatch logs which are invoking my lambda are created on the fly I can’t use resource name explicitly in events. I wanted to use regex but apparently lambda updation/creation fails with the error below.

` Member must satisfy regular expression pattern: [\.\-_/#A-Za-z0-9]+ (Service: AWSLogs; Status Code: 400; Error Code: InvalidParameterExceptio`

I wanted to know if I can create lambda invocation policy for log group with regex. I tried using resourcePolicy too but it doesn’t work. I have two questions which can help me move ahead and was looking for the help.

1. What is the difference between [events](https://www.serverless.com/framework/docs/providers/aws/events/cloudwatch-log/) and [resourcePolicy](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#resource-policy) in serverless ?
2. Any code pointers which can help me create a resource based policy on the lambda. Image of the policy details I want to create is below.  
 ![Screenshot 2021-05-29 at 11.00.41 AM](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/7/79503b976d90740cc41b8cdbea9d6722eaf172a3.png)
