title: How to pass values to a Lambda function in CloudWatch?
body: <p>What's the best way to wrap functions in a way that handles a ping from a CloudWatch timer? For example, take the lambda function below:</p>
  
  <pre><code>export const fn = (event, context, callback) =&gt; {
    const { year, make, model, } = event.queryStringParameters
  
    return otherFn({ year, make, model, })
      .then(res =&gt; response(callback, res))
      .catch(err =&gt; console.log(err))
  }
  </code></pre>
  
  <p>If I ping the function, it will error because there are no queryStringParameters on the CloudWatch request. Technically, this will still do the job of keeping the Lambda function warm (which is my goal), but I don't want to have a needlessly-long list of errors.</p>
  
  <p>I noticed that CloudWatch allows you to include inputs that (presumably) are passed to a Lambda function:</p>
  
  <p><a href="https://i.stack.imgur.com/u1BxW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/u1BxW.png" alt="configure input"></a></p>
  
  <p>What's the smartest way to wrap the function above so that it can accept a ping? Ideally it would look like this:</p>
  
  <pre><code>export const fn = (event, context, callback) =&gt; {
    if (event.ping) return ping(callback) // the ping function is an import to stay DRY
    const { year, make, model, } = event.queryStringParameters
  
    return otherFn({ year, make, model, })
      .then(res =&gt; response(callback, res))
      .catch(err =&gt; console.log(err))
  }
  </code></pre>
  
  <p>Where I would pass some JSON that allows me to alter the event, such as:</p>
  
  <pre><code>{ "ping": true }
  </code></pre>
  
  <p>I've read through the documentation for the inputs, but it's not at all clear to me what the various input types mean or how to use them...</p>