This is my stack:
import * as cdk from "aws-cdk-lib";
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
import { Construct } from "constructs";
export class CdkImmersion2HelloCdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    // defines an AWS Lambda resource
    const hello = new Function(this, "HelloHandler", {
      runtime: Runtime.NODEJS_18_X, // execution environment
      code: Code.fromAsset("lambda"), // code loaded from "lambda" directory
      handler: "hello.handler", // file is "hello", function is "handler"
    });
  }
}
and this is my function code:
exports.handler = async function (event) {
  console.log("request:", JSON.stringify(event, undefined, 2));
  return {
    statusCode: 200,
    headers: { "Content-Type": "text/plain" },
    body: `Hello, CDK! You've hit ${event.path}\n`,
  };
};
When I run cdk synth the cloud formation template builds fine, but when I attempt to deploy it with:
cdk deploy
I get the following error:
❌  CdkImmersion2HelloCdkStack failed: Error: The stack named CdkImmersion2HelloCdkStack 
failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Cannot 
invoke "String.contains(java.lang.CharSequence)" because "errorMsg" is null" 
(RequestToken: <some-token>, HandlerErrorCode: InternalFailure)
What's causing this?
This is my stack:
import * as cdk from "aws-cdk-lib";
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
import { Construct } from "constructs";
export class CdkImmersion2HelloCdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    // defines an AWS Lambda resource
    const hello = new Function(this, "HelloHandler", {
      runtime: Runtime.NODEJS_18_X, // execution environment
      code: Code.fromAsset("lambda"), // code loaded from "lambda" directory
      handler: "hello.handler", // file is "hello", function is "handler"
    });
  }
}
and this is my function code:
exports.handler = async function (event) {
  console.log("request:", JSON.stringify(event, undefined, 2));
  return {
    statusCode: 200,
    headers: { "Content-Type": "text/plain" },
    body: `Hello, CDK! You've hit ${event.path}\n`,
  };
};
When I run cdk synth the cloud formation template builds fine, but when I attempt to deploy it with:
cdk deploy
I get the following error:
❌  CdkImmersion2HelloCdkStack failed: Error: The stack named CdkImmersion2HelloCdkStack 
failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Cannot 
invoke "String.contains(java.lang.CharSequence)" because "errorMsg" is null" 
(RequestToken: <some-token>, HandlerErrorCode: InternalFailure)
What's causing this?
This was caused by an internal issue on AWS. The giveaway was when I searched this error nothing was coming up at all. I went onto the AWS Service Health Page and found an issue registered with AWS IAM:
Once this issue was resolved, my stack was deployed as expected.
