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.
- What is the difference between events and resourcePolicy in serverless ?
- 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.