title: Force Lambda Function to Fail
body: <p>I want to ensure a Lambda function fails when certain conditions are met.</p>
  <p>After some Googling I ended up with variations on the below code, but even in the Lambda UI, when I 'test' , it still succeeds and simply spits the json out as as a response.</p>
  <p>Ultimately I will be invoking the function from Terraform, and I need a solid fail in order to prevent subsequent code from continuing.</p>
  <p>Any guidance appreciated :)</p>
  <pre><code>def lambda_handler(event, context):
      x = 'dummy'
      
      return {
          &quot;isBase64Encoded&quot; : True,
          &quot;statusCode&quot;: &quot;400&quot;,
          &quot;headers&quot;: {},
          &quot;body&quot;: &quot;My error text&quot;
  }
  </code></pre>