title: Getting the following error when running lambda "errorMessage": "Cannot read property 'requestParameters' of undefined",
body: <p>I am trying to run a lambda to set log retention of log groups in AWS to 14 days, I pulled up the following .js code from the web but when I am running it I am getting an error  <code>"errorMessage": "Cannot read property 'requestParameters' of undefined",. Runtime of Nodejs is 8.10.</code></p>
  
  <p>Here is the .js I am running:</p>
  
  <pre><code>const AWS = require('aws-sdk');
  const cloudwatchLogs = new AWS.CloudWatchLogs();
  
  function setRetentionOfCloudwatchLogGroup(logGroupName, duration) {
      let params = {
          logGroupName : logGroupName,
          retentionInDays: duration
      };
      return cloudwatchLogs.putRetentionPolicy(params).promise();
  }
  
  exports.handler = async (event) =&gt; {
      const logGroupName = event.logGroupName ? event.logGroupName : event.detail.requestparameters.logGroupName;
      try {
          await setRetentionOfCloudwatchLogGroup(logGroupName, 14);
          console.log('Retention has been set to ' + logGroupName + 'for 2 weeks');
          return;
      } catch(error) {
          console.error(error);
          throw error;
      }
  };
  </code></pre>
  
  <p>Here is the error I am getting:</p>
  
  <pre><code>Response:
  {
    "errorType": "TypeError",
    "errorMessage": "Cannot read property 'requestParameters' of undefined",
    "trace": [
      "TypeError: Cannot read property 'requestParameters' of undefined",
      "    at Runtime.exports.handler (/var/task/index.js:14:81)",
      "    at Runtime.handleOnce (/var/runtime/Runtime.js:63:25)",
      "    at process._tickCallback (internal/process/next_tick.js:68:7)"
    ]
  }
  </code></pre>